Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 194489 Details for
Bug 344460
Bidi 3.7: [Coolbar] Chrevon is not updated during setOrientation()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for Linux.
patch201105011422_SWT_Linux.txt (text/plain), 895.52 KB, created by
mariavin
on 2011-05-02 10:21:08 EDT
(
hide
)
Description:
Patch for Linux.
Filename:
MIME Type:
Creator:
mariavin
Created:
2011-05-02 10:21:08 EDT
Size:
895.52 KB
patch
obsolete
>Index: .classpath >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt.examples/.classpath,v >retrieving revision 1.8 >diff -u -r1.8 .classpath >--- .classpath 24 Mar 2004 21:43:53 -0000 1.8 >+++ .classpath 1 May 2011 11:22:59 -0000 >@@ -3,5 +3,6 @@ > <classpathentry kind="src" path="src"/> > <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> > <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> >+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.swt"/> > <classpathentry kind="output" path="bin"/> > </classpath> >Index: MariasPatch >=================================================================== >RCS file: MariasPatch >diff -N MariasPatch >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ MariasPatch 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,12631 @@ >+ >+ >+ >+ >+Index: src/org/eclipse/swt/examples/mirroringTest/AlignableTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/AlignableTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/AlignableTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/AlignableTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,89 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++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 { >++ >++ /* Alignment Controls */ >++ Button leftButton, rightButton, centerButton; >++ >++ /* Alignment Group */ >++ Group alignmentGroup; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ AlignableTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Other" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ >++ /* Create the group */ >++ alignmentGroup = new Group (otherGroup, SWT.NONE); >++ alignmentGroup.setLayout (new GridLayout ()); >++ alignmentGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | >++ GridData.VERTICAL_ALIGN_FILL)); >++ alignmentGroup.setText (ControlExample.getResourceString("Alignment")); >++ >++ /* Create the controls */ >++ leftButton = new Button (alignmentGroup, SWT.RADIO); >++ leftButton.setText (ControlExample.getResourceString("Left")); >++ centerButton = new Button (alignmentGroup, SWT.RADIO); >++ centerButton.setText(ControlExample.getResourceString("Center")); >++ rightButton = new Button (alignmentGroup, SWT.RADIO); >++ rightButton.setText (ControlExample.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 (); >++ Widget [] widgets = getExampleWidgets (); >++ if (widgets.length != 0) { >++ leftButton.setSelection ((widgets [0].getStyle () & SWT.LEFT) != 0); >++ centerButton.setSelection ((widgets [0].getStyle () & SWT.CENTER) != 0); >++ rightButton.setSelection ((widgets [0].getStyle () & SWT.RIGHT) != 0); >++ } >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/BrowserTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/BrowserTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/BrowserTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/BrowserTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,347 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import java.io.BufferedReader; >++import java.io.IOException; >++import java.io.InputStream; >++import java.io.InputStreamReader; >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.browser.*; >++import org.eclipse.swt.events.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++ >++class BrowserTab extends Tab { >++ >++ /* Example widgets and groups that contain them */ >++ Browser browser; >++ Group browserGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button mozillaButton, webKitButton; >++ >++ String errorMessage, lastText, lastUrl; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ BrowserTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ void createBackgroundModeGroup () { >++ // Browser does not need a background mode group. >++ } >++ >++ void createColorAndFontGroup () { >++ // Browser does not need a color and font group. >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the browser */ >++ browserGroup = new Group (exampleGroup, SWT.NONE); >++ browserGroup.setLayout (new GridLayout ()); >++ browserGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ browserGroup.setText ("Browser"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (mozillaButton.getSelection ()) style |= SWT.MOZILLA; >++ if (webKitButton.getSelection ()) style |= SWT.WEBKIT; >++ >++ /* Create the example widgets */ >++ try { >++ browser = new Browser (browserGroup, style); >++ } catch (SWTError e) { // Probably missing browser >++ try { >++ browser = new Browser (browserGroup, style & ~(SWT.MOZILLA | SWT.WEBKIT)); >++ } catch (SWTError e2) { // Unsupported platform >++ errorMessage = e.getMessage(); >++ return; >++ } >++ MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); >++ String resourceString = (style & SWT.MOZILLA) != 0 ? "MozillaNotFound" : "WebKitNotFound"; >++ dialog.setMessage(ControlExample.getResourceString(resourceString, new String [] {e.getMessage()})); >++ dialog.open(); >++ } >++ >++ if (lastUrl != null) { >++ browser.setUrl(lastUrl); >++ } else if (lastText != null) { >++ browser.setText(lastText); >++ } else { >++ InputStream htmlStream= ControlExample.class.getResourceAsStream("browser-content.html"); >++ BufferedReader br= new BufferedReader(new InputStreamReader(htmlStream)); >++ StringBuffer sb= new StringBuffer(300); >++ try { >++ int read= 0; >++ while ((read= br.read()) != -1) >++ sb.append((char) read); >++ } catch (IOException e) { >++ log(e.getMessage()); >++ } finally { >++ try { >++ br.close(); >++ } catch (IOException e) { >++ log(e.getMessage()); >++ } >++ } >++ String text= sb.toString(); >++ browser.setText(text); >++ } >++ lastText = lastUrl = null; >++ } >++ >++ /** >++ * Creates the "Other" group. This is typically >++ * a child of the "Control" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ backgroundImageButton.dispose (); >++ } >++ >++ /** >++ * Creates the "Size" group. The "Size" group contains >++ * controls that allow the user to change the size of >++ * the example widgets. >++ */ >++ void createSizeGroup () { >++ super.createSizeGroup (); >++ >++ /* Set the default state for Browser to fill horizontally & vertically. */ >++ fillHButton.setSelection (true); >++ fillVButton.setSelection (true); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup () { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ mozillaButton = new Button (styleGroup, SWT.CHECK); >++ mozillaButton.setText ("SWT.MOZILLA"); >++ mozillaButton.addListener(SWT.Selection, new Listener() { >++ public void handleEvent(Event event) { >++ webKitButton.setSelection(false); >++ } >++ }); >++ webKitButton = new Button (styleGroup, SWT.CHECK); >++ webKitButton.setText ("SWT.WEBKIT"); >++ webKitButton.addListener(SWT.Selection, new Listener() { >++ public void handleEvent(Event event) { >++ mozillaButton.setSelection(false); >++ } >++ }); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ } >++ >++ /** >++ * Creates the tab folder page. >++ * >++ * @param tabFolder org.eclipse.swt.widgets.TabFolder >++ * @return the new page for the tab folder >++ */ >++ Composite createTabFolderPage (final TabFolder tabFolder) { >++ super.createTabFolderPage (tabFolder); >++ >++ /* >++ * Add a resize listener to the tabFolderPage so that >++ * if the user types into the example widget to change >++ * its preferred size, and then resizes the shell, we >++ * recalculate the preferred size correctly. >++ */ >++ tabFolderPage.addControlListener(new ControlAdapter() { >++ public void controlResized(ControlEvent e) { >++ setExampleWidgetSize (); >++ } >++ }); >++ >++ /* >++ * Add a selection listener to the tabFolder to bring up a >++ * dialog if this platform does not support the Browser. >++ */ >++ tabFolder.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ if (errorMessage != null && tabFolder.getSelection()[0].getText().equals(getTabText())) { >++ MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); >++ dialog.setMessage(ControlExample.getResourceString("BrowserNotFound", new String [] {errorMessage})); >++ dialog.open(); >++ } >++ } >++ }); >++ >++ return tabFolderPage; >++ } >++ >++ /** >++ * Disposes the "Example" widgets. >++ */ >++ void disposeExampleWidgets () { >++ /* store the state of the Browser if applicable */ >++ if (browser != null) { >++ String url = browser.getUrl(); >++ if (url.length() > 0 && !url.equals("about:blank")) { //$NON-NLS-1$ >++ lastUrl = url; >++ } else { >++ String text = browser.getText(); >++ if (text.length() > 0) { >++ lastText = text; >++ } >++ } >++ } >++ super.disposeExampleWidgets(); >++ } >++ >++ public static String getContents(InputStream in) throws IOException { >++ BufferedReader br= new BufferedReader(new InputStreamReader(in)); >++ >++ StringBuffer sb= new StringBuffer(300); >++ try { >++ int read= 0; >++ while ((read= br.read()) != -1) >++ sb.append((char) read); >++ } finally { >++ br.close(); >++ } >++ return sb.toString(); >++ } >++ >++ /** >++ * Gets the list of custom event names. >++ * >++ * @return an array containing custom event names >++ */ >++ String [] getCustomEventNames () { >++ return new String [] {"CloseWindowListener", "LocationListener", "OpenWindowListener", >++ "ProgressListener", "StatusTextListener", "TitleListener", "VisibilityWindowListener"}; >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ if (browser != null) return new Widget [] {browser}; >++ return super.getExampleWidgets(); >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Text", "Url", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Browser"; >++ } >++ >++ /** >++ * Hooks the custom listener specified by eventName. >++ */ >++ void hookCustomListener (final String eventName) { >++ if (browser == null) return; >++ if (eventName == "CloseWindowListener") { >++ browser.addCloseWindowListener (new CloseWindowListener () { >++ public void close(WindowEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "LocationListener") { >++ browser.addLocationListener (new LocationListener () { >++ public void changed(LocationEvent event) { >++ log (eventName + ".changed", event); >++ } >++ public void changing(LocationEvent event) { >++ log (eventName + ".changing", event); >++ } >++ }); >++ } >++ if (eventName == "OpenWindowListener") { >++ browser.addOpenWindowListener (new OpenWindowListener () { >++ public void open(WindowEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "ProgressListener") { >++ browser.addProgressListener (new ProgressListener () { >++ public void changed(ProgressEvent event) { >++ log (eventName + ".changed", event); >++ } >++ public void completed(ProgressEvent event) { >++ log (eventName + ".completed", event); >++ } >++ }); >++ } >++ if (eventName == "StatusTextListener") { >++ browser.addStatusTextListener (new StatusTextListener () { >++ public void changed(StatusTextEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "TitleListener") { >++ browser.addTitleListener (new TitleListener () { >++ public void changed(TitleEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "VisibilityWindowListener") { >++ browser.addVisibilityWindowListener (new VisibilityWindowListener () { >++ public void hide(WindowEvent event) { >++ log (eventName + ".hide", event); >++ } >++ public void show(WindowEvent event) { >++ log (eventName + ".show", event); >++ } >++ }); >++ } >++ } >++ >++ boolean rtlSupport() { >++ return false; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ mozillaButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.MOZILLA) != 0); >++ webKitButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.WEBKIT) != 0); >++ borderButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.BORDER) != 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ButtonTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ButtonTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ButtonTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ButtonTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,245 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++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, button7, button8, button9; >++ Group textButtonGroup, imageButtonGroup, imagetextButtonGroup; >++ >++ /* Alignment widgets added to the "Control" group */ >++ Button upButton, downButton; >++ >++ /* Style widgets added to the "Style" group */ >++ Button pushButton, checkButton, radioButton, toggleButton, arrowButton, flatButton, wrapButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ButtonTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Control" group. >++ */ >++ void createControlGroup () { >++ super.createControlGroup (); >++ >++ /* Create the controls */ >++ upButton = new Button (alignmentGroup, SWT.RADIO); >++ upButton.setText (ControlExample.getResourceString("Up")); >++ downButton = new Button (alignmentGroup, SWT.RADIO); >++ downButton.setText (ControlExample.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 (SWT.FILL, SWT.FILL, true, true)); >++ textButtonGroup.setText (ControlExample.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 (SWT.FILL, SWT.FILL, true, true)); >++ imageButtonGroup.setText (ControlExample.getResourceString("Image_Buttons")); >++ >++ /* Create a group for the image and text buttons */ >++ imagetextButtonGroup = new Group(exampleGroup, SWT.NONE); >++ gridLayout = new GridLayout(); >++ imagetextButtonGroup.setLayout(gridLayout); >++ gridLayout.numColumns = 3; >++ imagetextButtonGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ imagetextButtonGroup.setText (ControlExample.getResourceString("Image_Text_Buttons")); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ 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 (flatButton.getSelection()) style |= SWT.FLAT; >++ if (wrapButton.getSelection()) style |= SWT.WRAP; >++ if (borderButton.getSelection()) style |= SWT.BORDER; >++ if (leftButton.getSelection()) style |= SWT.LEFT; >++ if (rightButton.getSelection()) style |= SWT.RIGHT; >++ if (arrowButton.getSelection()) { >++ style |= SWT.ARROW; >++ if (upButton.getSelection()) style |= SWT.UP; >++ if (downButton.getSelection()) style |= SWT.DOWN; >++ } else { >++ if (centerButton.getSelection()) style |= SWT.CENTER; >++ } >++ >++ /* Create the example widgets */ >++ button1 = new Button(textButtonGroup, style); >++ button1.setText(ControlExample.getResourceString("One...")); >++ button2 = new Button(textButtonGroup, style); >++ button2.setText(ControlExample.getResourceString("Two...")); >++ button3 = new Button(textButtonGroup, style); >++ if (wrapButton.getSelection ()) { >++ button3.setText (ControlExample.getResourceString("Wrap_Text...")); >++ } else { >++ button3.setText (ControlExample.getResourceString("Three...")); >++ } >++ button4 = new Button(imageButtonGroup, style); >++ button4.setImage(instance.images[ControlExample.ciClosedFolder]); >++ button5 = new Button(imageButtonGroup, style); >++ button5.setImage(instance.images[ControlExample.ciOpenFolder]); >++ button6 = new Button(imageButtonGroup, style); >++ button6.setImage(instance.images[ControlExample.ciTarget]); >++ button7 = new Button(imagetextButtonGroup, style); >++ button7.setText(ControlExample.getResourceString("One...")); >++ button7.setImage(instance.images[ControlExample.ciClosedFolder]); >++ button8 = new Button(imagetextButtonGroup, style); >++ button8.setText(ControlExample.getResourceString("Two...")); >++ button8.setImage(instance.images[ControlExample.ciOpenFolder]); >++ button9 = new Button(imagetextButtonGroup, style); >++ if (wrapButton.getSelection ()) { >++ button9.setText (ControlExample.getResourceString("Wrap_Text...")); >++ } else { >++ button9.setText (ControlExample.getResourceString("Three...")); >++ } >++ button9.setImage(instance.images[ControlExample.ciTarget]); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ pushButton = new Button (styleGroup, SWT.RADIO); >++ pushButton.setText("SWT.PUSH"); >++ checkButton = new Button (styleGroup, SWT.RADIO); >++ checkButton.setText ("SWT.CHECK"); >++ radioButton = new Button (styleGroup, SWT.RADIO); >++ radioButton.setText ("SWT.RADIO"); >++ toggleButton = new Button (styleGroup, SWT.RADIO); >++ toggleButton.setText ("SWT.TOGGLE"); >++ arrowButton = new Button (styleGroup, SWT.RADIO); >++ arrowButton.setText ("SWT.ARROW"); >++ flatButton = new Button (styleGroup, SWT.CHECK); >++ flatButton.setText ("SWT.FLAT"); >++ wrapButton = new Button (styleGroup, SWT.CHECK); >++ wrapButton.setText ("SWT.WRAP"); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {button1, button2, button3, button4, button5, button6, button7, button8, button9}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Grayed", "Selection", "Text", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Button"; >++ } >++ >++ /** >++ * Sets the alignment of the "Example" widgets. >++ */ >++ void setExampleWidgetAlignment () { >++ int alignment = 0; >++ if (leftButton.getSelection ()) alignment = SWT.LEFT; >++ if (centerButton.getSelection ()) alignment = SWT.CENTER; >++ if (rightButton.getSelection ()) alignment = SWT.RIGHT; >++ if (upButton.getSelection ()) alignment = SWT.UP; >++ if (downButton.getSelection ()) alignment = SWT.DOWN; >++ button1.setAlignment (alignment); >++ button2.setAlignment (alignment); >++ button3.setAlignment (alignment); >++ button4.setAlignment (alignment); >++ button5.setAlignment (alignment); >++ button6.setAlignment (alignment); >++ button7.setAlignment (alignment); >++ button8.setAlignment (alignment); >++ button9.setAlignment (alignment); >++ } >++ >++ /** >++ * 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); >++ flatButton.setSelection ((button1.getStyle () & SWT.FLAT) != 0); >++ wrapButton.setSelection ((button1.getStyle () & SWT.WRAP) != 0); >++ borderButton.setSelection ((button1.getStyle () & SWT.BORDER) != 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/CComboTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CComboTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CComboTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CComboTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,123 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.custom.*; >++import org.eclipse.swt.layout.*; >++ >++class CComboTab extends Tab { >++ >++ /* Example widgets and groups that contain them */ >++ CCombo combo1; >++ Group comboGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button flatButton, readOnlyButton; >++ >++ static String [] ListData = {ControlExample.getResourceString("ListData1_0"), >++ ControlExample.getResourceString("ListData1_1"), >++ ControlExample.getResourceString("ListData1_2"), >++ ControlExample.getResourceString("ListData1_3"), >++ ControlExample.getResourceString("ListData1_4"), >++ ControlExample.getResourceString("ListData1_5"), >++ ControlExample.getResourceString("ListData1_6"), >++ ControlExample.getResourceString("ListData1_7"), >++ ControlExample.getResourceString("ListData1_8")}; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ CComboTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the combo box */ >++ comboGroup = new Group (exampleGroup, SWT.NONE); >++ comboGroup.setLayout (new GridLayout ()); >++ comboGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ comboGroup.setText (ControlExample.getResourceString("Custom_Combo")); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (flatButton.getSelection ()) style |= SWT.FLAT; >++ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ >++ /* Create the example widgets */ >++ combo1 = new CCombo (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 */ >++ readOnlyButton = new Button (styleGroup, SWT.CHECK); >++ readOnlyButton.setText ("SWT.READ_ONLY"); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ flatButton = new Button (styleGroup, SWT.CHECK); >++ flatButton.setText ("SWT.FLAT"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {combo1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Editable", "Items", "Selection", "Text", "TextLimit", "ToolTipText", "VisibleItemCount"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "CCombo"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ flatButton.setSelection ((combo1.getStyle () & SWT.FLAT) != 0); >++ readOnlyButton.setSelection ((combo1.getStyle () & SWT.READ_ONLY) != 0); >++ borderButton.setSelection ((combo1.getStyle () & SWT.BORDER) != 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/CLabelTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CLabelTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CLabelTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CLabelTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,135 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.custom.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++ >++class CLabelTab extends AlignableTab { >++ /* Example widgets and groups that contain them */ >++ CLabel label1, label2, label3; >++ Group textLabelGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button shadowInButton, shadowOutButton, shadowNoneButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ CLabelTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the text labels */ >++ textLabelGroup = new Group(exampleGroup, SWT.NONE); >++ GridLayout gridLayout = new GridLayout (); >++ textLabelGroup.setLayout (gridLayout); >++ gridLayout.numColumns = 3; >++ textLabelGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ textLabelGroup.setText (ControlExample.getResourceString("Custom_Labels")); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (shadowInButton.getSelection ()) style |= SWT.SHADOW_IN; >++ if (shadowNoneButton.getSelection ()) style |= SWT.SHADOW_NONE; >++ if (shadowOutButton.getSelection ()) style |= SWT.SHADOW_OUT; >++ if (leftButton.getSelection ()) style |= SWT.LEFT; >++ if (centerButton.getSelection ()) style |= SWT.CENTER; >++ if (rightButton.getSelection ()) style |= SWT.RIGHT; >++ >++ /* Create the example widgets */ >++ label1 = new CLabel (textLabelGroup, style); >++ label1.setText(ControlExample.getResourceString("One")); >++ label1.setImage (instance.images[ControlExample.ciClosedFolder]); >++ label2 = new CLabel (textLabelGroup, style); >++ label2.setImage (instance.images[ControlExample.ciTarget]); >++ label3 = new CLabel (textLabelGroup, style); >++ label3.setText(ControlExample.getResourceString("Example_string") + "\n" + ControlExample.getResourceString("One_Two_Three")); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ shadowNoneButton = new Button (styleGroup, SWT.RADIO); >++ shadowNoneButton.setText ("SWT.SHADOW_NONE"); >++ shadowInButton = new Button (styleGroup, SWT.RADIO); >++ shadowInButton.setText ("SWT.SHADOW_IN"); >++ shadowOutButton = new Button (styleGroup, SWT.RADIO); >++ shadowOutButton.setText ("SWT.SHADOW_OUT"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {label1, label2, label3}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"BottomMargin", "LeftMargin", "RightMargin", "Text", "ToolTipText", "TopMargin"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "CLabel"; >++ } >++ >++ /** >++ * Sets the alignment of the "Example" widgets. >++ */ >++ void setExampleWidgetAlignment () { >++ int alignment = 0; >++ if (leftButton.getSelection ()) alignment = SWT.LEFT; >++ if (centerButton.getSelection ()) alignment = SWT.CENTER; >++ if (rightButton.getSelection ()) alignment = SWT.RIGHT; >++ label1.setAlignment (alignment); >++ label2.setAlignment (alignment); >++ label3.setAlignment (alignment); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ leftButton.setSelection ((label1.getStyle () & SWT.LEFT) != 0); >++ centerButton.setSelection ((label1.getStyle () & SWT.CENTER) != 0); >++ rightButton.setSelection ((label1.getStyle () & SWT.RIGHT) != 0); >++ shadowInButton.setSelection ((label1.getStyle () & SWT.SHADOW_IN) != 0); >++ shadowOutButton.setSelection ((label1.getStyle () & SWT.SHADOW_OUT) != 0); >++ shadowNoneButton.setSelection ((label1.getStyle () & (SWT.SHADOW_IN | SWT.SHADOW_OUT)) == 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/CTabFolderTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CTabFolderTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CTabFolderTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CTabFolderTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,446 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.custom.*; >++import org.eclipse.swt.events.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.graphics.*; >++import org.eclipse.swt.widgets.*; >++ >++class CTabFolderTab extends Tab { >++ int lastSelectedTab = 0; >++ >++ /* Example widgets and groups that contain them */ >++ CTabFolder tabFolder1; >++ Group tabFolderGroup, itemGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button topButton, bottomButton, flatButton, closeButton; >++ >++ static String [] CTabItems1 = {ControlExample.getResourceString("CTabItem1_0"), >++ ControlExample.getResourceString("CTabItem1_1"), >++ ControlExample.getResourceString("CTabItem1_2")}; >++ >++ /* Controls and resources added to the "Fonts" group */ >++ static final int SELECTION_FOREGROUND_COLOR = 3; >++ static final int SELECTION_BACKGROUND_COLOR = 4; >++ static final int ITEM_FONT = 5; >++ Color selectionForegroundColor, selectionBackgroundColor; >++ Font itemFont; >++ >++ /* Other widgets added to the "Other" group */ >++ Button simpleTabButton, singleTabButton, imageButton, showMinButton, showMaxButton, unselectedCloseButton, unselectedImageButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ CTabFolderTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Colors and Fonts" group. >++ */ >++ void createColorAndFontGroup () { >++ super.createColorAndFontGroup(); >++ >++ TableItem item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Selection_Foreground_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Selection_Background_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Item_Font")); >++ >++ shell.addDisposeListener(new DisposeListener() { >++ public void widgetDisposed(DisposeEvent event) { >++ if (selectionBackgroundColor != null) selectionBackgroundColor.dispose(); >++ if (selectionForegroundColor != null) selectionForegroundColor.dispose(); >++ if (itemFont != null) itemFont.dispose(); >++ selectionBackgroundColor = null; >++ selectionForegroundColor = null; >++ itemFont = null; >++ } >++ }); >++ } >++ >++ void changeFontOrColor(int index) { >++ switch (index) { >++ case SELECTION_FOREGROUND_COLOR: { >++ Color oldColor = selectionForegroundColor; >++ if (oldColor == null) oldColor = tabFolder1.getSelectionForeground(); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = selectionForegroundColor; >++ selectionForegroundColor = new Color (display, rgb); >++ setSelectionForeground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case SELECTION_BACKGROUND_COLOR: { >++ Color oldColor = selectionBackgroundColor; >++ if (oldColor == null) oldColor = tabFolder1.getSelectionBackground(); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = selectionBackgroundColor; >++ selectionBackgroundColor = new Color (display, rgb); >++ setSelectionBackground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case ITEM_FONT: { >++ Font oldFont = itemFont; >++ if (oldFont == null) oldFont = tabFolder1.getItem (0).getFont (); >++ fontDialog.setFontList(oldFont.getFontData()); >++ FontData fontData = fontDialog.open (); >++ if (fontData == null) return; >++ oldFont = itemFont; >++ itemFont = new Font (display, fontData); >++ setItemFont (); >++ setExampleWidgetSize (); >++ if (oldFont != null) oldFont.dispose (); >++ } >++ break; >++ default: >++ super.changeFontOrColor(index); >++ } >++ } >++ >++ /** >++ * Creates the "Other" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ >++ /* Create display controls specific to this example */ >++ simpleTabButton = new Button (otherGroup, SWT.CHECK); >++ simpleTabButton.setText (ControlExample.getResourceString("Set_Simple_Tabs")); >++ simpleTabButton.setSelection(true); >++ simpleTabButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setSimpleTabs(); >++ } >++ }); >++ >++ singleTabButton = new Button (otherGroup, SWT.CHECK); >++ singleTabButton.setText (ControlExample.getResourceString("Set_Single_Tabs")); >++ singleTabButton.setSelection(false); >++ singleTabButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setSingleTabs(); >++ } >++ }); >++ >++ showMinButton = new Button (otherGroup, SWT.CHECK); >++ showMinButton.setText (ControlExample.getResourceString("Set_Min_Visible")); >++ showMinButton.setSelection(false); >++ showMinButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setMinimizeVisible(); >++ } >++ }); >++ >++ showMaxButton = new Button (otherGroup, SWT.CHECK); >++ showMaxButton.setText (ControlExample.getResourceString("Set_Max_Visible")); >++ showMaxButton.setSelection(false); >++ showMaxButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setMaximizeVisible(); >++ } >++ }); >++ >++ imageButton = new Button (otherGroup, SWT.CHECK); >++ imageButton.setText (ControlExample.getResourceString("Set_Image")); >++ imageButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setImages(); >++ } >++ }); >++ >++ unselectedImageButton = new Button (otherGroup, SWT.CHECK); >++ unselectedImageButton.setText (ControlExample.getResourceString("Set_Unselected_Image_Visible")); >++ unselectedImageButton.setSelection(true); >++ unselectedImageButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setUnselectedImageVisible(); >++ } >++ }); >++ unselectedCloseButton = new Button (otherGroup, SWT.CHECK); >++ unselectedCloseButton.setText (ControlExample.getResourceString("Set_Unselected_Close_Visible")); >++ unselectedCloseButton.setSelection(true); >++ unselectedCloseButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setUnselectedCloseVisible(); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the CTabFolder */ >++ tabFolderGroup = new Group (exampleGroup, SWT.NONE); >++ tabFolderGroup.setLayout (new GridLayout ()); >++ tabFolderGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ tabFolderGroup.setText ("CTabFolder"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (topButton.getSelection ()) style |= SWT.TOP; >++ if (bottomButton.getSelection ()) style |= SWT.BOTTOM; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (flatButton.getSelection ()) style |= SWT.FLAT; >++ if (closeButton.getSelection ()) style |= SWT.CLOSE; >++ >++ /* Create the example widgets */ >++ tabFolder1 = new CTabFolder (tabFolderGroup, style); >++ for (int i = 0; i < CTabItems1.length; i++) { >++ CTabItem item = new CTabItem(tabFolder1, SWT.NONE); >++ item.setText(CTabItems1[i]); >++ Text text = new Text(tabFolder1, SWT.WRAP | SWT.MULTI); >++ text.setText(ControlExample.getResourceString("CTabItem_content") + ": " + i); >++ item.setControl(text); >++ } >++ tabFolder1.addListener(SWT.Selection, new Listener() { >++ public void handleEvent(Event event) { >++ lastSelectedTab = tabFolder1.getSelectionIndex(); >++ } >++ }); >++ tabFolder1.setSelection(lastSelectedTab); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ topButton = new Button (styleGroup, SWT.RADIO); >++ topButton.setText ("SWT.TOP"); >++ topButton.setSelection(true); >++ bottomButton = new Button (styleGroup, SWT.RADIO); >++ bottomButton.setText ("SWT.BOTTOM"); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ flatButton = new Button (styleGroup, SWT.CHECK); >++ flatButton.setText ("SWT.FLAT"); >++ closeButton = new Button (styleGroup, SWT.CHECK); >++ closeButton.setText ("SWT.CLOSE"); >++ } >++ >++ /** >++ * Gets the list of custom event names. >++ * >++ * @return an array containing custom event names >++ */ >++ String [] getCustomEventNames () { >++ return new String [] {"CTabFolderEvent"}; >++ } >++ >++ /** >++ * Gets the "Example" widget children's items, if any. >++ * >++ * @return an array containing the example widget children's items >++ */ >++ Item [] getExampleWidgetItems () { >++ return tabFolder1.getItems(); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {tabFolder1}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "CTabFolder"; >++ } >++ >++ /** >++ * Hooks the custom listener specified by eventName. >++ */ >++ void hookCustomListener (final String eventName) { >++ if (eventName == "CTabFolderEvent") { >++ tabFolder1.addCTabFolder2Listener (new CTabFolder2Adapter () { >++ public void close (CTabFolderEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ } >++ >++ /** >++ * Sets the foreground color, background color, and font >++ * of the "Example" widgets to their default settings. >++ * Also sets foreground and background color of the Node 1 >++ * TreeItems to default settings. >++ */ >++ void resetColorsAndFonts () { >++ super.resetColorsAndFonts (); >++ Color oldColor = selectionForegroundColor; >++ selectionForegroundColor = null; >++ setSelectionForeground (); >++ if (oldColor != null) oldColor.dispose(); >++ oldColor = selectionBackgroundColor; >++ selectionBackgroundColor = null; >++ setSelectionBackground (); >++ if (oldColor != null) oldColor.dispose(); >++ Font oldFont = itemFont; >++ itemFont = null; >++ setItemFont (); >++ if (oldFont != null) oldFont.dispose(); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState(); >++ setSimpleTabs(); >++ setSingleTabs(); >++ setImages(); >++ setMinimizeVisible(); >++ setMaximizeVisible(); >++ setUnselectedCloseVisible(); >++ setUnselectedImageVisible(); >++ setSelectionBackground (); >++ setSelectionForeground (); >++ setItemFont (); >++ setExampleWidgetSize(); >++ } >++ >++ /** >++ * Sets the shape that the CTabFolder will use to render itself. >++ */ >++ void setSimpleTabs () { >++ tabFolder1.setSimple (simpleTabButton.getSelection ()); >++ setExampleWidgetSize(); >++ } >++ >++ /** >++ * Sets the number of tabs that the CTabFolder should display. >++ */ >++ void setSingleTabs () { >++ tabFolder1.setSingle (singleTabButton.getSelection ()); >++ setExampleWidgetSize(); >++ } >++ /** >++ * Sets an image into each item of the "Example" widgets. >++ */ >++ void setImages () { >++ boolean setImage = imageButton.getSelection (); >++ CTabItem items[] = tabFolder1.getItems (); >++ for (int i = 0; i < items.length; i++) { >++ if (setImage) { >++ items[i].setImage (instance.images[ControlExample.ciClosedFolder]); >++ } else { >++ items[i].setImage (null); >++ } >++ } >++ setExampleWidgetSize (); >++ } >++ /** >++ * Sets the visibility of the minimize button >++ */ >++ void setMinimizeVisible () { >++ tabFolder1.setMinimizeVisible(showMinButton.getSelection ()); >++ setExampleWidgetSize(); >++ } >++ /** >++ * Sets the visibility of the maximize button >++ */ >++ void setMaximizeVisible () { >++ tabFolder1.setMaximizeVisible(showMaxButton.getSelection ()); >++ setExampleWidgetSize(); >++ } >++ /** >++ * Sets the visibility of the close button on unselected tabs >++ */ >++ void setUnselectedCloseVisible () { >++ tabFolder1.setUnselectedCloseVisible(unselectedCloseButton.getSelection ()); >++ setExampleWidgetSize(); >++ } >++ /** >++ * Sets the visibility of the image on unselected tabs >++ */ >++ void setUnselectedImageVisible () { >++ tabFolder1.setUnselectedImageVisible(unselectedImageButton.getSelection ()); >++ setExampleWidgetSize(); >++ } >++ /** >++ * Sets the background color of CTabItem 0. >++ */ >++ void setSelectionBackground () { >++ if (!instance.startup) { >++ tabFolder1.setSelectionBackground(selectionBackgroundColor); >++ } >++ // Set the selection background item's image to match the background color of the selection. >++ Color color = selectionBackgroundColor; >++ if (color == null) color = tabFolder1.getSelectionBackground (); >++ TableItem item = colorAndFontTable.getItem(SELECTION_BACKGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the foreground color of CTabItem 0. >++ */ >++ void setSelectionForeground () { >++ if (!instance.startup) { >++ tabFolder1.setSelectionForeground(selectionForegroundColor); >++ } >++ // Set the selection foreground item's image to match the foreground color of the selection. >++ Color color = selectionForegroundColor; >++ if (color == null) color = tabFolder1.getSelectionForeground (); >++ TableItem item = colorAndFontTable.getItem(SELECTION_FOREGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the font of CTabItem 0. >++ */ >++ void setItemFont () { >++ if (!instance.startup) { >++ tabFolder1.getItem (0).setFont (itemFont); >++ setExampleWidgetSize(); >++ } >++ /* Set the font item's image to match the font of the item. */ >++ Font ft = itemFont; >++ if (ft == null) ft = tabFolder1.getItem (0).getFont (); >++ TableItem item = colorAndFontTable.getItem(ITEM_FONT); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (fontImage(ft)); >++ item.setFont(ft); >++ colorAndFontTable.layout (); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/CanvasTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CanvasTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CanvasTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CanvasTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,312 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.graphics.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.events.*; >++import org.eclipse.swt.layout.*; >++ >++class CanvasTab extends Tab { >++ static final int colors [] = { >++ SWT.COLOR_RED, >++ SWT.COLOR_GREEN, >++ SWT.COLOR_BLUE, >++ SWT.COLOR_MAGENTA, >++ SWT.COLOR_YELLOW, >++ SWT.COLOR_CYAN, >++ SWT.COLOR_DARK_RED, >++ SWT.COLOR_DARK_GREEN, >++ SWT.COLOR_DARK_BLUE, >++ SWT.COLOR_DARK_MAGENTA, >++ SWT.COLOR_DARK_YELLOW, >++ SWT.COLOR_DARK_CYAN >++ }; >++ static final String canvasString = "Canvas"; //$NON-NLS-1$ >++ >++ /* Example widgets and groups that contain them */ >++ Canvas canvas; >++ Group canvasGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button horizontalButton, verticalButton, noBackgroundButton, noFocusButton, >++ noMergePaintsButton, noRedrawResizeButton, doubleBufferedButton; >++ >++ /* Other widgets added to the "Other" group */ >++ Button caretButton, fillDamageButton; >++ >++ int paintCount; >++ int cx, cy; >++ int maxX, maxY; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ CanvasTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Other" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ >++ /* Create display controls specific to this example */ >++ caretButton = new Button (otherGroup, SWT.CHECK); >++ caretButton.setText (ControlExample.getResourceString("Caret")); >++ fillDamageButton = new Button (otherGroup, SWT.CHECK); >++ fillDamageButton.setText (ControlExample.getResourceString("FillDamage")); >++ >++ /* Add the listeners */ >++ caretButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setCaret (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the canvas widget */ >++ canvasGroup = new Group (exampleGroup, SWT.NONE); >++ canvasGroup.setLayout (new GridLayout ()); >++ canvasGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ canvasGroup.setText ("Canvas"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL; >++ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (noBackgroundButton.getSelection ()) style |= SWT.NO_BACKGROUND; >++ if (noFocusButton.getSelection ()) style |= SWT.NO_FOCUS; >++ if (noMergePaintsButton.getSelection ()) style |= SWT.NO_MERGE_PAINTS; >++ if (noRedrawResizeButton.getSelection ()) style |= SWT.NO_REDRAW_RESIZE; >++ if (doubleBufferedButton.getSelection ()) style |= SWT.DOUBLE_BUFFERED; >++ >++ /* Create the example widgets */ >++ paintCount = 0; cx = 0; cy = 0; >++ canvas = new Canvas (canvasGroup, style); >++ canvas.addPaintListener(new PaintListener () { >++ public void paintControl(PaintEvent e) { >++ paintCount++; >++ GC gc = e.gc; >++ if (fillDamageButton.getSelection ()) { >++ Color color = e.display.getSystemColor (colors [paintCount % colors.length]); >++ gc.setBackground(color); >++ gc.fillRectangle(e.x, e.y, e.width, e.height); >++ } >++ Point size = canvas.getSize (); >++ gc.drawArc(cx + 1, cy + 1, size.x - 2, size.y - 2, 0, 360); >++ gc.drawRectangle(cx + (size.x - 10) / 2, cy + (size.y - 10) / 2, 10, 10); >++ Point extent = gc.textExtent(canvasString); >++ gc.drawString(canvasString, cx + (size.x - extent.x) / 2, cy - extent.y + (size.y - 10) / 2, true); >++ } >++ }); >++ canvas.addControlListener(new ControlAdapter() { >++ public void controlResized(ControlEvent event) { >++ Point size = canvas.getSize (); >++ maxX = size.x * 3 / 2; maxY = size.y * 3 / 2; >++ resizeScrollBars (); >++ } >++ }); >++ ScrollBar bar = canvas.getHorizontalBar(); >++ if (bar != null) { >++ hookListeners (bar); >++ bar.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent event) { >++ scrollHorizontal ((ScrollBar)event.widget); >++ } >++ }); >++ } >++ bar = canvas.getVerticalBar(); >++ if (bar != null) { >++ hookListeners (bar); >++ bar.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent event) { >++ scrollVertical ((ScrollBar)event.widget); >++ } >++ }); >++ } >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup(); >++ >++ /* Create the extra widgets */ >++ horizontalButton = new Button (styleGroup, SWT.CHECK); >++ horizontalButton.setText ("SWT.H_SCROLL"); >++ horizontalButton.setSelection(true); >++ verticalButton = new Button (styleGroup, SWT.CHECK); >++ verticalButton.setText ("SWT.V_SCROLL"); >++ verticalButton.setSelection(true); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ noBackgroundButton = new Button (styleGroup, SWT.CHECK); >++ noBackgroundButton.setText ("SWT.NO_BACKGROUND"); >++ noFocusButton = new Button (styleGroup, SWT.CHECK); >++ noFocusButton.setText ("SWT.NO_FOCUS"); >++ noMergePaintsButton = new Button (styleGroup, SWT.CHECK); >++ noMergePaintsButton.setText ("SWT.NO_MERGE_PAINTS"); >++ noRedrawResizeButton = new Button (styleGroup, SWT.CHECK); >++ noRedrawResizeButton.setText ("SWT.NO_REDRAW_RESIZE"); >++ doubleBufferedButton = new Button (styleGroup, SWT.CHECK); >++ doubleBufferedButton.setText ("SWT.DOUBLE_BUFFERED"); >++ } >++ >++ /** >++ * Creates the tab folder page. >++ * >++ * @param tabFolder org.eclipse.swt.widgets.TabFolder >++ * @return the new page for the tab folder >++ */ >++ Composite createTabFolderPage (TabFolder tabFolder) { >++ super.createTabFolderPage (tabFolder); >++ >++ /* >++ * Add a resize listener to the tabFolderPage so that >++ * if the user types into the example widget to change >++ * its preferred size, and then resizes the shell, we >++ * recalculate the preferred size correctly. >++ */ >++ tabFolderPage.addControlListener(new ControlAdapter() { >++ public void controlResized(ControlEvent e) { >++ setExampleWidgetSize (); >++ } >++ }); >++ >++ return tabFolderPage; >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {canvas}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Canvas"; >++ } >++ >++ /** >++ * Resizes the maximum and thumb of both scrollbars. >++ */ >++ void resizeScrollBars () { >++ Rectangle clientArea = canvas.getClientArea(); >++ ScrollBar bar = canvas.getHorizontalBar(); >++ if (bar != null) { >++ bar.setMaximum(maxX); >++ bar.setThumb(clientArea.width); >++ bar.setPageIncrement(clientArea.width); >++ } >++ bar = canvas.getVerticalBar(); >++ if (bar != null) { >++ bar.setMaximum(maxY); >++ bar.setThumb(clientArea.height); >++ bar.setPageIncrement(clientArea.height); >++ } >++ } >++ >++ /** >++ * Scrolls the canvas horizontally. >++ * >++ * @param scrollBar >++ */ >++ void scrollHorizontal (ScrollBar scrollBar) { >++ Rectangle bounds = canvas.getClientArea(); >++ int x = -scrollBar.getSelection(); >++ if (x + maxX < bounds.width) { >++ x = bounds.width - maxX; >++ } >++ canvas.scroll(x, cy, cx, cy, maxX, maxY, false); >++ cx = x; >++ } >++ >++ /** >++ * Scrolls the canvas vertically. >++ * >++ * @param scrollBar >++ */ >++ void scrollVertical (ScrollBar scrollBar) { >++ Rectangle bounds = canvas.getClientArea(); >++ int y = -scrollBar.getSelection(); >++ if (y + maxY < bounds.height) { >++ y = bounds.height - maxY; >++ } >++ canvas.scroll(cx, y, cx, cy, maxX, maxY, false); >++ cy = y; >++ } >++ >++ /** >++ * Sets or clears the caret in the "Example" widget. >++ */ >++ void setCaret () { >++ Caret oldCaret = canvas.getCaret (); >++ if (caretButton.getSelection ()) { >++ Caret newCaret = new Caret(canvas, SWT.NONE); >++ Font font = canvas.getFont(); >++ newCaret.setFont(font); >++ GC gc = new GC(canvas); >++ gc.setFont(font); >++ newCaret.setBounds(1, 1, 1, gc.getFontMetrics().getHeight()); >++ gc.dispose(); >++ canvas.setCaret (newCaret); >++ canvas.setFocus(); >++ } else { >++ canvas.setCaret (null); >++ } >++ if (oldCaret != null) oldCaret.dispose (); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ horizontalButton.setSelection ((canvas.getStyle () & SWT.H_SCROLL) != 0); >++ verticalButton.setSelection ((canvas.getStyle () & SWT.V_SCROLL) != 0); >++ borderButton.setSelection ((canvas.getStyle () & SWT.BORDER) != 0); >++ noBackgroundButton.setSelection ((canvas.getStyle () & SWT.NO_BACKGROUND) != 0); >++ noFocusButton.setSelection ((canvas.getStyle () & SWT.NO_FOCUS) != 0); >++ noMergePaintsButton.setSelection ((canvas.getStyle () & SWT.NO_MERGE_PAINTS) != 0); >++ noRedrawResizeButton.setSelection ((canvas.getStyle () & SWT.NO_REDRAW_RESIZE) != 0); >++ doubleBufferedButton.setSelection ((canvas.getStyle () & SWT.DOUBLE_BUFFERED) != 0); >++ if (!instance.startup) setCaret (); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/CombineComposition.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CombineComposition.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CombineComposition.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CombineComposition.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,896 @@ >++package org.eclipse.swt.examples.mirroringTest; >++ >++import org.eclipse.swt.SWT; >++import org.eclipse.swt.events.SelectionAdapter; >++import org.eclipse.swt.events.SelectionEvent; >++import org.eclipse.swt.events.SelectionListener; >++import org.eclipse.swt.graphics.Color; >++import org.eclipse.swt.graphics.Image; >++import org.eclipse.swt.graphics.Point; >++import org.eclipse.swt.graphics.Rectangle; >++import org.eclipse.swt.layout.FormAttachment; >++import org.eclipse.swt.layout.FormData; >++import org.eclipse.swt.layout.FormLayout; >++import org.eclipse.swt.layout.GridData; >++import org.eclipse.swt.layout.GridLayout; >++import org.eclipse.swt.widgets.Button; >++import org.eclipse.swt.widgets.Combo; >++import org.eclipse.swt.widgets.Composite; >++import org.eclipse.swt.widgets.Control; >++import org.eclipse.swt.widgets.CoolBar; >++import org.eclipse.swt.widgets.CoolItem; >++import org.eclipse.swt.widgets.Display; >++import org.eclipse.swt.widgets.Group; >++import org.eclipse.swt.widgets.Label; >++import org.eclipse.swt.widgets.List; >++import org.eclipse.swt.widgets.Menu; >++import org.eclipse.swt.widgets.MenuItem; >++import org.eclipse.swt.widgets.ProgressBar; >++import org.eclipse.swt.widgets.Shell; >++import org.eclipse.swt.widgets.Slider; >++import org.eclipse.swt.widgets.TabFolder; >++import org.eclipse.swt.widgets.TabItem; >++import org.eclipse.swt.widgets.Table; >++import org.eclipse.swt.widgets.TableColumn; >++import org.eclipse.swt.widgets.TableItem; >++import org.eclipse.swt.widgets.Text; >++import org.eclipse.swt.widgets.ToolBar; >++import org.eclipse.swt.widgets.ToolItem; >++import org.eclipse.swt.widgets.Tree; >++import org.eclipse.swt.widgets.TreeColumn; >++import org.eclipse.swt.widgets.TreeItem; >++ >++public class CombineComposition extends Composite{ >++ >++ private Button buttonRTLCompositeGroups; >++ private Button buttonLTRCompositeGroups; >++ >++ private Button buttonListRTLCompositeGroups; >++ private Button buttonListLTRCompositeGroups; >++ >++ private Composite compositeGroups; >++ private Slider sliderGtoupC; >++ private Combo comboSimpleGroupA; >++ private Combo comboDropDownGroupA; >++ private Button buttonTextPicGroupA; >++ private Button buttonPic; >++ private Button buttonTextGroupA; >++ private Button buttonRTLGroupA; >++ private Button buttonLTRGroupA; >++ private Label labelPicture; >++ private Label labelTextGroupA; >++ private Button buttonLTRGroupC; >++ private Button buttonRTLGroupC; >++ private ProgressBar progressBarGroupC; >++ private ToolBar toolBar1; >++ CoolItem pushItem, dropDownItem, radioItem, checkItem, textItem; >++ private CoolBar coolBarGroupC; >++ private Tree treeGroupC; >++ TreeItem textNode1, imageNode1; >++ private Group groupC; >++ private Button buttonRTLGroupD; >++ private Button buttonLTRGroupD; >++ private Text textAriaGroupD; >++ private Text textSingleGroupD; >++ private Table tableGroupD; >++ private Composite compositeInTabGtoupD; >++ private TabItem cTabItem1; >++ private TabFolder tabFolderInGroupD; >++ private Group groupD; >++ private Group groupA; >++ private Label labelMultiText; >++ private Label labelSimpleText; >++ private List list; >++ >++ Control[] controls; >++ >++ CombinedBasic combinedBasic; >++ CombinedOrientationExample instance; >++ >++ static String [] ListData = {"\u05d0\u05e0\u05d9\u0020\u05e2\u05d5\u05d1\u05d3\u05ea\u0020\u05d1 - IBM \u05d9\u05e9\u05e8\u05d0\u05dc...", >++ "I work at \u05d9\u05d1\u05de in Israel...", >++ "My name is \u05d0\u05dc\u05d9\u05e1...", >++ "\u05e7\u05d5\u05e8\u05d0\u05d9\u05dd\u0020\u05dc\u05d9 Alice...", >++ "1234..."}; >++ static String [] columnTitles = {CombinedOrientationExample.getResourceString("TableTitle_0"), >++ CombinedOrientationExample.getResourceString("TableTitle_1"), >++ CombinedOrientationExample.getResourceString("TableTitle_2"), >++ CombinedOrientationExample.getResourceString("TableTitle_3")}; >++ >++ static String[][] tableData = { >++ { CombinedOrientationExample.getResourceString("TableLine0_0"), >++ CombinedOrientationExample.getResourceString("TableLine0_1"), >++ CombinedOrientationExample.getResourceString("TableLine0_2"), >++ CombinedOrientationExample.getResourceString("TableLine0_3") }, >++ { CombinedOrientationExample.getResourceString("TableLine1_0"), >++ CombinedOrientationExample.getResourceString("TableLine1_1"), >++ CombinedOrientationExample.getResourceString("TableLine1_2"), >++ CombinedOrientationExample.getResourceString("TableLine1_3") }, >++ { CombinedOrientationExample.getResourceString("TableLine2_0"), >++ CombinedOrientationExample.getResourceString("TableLine2_1"), >++ CombinedOrientationExample.getResourceString("TableLine2_2"), >++ CombinedOrientationExample.getResourceString("TableLine2_3") } }; >++ >++ >++ static String [] widgetsListData = { >++ "\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 - group D...", >++ "Tab folder...", >++// "Tab Item...", >++ "Composite in tab Item...", >++ "Table...", >++ "Simple Text Label...", >++ "Simple Text...", >++ "Multi Text Label...", >++ "Multi Text...", >++ "\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 LTR...", >++ "\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 RTL...", >++ "---", >++ "Complex Group", >++ "Text Label - Complex group...", >++ "Picture Label - Complex group", >++ "Text Button - Complex group", >++ "Picture Button - Complex group", >++ "Text & Picture Button - Complex group", >++ "Drop down combo - Complex group", >++ "Simple combo - Complex group", >++ "LTR button - Complex group", >++ "RTL button - Complex group", >++ "---", >++ "Small Group", >++ "Tree - Small group", >++ "CoolBar - Small group", >++ "Progress Bar - Small group", >++ "Slider - Small group", >++// "pushItem", >++// "dropDownItem", >++// "radioItem", >++// "checkItem", >++// "textItem", >++ "LTR button - Small group", >++ "RTL button - Small group", >++ "---", >++ "List - Me..." >++ }; >++ >++ >++ >++ public CombineComposition(Composite parent, int style, CombinedOrientationExample instance) { >++ super(parent, style); >++ this.instance = instance; >++ initGUI(style); >++ } >++ /** >++ * Initializes the GUI. >++ */ >++ private void initGUI(int style) { >++ try { >++ SelectionListener bidiListener = new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ >++ if(event.widget == buttonRTLCompositeGroups || event.widget == buttonLTRCompositeGroups){ >++ compositeGroups.setOrientation(event.widget == buttonLTRCompositeGroups ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >++ compositeGroups.setToolTipText("I'm " + (event.widget == buttonLTRCompositeGroups ? "LTR" : "RTL")); >++ } >++ if(event.widget == buttonRTLGroupA || event.widget == buttonLTRGroupA){ >++ groupA.setOrientation(event.widget == buttonLTRGroupA ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >++ } >++ if(event.widget == buttonLTRGroupC || event.widget == buttonRTLGroupC){ >++ groupC.setOrientation(event.widget == buttonLTRGroupC ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >++ } >++ if(event.widget == buttonLTRGroupD || event.widget == buttonRTLGroupD){ >++ groupD.setOrientation(event.widget == buttonLTRGroupD ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >++ } >++ if(event.widget == buttonListRTLCompositeGroups || event.widget == buttonListLTRCompositeGroups){ >++ setOrientationItemFromList(list.getSelectionIndices(), event.widget == buttonListLTRCompositeGroups ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >++ } >++ } >++ }; >++ >++ //this.setBackground(new Color(Display.getDefault(),192, 192, 192)); >++ FormLayout thisLayout = new FormLayout(); >++ this.setLayout(thisLayout); >++ { >++ { >++ FormData listLData = new FormData(); >++ listLData.left = new FormAttachment(0, 1000, 505); >++ listLData.top = new FormAttachment(0, 1000, 26); >++ listLData.width = 99; >++ listLData.height = 509; >++ list = new List(this, style | SWT.MULTI | SWT.BORDER); >++ list.setItems (widgetsListData); >++ >++ list.setLayoutData(listLData); >++ } >++ { >++ buttonListRTLCompositeGroups = new Button(this, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonRTLCompositeGroupsLData = new FormData(); >++ buttonRTLCompositeGroupsLData.left = new FormAttachment(0, 1000, 505); >++ buttonRTLCompositeGroupsLData.top = new FormAttachment(904, 1000, 0); >++ buttonRTLCompositeGroupsLData.width = 50; >++ buttonRTLCompositeGroupsLData.height = 23; >++ buttonListRTLCompositeGroups.setLayoutData(buttonRTLCompositeGroupsLData); >++ buttonListRTLCompositeGroups.setText("Item RTL"); >++ } >++ { >++ buttonListLTRCompositeGroups = new Button(this, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonLTRCompositeGroupsLData = new FormData(); >++ buttonLTRCompositeGroupsLData.width = 50; >++ buttonLTRCompositeGroupsLData.height = 23; >++ buttonLTRCompositeGroupsLData.left = new FormAttachment(0, 1000, 559); >++ buttonLTRCompositeGroupsLData.top = new FormAttachment(904, 1000, 0); >++ buttonListLTRCompositeGroups.setLayoutData(buttonLTRCompositeGroupsLData); >++ buttonListLTRCompositeGroups.setText("Item LTR"); >++ } >++ { >++ buttonRTLCompositeGroups = new Button(this, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonRTLCompositeGroupsLData = new FormData(); >++ buttonRTLCompositeGroupsLData.left = new FormAttachment(860, 1000, 0); >++ buttonRTLCompositeGroupsLData.top = new FormAttachment(950, 1000, 0); >++ buttonRTLCompositeGroupsLData.width = 30; >++ buttonRTLCompositeGroupsLData.height = 23; >++ buttonRTLCompositeGroups.setLayoutData(buttonRTLCompositeGroupsLData); >++ buttonRTLCompositeGroups.setText("RTL"); >++ } >++ { >++ buttonLTRCompositeGroups = new Button(this, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonLTRCompositeGroupsLData = new FormData(); >++ buttonLTRCompositeGroupsLData.width = 30; >++ buttonLTRCompositeGroupsLData.height = 23; >++ buttonLTRCompositeGroupsLData.left = new FormAttachment(916, 1000, 0); >++ buttonLTRCompositeGroupsLData.top = new FormAttachment(950, 1000, 0); >++ buttonLTRCompositeGroups.setLayoutData(buttonLTRCompositeGroupsLData); >++ buttonLTRCompositeGroups.setText("LTR"); >++ } >++ { >++ groupA = new Group(this, SWT.NONE | style); >++ FormLayout groupALayout = new FormLayout(); >++ groupA.setLayout(groupALayout); >++ FormData groupALData = new FormData(); >++ groupALData.width = 385; >++ groupALData.height = 421; >++ groupALData.left = new FormAttachment(11, 1000, 0); >++ groupALData.right = new FormAttachment(817, 1000, 0); >++ groupALData.top = new FormAttachment(9, 1000, 0); >++ groupALData.bottom = new FormAttachment(731, 1000, 0); >++ groupA.setLayoutData(groupALData); >++ groupA.setText("Very complex group..."); >++ groupA.setBackground(new Color(Display.getDefault(),192,192,192)); >++ { >++ comboSimpleGroupA = new Combo(groupA, SWT.NONE | style | SWT.SIMPLE); >++ FormData comboSimpleGroupALData = new FormData(); >++ comboSimpleGroupALData.left = new FormAttachment(0, 1000, 315); >++ comboSimpleGroupALData.top = new FormAttachment(0, 1000, 188); >++ comboSimpleGroupALData.width = 135; >++// comboSimpleGroupALData.height = 21; >++ comboSimpleGroupA.setLayoutData(comboSimpleGroupALData); >++ comboSimpleGroupA.setText("combo"); >++ comboSimpleGroupA.setItems (ListData); >++ if (ListData.length >= 3) { >++ comboSimpleGroupA.setText(ListData [2]); >++ } >++ } >++ { >++ comboDropDownGroupA = new Combo(groupA, SWT.NONE | style | SWT.DROP_DOWN); >++ FormData comboDropDownGroupALData = new FormData(); >++ comboDropDownGroupALData.left = new FormAttachment(0, 1000, 315); >++ comboDropDownGroupALData.top = new FormAttachment(0, 1000, 150); >++// comboDropDownGroupALData.width = 31; >++// comboDropDownGroupALData.height = 21; >++ comboDropDownGroupA.setLayoutData(comboDropDownGroupALData); >++ comboDropDownGroupA.setText("simple combo"); >++ comboDropDownGroupA.setItems (ListData); >++ if (ListData.length >= 3) { >++ comboDropDownGroupA.setText(ListData [2]); >++ } >++ } >++ { >++ buttonTextPicGroupA = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonTextPicGroupALData = new FormData(); >++ buttonTextPicGroupALData.left = new FormAttachment(0, 1000, 316); >++ buttonTextPicGroupALData.top = new FormAttachment(0, 1000, 103); >++ buttonTextPicGroupALData.width = 91; >++ buttonTextPicGroupALData.height = 23; >++ buttonTextPicGroupA.setLayoutData(buttonTextPicGroupALData); >++ buttonTextPicGroupA.setText("Text..."); >++ buttonTextPicGroupA.setImage(instance.images[CombinedOrientationExample.ciOpenFolder]); >++ >++ } >++ { >++ buttonPic = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonPicLData = new FormData(); >++ buttonPicLData.left = new FormAttachment(0, 1000, 374); >++ buttonPicLData.top = new FormAttachment(0, 1000, 74); >++ buttonPic.setLayoutData(buttonPicLData); >++ buttonPic.setImage(instance.images[CombinedOrientationExample.ciOpenFolder]); >++ >++ } >++ { >++ buttonTextGroupA = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonTextGroupALData = new FormData(); >++ buttonTextGroupALData.left = new FormAttachment(0, 1000, 316); >++ buttonTextGroupALData.top = new FormAttachment(0, 1000, 74); >++ buttonTextGroupALData.width = 46; >++ buttonTextGroupALData.height = 23; >++ buttonTextGroupA.setLayoutData(buttonTextGroupALData); >++ buttonTextGroupA.setText("Text..."); >++ } >++ { >++ buttonRTLGroupA = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonRTLGroupALData = new FormData(); >++ buttonRTLGroupALData.left = new FormAttachment(0, 1000, 353); >++ buttonRTLGroupALData.top = new FormAttachment(0, 1000, 384); >++ buttonRTLGroupALData.width = 30; >++ buttonRTLGroupALData.height = 23; >++ buttonRTLGroupA.setLayoutData(buttonRTLGroupALData); >++ buttonRTLGroupA.setText("RTL"); >++ } >++ { >++ buttonLTRGroupA = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonLTRGroupALData = new FormData(); >++ buttonLTRGroupALData.left = new FormAttachment(0, 1000, 317); >++ buttonLTRGroupALData.top = new FormAttachment(0, 1000, 384); >++ buttonLTRGroupALData.width = 30; >++ buttonLTRGroupALData.height = 23; >++ buttonLTRGroupA.setLayoutData(buttonLTRGroupALData); >++ buttonLTRGroupA.setText("LTR"); >++ } >++ { >++ labelPicture = new Label(groupA, SWT.NONE | style); >++ FormData labelPictureLData = new FormData(); >++ labelPictureLData.left = new FormAttachment(0, 1000, 316); >++ labelPictureLData.top = new FormAttachment(0, 1000, 38); >++ labelPicture.setLayoutData(labelPictureLData); >++ labelPicture.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >++ } >++ { >++ groupD = new Group(groupA, SWT.NONE | style); >++ FormLayout groupDLayout = new FormLayout(); >++ groupD.setLayout(groupDLayout); >++ FormData groupDLData = new FormData(); >++ groupDLData.width = 267; >++ groupDLData.height = 384; >++ groupDLData.left = new FormAttachment(14, 1000, 0); >++ groupDLData.right = new FormAttachment(638, 1000, 0); >++ groupDLData.top = new FormAttachment(13, 1000, 0); >++ groupDLData.bottom = new FormAttachment(963, 1000, 0); >++ groupD.setLayoutData(groupDLData); >++ groupD.setText("\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4..."); >++ groupD.setBackground(new Color(Display.getDefault(),192, 192, 192)); >++ { >++ labelMultiText = new Label(groupD, SWT.NONE); >++ FormData labelMultiTextLData = new FormData(); >++ labelMultiTextLData.left = new FormAttachment(0, 1000, 0); >++ labelMultiTextLData.top = new FormAttachment(0, 1000, 306); >++ //labelMultiTextLData.width = 56; >++ labelMultiTextLData.height = 13; >++ labelMultiText.setLayoutData(labelMultiTextLData); >++ labelMultiText.setText("SWT.MULTI..."); >++ } >++ { >++ labelSimpleText = new Label(groupD, SWT.NONE); >++ FormData labelSimpleTextLData = new FormData(); >++ labelSimpleTextLData.left = new FormAttachment(0, 1000, 0); >++ labelSimpleTextLData.top = new FormAttachment(0, 1000, 280); >++ //labelSimpleTextLData.width = 53; >++ labelSimpleTextLData.height = 13; >++ labelSimpleText.setLayoutData(labelSimpleTextLData); >++ labelSimpleText.setText("SWT.SINGLE..."); >++ } >++ { >++ buttonRTLGroupD = new Button(groupD, SWT.PUSH | SWT.CENTER); >++ FormData buttonRTLGroupDLData = new FormData(); >++ buttonRTLGroupDLData.width = 108; >++ buttonRTLGroupDLData.height = 23; >++ buttonRTLGroupDLData.left = new FormAttachment(20, 1000, 0); >++ buttonRTLGroupDLData.right = new FormAttachment(425, 1000, 0); >++ buttonRTLGroupDLData.top = new FormAttachment(14, 1000, 0); >++ buttonRTLGroupDLData.bottom = new FormAttachment(74, 1000, 0); >++ buttonRTLGroupD.setLayoutData(buttonRTLGroupDLData); >++ buttonRTLGroupD.setText("\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 RTL..."); >++ } >++ { >++ buttonLTRGroupD = new Button(groupD, SWT.PUSH | SWT.CENTER); >++ FormData buttonLTRGroupDLData = new FormData(); >++ buttonLTRGroupDLData.width = 108; >++ buttonLTRGroupDLData.height = 23; >++ buttonLTRGroupDLData.left = new FormAttachment(20, 1000, 0); >++ buttonLTRGroupDLData.right = new FormAttachment(425, 1000, 0); >++ buttonLTRGroupDLData.top = new FormAttachment(87, 1000, 0); >++ buttonLTRGroupDLData.bottom = new FormAttachment(147, 1000, 0); >++ buttonLTRGroupD.setLayoutData(buttonLTRGroupDLData); >++ buttonLTRGroupD.setText("\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 LTR..."); >++ } >++ { >++ tabFolderInGroupD = new TabFolder(groupD, SWT.NONE | style); >++ { >++ cTabItem1 = new TabItem(tabFolderInGroupD, SWT.NONE | style); >++ cTabItem1.setText("Tab"); >++ { >++ compositeInTabGtoupD = new Composite(tabFolderInGroupD, SWT.NONE | style); >++ GridLayout compositeInTabGtoupDLayout = new GridLayout(); >++ compositeInTabGtoupDLayout.makeColumnsEqualWidth = true; >++ compositeInTabGtoupD.setLayout(compositeInTabGtoupDLayout); >++ cTabItem1.setControl(compositeInTabGtoupD); >++ { >++ GridData tableGroupDLData = new GridData(); >++ tableGroupDLData.widthHint = 222; >++ tableGroupDLData.heightHint = 166; >++ tableGroupD = new Table(compositeInTabGtoupD, SWT.NONE | style); >++ for (int i = 0; i < columnTitles.length; i++) { >++ TableColumn tableColumn = new TableColumn(tableGroupD, SWT.NONE); >++ tableColumn.setText(columnTitles[i]); >++ tableColumn.setImage(instance.images [i % 3]); >++ } >++ tableGroupD.setSortColumn(tableGroupD.getColumn(0)); >++ for (int i=0; i<16; i++) { >++ TableItem item = new TableItem (tableGroupD, SWT.NONE); >++ setItemText (item, i, CombinedOrientationExample.getResourceString("Index") + i); >++ } >++ packColumns(); >++ tableGroupD.setHeaderVisible(true); >++ tableGroupD.setLinesVisible (true); >++ tableGroupD.setLayoutData(tableGroupDLData); >++ } >++ } >++ } >++ FormData tabFolderInGroupDLData = new FormData(); >++ tabFolderInGroupDLData.width = 250; >++ tabFolderInGroupDLData.height = 193; >++ tabFolderInGroupDLData.left = new FormAttachment(20, 1000, 0); >++ tabFolderInGroupDLData.right = new FormAttachment(971, 1000, 0); >++ tabFolderInGroupDLData.top = new FormAttachment(160, 1000, 0); >++ tabFolderInGroupDLData.bottom = new FormAttachment(720, 1000, 0); >++ tabFolderInGroupD.setLayoutData(tabFolderInGroupDLData); >++ tabFolderInGroupD.setSelection(0); >++ tabFolderInGroupD.setBackground(new Color(Display.getDefault(),192, 192, 192)); >++ } >++ { >++ textSingleGroupD = new Text(groupD, SWT.NONE | style | SWT.BORDER); >++ FormData textSingleGroupDLData = new FormData(); >++ textSingleGroupDLData.width = 188; >++ textSingleGroupDLData.height = 20; >++ textSingleGroupDLData.left = new FormAttachment(256, 1000, 0); >++ textSingleGroupDLData.right = new FormAttachment(983, 1000, 0); >++ textSingleGroupDLData.top = new FormAttachment(730, 1000, 0); >++ textSingleGroupDLData.bottom = new FormAttachment(782, 1000, 0); >++ textSingleGroupD.setLayoutData(textSingleGroupDLData); >++ } >++ { >++ textAriaGroupD = new Text(groupD, SWT.MULTI | SWT.WRAP | style | SWT.BORDER); >++ FormData textAriaGroupDLData = new FormData(); >++ textAriaGroupDLData.width = 188; >++ textAriaGroupDLData.height = 63; >++ textAriaGroupDLData.left = new FormAttachment(256, 1000, 0); >++ textAriaGroupDLData.right = new FormAttachment(983, 1000, 0); >++ textAriaGroupDLData.top = new FormAttachment(798, 1000, 0); >++ textAriaGroupDLData.bottom = new FormAttachment(962, 1000, 0); >++ textAriaGroupD.setLayoutData(textAriaGroupDLData); >++ } >++ } >++ { >++ labelTextGroupA = new Label(groupA, SWT.NONE | style); >++ FormData labelTextGroupALData = new FormData(); >++ labelTextGroupALData.width = 121; >++ labelTextGroupALData.height = 13; >++ labelTextGroupALData.left = new FormAttachment(704, 1000, 0); >++ labelTextGroupALData.right = new FormAttachment(980, 1000, 0); >++ labelTextGroupALData.top = new FormAttachment(32, 1000, 0); >++ labelTextGroupALData.bottom = new FormAttachment(62, 1000, 0); >++ labelTextGroupA.setLayoutData(labelTextGroupALData); >++ labelTextGroupA.setText("I work at \u05d9\u05d1\u05de Israel..."); >++ } >++ } >++ { >++ groupC = new Group(this, SWT.NONE | style); >++ FormLayout groupCLayout = new FormLayout(); >++ groupC.setLayout(groupCLayout); >++ FormData groupCLData = new FormData(); >++ groupCLData.width = 439; >++ groupCLData.height = 134; >++ groupCLData.left = new FormAttachment(11, 1000, 0); >++ groupCLData.right = new FormAttachment(819, 1000, 0); >++ groupCLData.top = new FormAttachment(741, 1000, 0); >++ groupCLData.bottom = new FormAttachment(989, 1000, 0); >++ groupC.setLayoutData(groupCLData); >++ groupC.setText("Small group..."); >++ groupC.setBackground(new Color(Display.getDefault(),192,192,192)); >++ { >++ FormData sliderGtoupCLData = new FormData(); >++ sliderGtoupCLData.left = new FormAttachment(0, 1000, 201); >++ sliderGtoupCLData.top = new FormAttachment(0, 1000, 110); >++ sliderGtoupCLData.width = 155; >++ sliderGtoupCLData.height = 17; >++ sliderGtoupC = new Slider(groupC, SWT.NONE); >++ sliderGtoupC.setLayoutData(sliderGtoupCLData); >++ } >++ { >++ buttonRTLGroupC = new Button(groupC, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonRTLGroupCLData = new FormData(); >++ buttonRTLGroupCLData.left = new FormAttachment(0, 1000, 400); >++ buttonRTLGroupCLData.top = new FormAttachment(0, 1000, 110); >++ buttonRTLGroupCLData.width = 30; >++ buttonRTLGroupCLData.height = 23; >++ buttonRTLGroupC.setLayoutData(buttonRTLGroupCLData); >++ buttonRTLGroupC.setText("RTL"); >++ } >++ { >++ FormData treeGroupCLData = new FormData(); >++ treeGroupCLData.width = 150; >++ treeGroupCLData.height = 112; >++ treeGroupCLData.left = new FormAttachment(7, 1000, 0); >++// treeGroupCLData.right = new FormAttachment(413, 1000, 0); >++ treeGroupCLData.top = new FormAttachment(26, 1000, 0); >++// treeGroupCLData.bottom = new FormAttachment(988, 1000, 0); >++ treeGroupC = new Tree(groupC, SWT.NONE | style); >++ updateTree(); >++ treeGroupC.setLayoutData(treeGroupCLData); >++ } >++ { >++ FormData coolBarGroupCLData = new FormData(); >++ coolBarGroupCLData.width = 223; >++ coolBarGroupCLData.height = 22; >++ coolBarGroupCLData.left = new FormAttachment(458, 1000, 0); >++ coolBarGroupCLData.right = new FormAttachment(966, 1000, 0); >++ coolBarGroupCLData.top = new FormAttachment(26, 1000, 0); >++ coolBarGroupCLData.bottom = new FormAttachment(190, 1000, 0); >++ coolBarGroupC = new CoolBar(groupC, SWT.NONE | style); >++ updateCoolbar(); >++ coolBarGroupC.setLayoutData(coolBarGroupCLData); >++// { >++// coolItem1 = new CoolItem(coolBarGroupC, SWT.NONE | style); >++// coolItem1.setMinimumSize(new org.eclipse.swt.graphics.Point(48, 23)); >++// coolItem1.setPreferredSize(new org.eclipse.swt.graphics.Point(48, 23)); >++// coolItem1.setSize(48, 23); >++// { >++// toolBar1 = new ToolBar(coolBarGroupC, SWT.NONE | style); >++// coolItem1.setControl(toolBar1); >++// } >++// } >++ } >++ { >++ FormData progressBarGroupCLData = new FormData(); >++ progressBarGroupCLData.width = 229; >++ progressBarGroupCLData.height = 17; >++ progressBarGroupCLData.left = new FormAttachment(458, 1000, 0); >++ progressBarGroupCLData.right = new FormAttachment(980, 1000, 0); >++ progressBarGroupCLData.top = new FormAttachment(652, 1000, 0); >++ progressBarGroupCLData.bottom = new FormAttachment(779, 1000, 0); >++ progressBarGroupC = new ProgressBar(groupC, style | SWT.INDETERMINATE); >++ progressBarGroupC.setLayoutData(progressBarGroupCLData); >++ } >++ { >++ buttonLTRGroupC = new Button(groupC, SWT.PUSH | SWT.CENTER | style); >++ FormData buttonLTRGroupCLData = new FormData(); >++ buttonLTRGroupCLData.width = 32; >++ buttonLTRGroupCLData.height = 23; >++ buttonLTRGroupCLData.left = new FormAttachment(0, 1000, 362); >++ buttonLTRGroupCLData.top = new FormAttachment(0, 1000, 110); >++ buttonLTRGroupC.setLayoutData(buttonLTRGroupCLData); >++ buttonLTRGroupC.setText("LTR"); >++ } >++ } >++ } >++ buttonRTLGroupA.addSelectionListener (bidiListener); >++ buttonLTRGroupA.addSelectionListener (bidiListener); >++ buttonRTLCompositeGroups.addSelectionListener (bidiListener); >++ buttonLTRCompositeGroups.addSelectionListener (bidiListener); >++ buttonListRTLCompositeGroups.addSelectionListener (bidiListener); >++ buttonListLTRCompositeGroups.addSelectionListener (bidiListener); >++ buttonLTRGroupC.addSelectionListener (bidiListener); >++ buttonRTLGroupC.addSelectionListener (bidiListener); >++ buttonLTRGroupD.addSelectionListener (bidiListener); >++ buttonRTLGroupD.addSelectionListener (bidiListener); >++ this.layout(); >++ } catch (Exception e) { >++ e.printStackTrace(); >++ } >++ setToolTipText("I'm " + (style == SWT.LEFT_TO_RIGHT ? "LTR" : "RTL")); >++ this.compositeGroups = this; >++ >++ controls = new Control[]{groupD, >++ tabFolderInGroupD, >++// cTabItem1, >++ compositeInTabGtoupD, >++ tableGroupD, >++ labelSimpleText, >++ textSingleGroupD, >++ labelMultiText, >++ textAriaGroupD, >++ buttonLTRGroupD, >++ buttonRTLGroupD, >++ null, >++ groupA, >++ labelTextGroupA, >++ labelPicture, >++ buttonTextGroupA, >++ buttonPic, >++ buttonTextPicGroupA, >++ comboDropDownGroupA, >++ comboSimpleGroupA, >++ buttonLTRGroupA, >++ buttonRTLGroupA, >++ null, >++ groupC, >++ treeGroupC, >++ coolBarGroupC, >++ progressBarGroupC, >++ sliderGtoupC, >++// pushItem, >++// dropDownItem, >++// radioItem, >++// checkItem, >++// textItem, >++ buttonLTRGroupC, >++ buttonRTLGroupC, >++ null, >++ list}; >++ } >++ void setItemText(TableItem item, int i, String node) { >++ int index = i % 3; >++ tableData [index][0] = node; >++ item.setText (tableData [index]); >++ } >++ void packColumns () { >++ int columnCount = tableGroupD.getColumnCount(); >++ for (int i = 0; i < columnCount; i++) { >++ TableColumn tableColumn = tableGroupD.getColumn(i); >++ tableColumn.pack(); >++ } >++ } >++ void updateTree(){ >++ /* Create the image tree */ >++ TreeItem treeRoots[]; >++ TreeItem item; >++ Image image = instance.images[CombinedOrientationExample.ciClosedFolder]; >++ for (int i = 0; i < 4; i++) { >++ item = new TreeItem (treeGroupC, SWT.NONE); >++ setItemText(item, i, CombinedOrientationExample.getResourceString("Node_" + (i + 1))); >++ item.setImage(image); >++ if (i < 3) { >++ TreeItem subitem = new TreeItem (item, SWT.NONE); >++ setItemText(subitem, i, CombinedOrientationExample.getResourceString("Node_" + (i + 1) + "_1")); >++ subitem.setImage(image); >++ } >++ } >++ treeRoots = treeGroupC.getItems (); >++ item = new TreeItem (treeRoots[1], SWT.NONE); >++ setItemText(item, 1, CombinedOrientationExample.getResourceString("Node_2_2")); >++ item.setImage(image); >++ item = new TreeItem (item, SWT.NONE); >++ setItemText(item, 1, CombinedOrientationExample.getResourceString("Node_2_2_1")); >++ item.setImage(image); >++ imageNode1 = treeRoots[0]; >++ packColumns(treeGroupC); >++ >++ } >++ void updateCoolbar(){ >++ int style = getStyle(), itemStyle = 0; >++ >++ /* Compute the widget, item, and item toolBar styles */ >++ int toolBarStyle = SWT.FLAT; >++ boolean vertical = false; >++ style |= SWT.HORIZONTAL; >++ toolBarStyle |= SWT.HORIZONTAL; >++ style |= SWT.BORDER; >++ >++ /* Create the push button toolbar cool item */ >++ ToolBar toolBar = new ToolBar (coolBarGroupC, toolBarStyle); >++ ToolItem item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[CombinedOrientationExample.ciTarget]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (toolBar, SWT.SEPARATOR); >++ item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ pushItem = new CoolItem (coolBarGroupC, itemStyle); >++ pushItem.setControl (toolBar); >++ pushItem.addSelectionListener (new CoolItemSelectionListener()); >++ >++ /* Create the dropdown toolbar cool item */ >++ toolBar = new ToolBar (coolBarGroupC, toolBarStyle); >++ item = new ToolItem (toolBar, SWT.DROP_DOWN); >++ item.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.DROP_DOWN"); >++// item.addSelectionListener (new DropDownSelectionListener()); >++ item = new ToolItem (toolBar, SWT.DROP_DOWN); >++ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.DROP_DOWN"); >++// item.addSelectionListener (new DropDownSelectionListener()); >++ dropDownItem = new CoolItem (coolBarGroupC, itemStyle); >++ dropDownItem.setControl (toolBar); >++ dropDownItem.addSelectionListener (new CoolItemSelectionListener()); >++ >++ /* Create the radio button toolbar cool item */ >++ toolBar = new ToolBar (coolBarGroupC, toolBarStyle); >++ item = new ToolItem (toolBar, SWT.RADIO); >++ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ item = new ToolItem (toolBar, SWT.RADIO); >++ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ item = new ToolItem (toolBar, SWT.RADIO); >++ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ radioItem = new CoolItem (coolBarGroupC, itemStyle); >++ radioItem.setControl (toolBar); >++ radioItem.addSelectionListener (new CoolItemSelectionListener()); >++ >++ /* Create the check button toolbar cool item */ >++ toolBar = new ToolBar (coolBarGroupC, toolBarStyle); >++ item = new ToolItem (toolBar, SWT.CHECK); >++ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.CHECK"); >++ item = new ToolItem (toolBar, SWT.CHECK); >++ item.setImage (instance.images[CombinedOrientationExample.ciTarget]); >++ item.setToolTipText ("SWT.CHECK"); >++ item = new ToolItem (toolBar, SWT.CHECK); >++ item.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.CHECK"); >++ item = new ToolItem (toolBar, SWT.CHECK); >++ item.setImage (instance.images[CombinedOrientationExample.ciTarget]); >++ item.setToolTipText ("SWT.CHECK"); >++ checkItem = new CoolItem (coolBarGroupC, itemStyle); >++ checkItem.setControl (toolBar); >++ checkItem.addSelectionListener (new CoolItemSelectionListener()); >++ >++ /* Create the text cool item */ >++ if (!vertical) { >++ Text text = new Text (coolBarGroupC, SWT.BORDER | SWT.SINGLE); >++ textItem = new CoolItem (coolBarGroupC, itemStyle); >++ textItem.setControl (text); >++ textItem.addSelectionListener (new CoolItemSelectionListener()); >++ Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); >++ textSize = textItem.computeSize(textSize.x, textSize.y); >++ textItem.setMinimumSize(textSize); >++ textItem.setPreferredSize(textSize); >++ textItem.setSize(textSize); >++ } >++ >++ /* Set the sizes after adding all cool items */ >++ CoolItem[] coolItems = coolBarGroupC.getItems(); >++ for (int i = 0; i < coolItems.length; i++) { >++ CoolItem coolItem = coolItems[i]; >++ Control control = coolItem.getControl(); >++ Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); >++ Point coolSize = coolItem.computeSize(size.x, size.y); >++ if (control instanceof ToolBar) { >++ ToolBar bar = (ToolBar)control; >++ if (bar.getItemCount() > 0) { >++ if (vertical) { >++ size.y = bar.getItem(0).getBounds().height; >++ } else { >++ size.x = bar.getItem(0).getWidth(); >++ } >++ } >++ } >++ coolItem.setMinimumSize(size); >++ coolItem.setPreferredSize(coolSize); >++ coolItem.setSize(coolSize); >++ } >++ } >++ void setItemText(TreeItem item, int i, String node) { >++ int index = i % 3; >++ tableData [index][0] = node; >++ item.setText (tableData [index]); >++ } >++ void packColumns (Tree tree) { >++ int columnCount = tree.getColumnCount(); >++ for (int i = 0; i < columnCount; i++) { >++ TreeColumn treeColumn = tree.getColumn(i); >++ treeColumn.pack(); >++ } >++ } >++ void setOrientationItemFromList(int[] indexArr, int orientation){ >++ for (int i = 0; i < indexArr.length; i++) { >++ controls[indexArr[i]].setOrientation(orientation); >++ } >++ } >++ class CoolItemSelectionListener extends SelectionAdapter { >++ private Menu menu = null; >++ >++ public void widgetSelected(SelectionEvent event) { >++ /** >++ * A selection event will be fired when the cool item >++ * is selected by its gripper or if the drop down arrow >++ * (or 'chevron') is selected. Examine the event detail >++ * to determine where the widget was selected. >++ */ >++ if (event.detail == SWT.ARROW) { >++ /* If the popup menu is already up (i.e. user pressed arrow twice), >++ * then dispose it. >++ */ >++ if (menu != null) { >++ menu.dispose(); >++ menu = null; >++ return; >++ } >++ >++ /* Get the cool item and convert its bounds to display coordinates. */ >++ CoolItem coolItem = (CoolItem) event.widget; >++ Rectangle itemBounds = coolItem.getBounds (); >++ itemBounds.width = event.x - itemBounds.x; >++ Point pt = coolBarGroupC.toDisplay(new Point (itemBounds.x, itemBounds.y)); >++ itemBounds.x = pt.x; >++ itemBounds.y = pt.y; >++ >++ /* Get the toolbar from the cool item. */ >++ ToolBar toolBar = (ToolBar) coolItem.getControl (); >++ ToolItem[] tools = toolBar.getItems (); >++ int toolCount = tools.length; >++ >++ /* Convert the bounds of each tool item to display coordinates, >++ * and determine which ones are past the bounds of the cool item. >++ */ >++ int i = 0; >++ while (i < toolCount) { >++ Rectangle toolBounds = tools[i].getBounds (); >++ pt = toolBar.toDisplay(new Point(toolBounds.x, toolBounds.y)); >++ toolBounds.x = pt.x; >++ toolBounds.y = pt.y; >++ Rectangle intersection = itemBounds.intersection (toolBounds); >++ if (!intersection.equals (toolBounds)) break; >++ i++; >++ } >++ >++ /* Create a pop-up menu with items for each of the hidden buttons. */ >++ menu = new Menu (getShell(), SWT.POP_UP | (coolBarGroupC.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT))); >++ for (int j = i; j < toolCount; j++) { >++ ToolItem tool = tools[j]; >++ Image image = tool.getImage(); >++ if (image == null) { >++ new MenuItem (menu, SWT.SEPARATOR); >++ } else { >++ if ((tool.getStyle() & SWT.DROP_DOWN) != 0) { >++ MenuItem menuItem = new MenuItem (menu, SWT.CASCADE); >++ menuItem.setImage(image); >++ String text = tool.getToolTipText(); >++ if (text != null) menuItem.setText(text); >++ Menu m = new Menu(menu); >++ menuItem.setMenu(m); >++ for (int k = 0; k < 9; ++k) { >++ text = ControlExample.getResourceString("DropDownData_" + k); >++ if (text.length() != 0) { >++ MenuItem mi = new MenuItem(m, SWT.NONE); >++ mi.setText(text); >++ /* Application code to perform the action for the submenu item would go here. */ >++ } else { >++ new MenuItem(m, SWT.SEPARATOR); >++ } >++ } >++ } else { >++ MenuItem menuItem = new MenuItem (menu, SWT.NONE); >++ menuItem.setImage(image); >++ String text = tool.getToolTipText(); >++ if (text != null) menuItem.setText(text); >++ } >++ /* Application code to perform the action for the menu item would go here. */ >++ } >++ } >++ >++ /* Display the pop-up menu at the lower left corner of the arrow button. >++ * Dispose the menu when the user is done with it. >++ */ >++ pt = coolBarGroupC.toDisplay(new Point(event.x, event.y)); >++ menu.setLocation (pt.x, pt.y); >++ menu.setVisible (true); >++ while (menu != null && !menu.isDisposed() && menu.isVisible ()) { >++ if (!getDisplay().readAndDispatch ()) getDisplay().sleep (); >++ } >++ if (menu != null) { >++ menu.dispose (); >++ menu = null; >++ } >++ } >++ } >++ } >++ >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/CombinedBasic.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CombinedBasic.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CombinedBasic.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CombinedBasic.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,165 @@ >++package org.eclipse.swt.examples.mirroringTest; >++import org.eclipse.swt.*; >++import org.eclipse.swt.events.SelectionAdapter; >++import org.eclipse.swt.events.SelectionEvent; >++import org.eclipse.swt.events.SelectionListener; >++import org.eclipse.swt.graphics.Color; >++import org.eclipse.swt.graphics.Point; >++import org.eclipse.swt.graphics.Rectangle; >++import org.eclipse.swt.internal.win32.OS; >++import org.eclipse.swt.layout.FillLayout; >++import org.eclipse.swt.layout.FormAttachment; >++import org.eclipse.swt.layout.FormData; >++import org.eclipse.swt.layout.FormLayout; >++import org.eclipse.swt.widgets.Button; >++import org.eclipse.swt.widgets.Composite; >++import org.eclipse.swt.widgets.Display; >++import org.eclipse.swt.widgets.Menu; >++import org.eclipse.swt.widgets.MenuItem; >++import org.eclipse.swt.widgets.Shell; >++ >++public class CombinedBasic extends org.eclipse.swt.widgets.Composite { >++ private Menu menu1; >++ private Menu fileMenu; >++ private MenuItem fileMenuItem; >++ private MenuItem aboutMenuItem; >++ private MenuItem contentsMenuItem; >++ private Menu helpMenu; >++ private MenuItem helpMenuItem; >++ private MenuItem exitMenuItem; >++ private MenuItem closeFileMenuItem; >++ private MenuItem saveFileMenuItem; >++ private MenuItem newFileMenuItem; >++ private MenuItem openFileMenuItem; >++ >++ private Button buttonLTRFocused; >++ private Button buttonRTLFocused; >++// private Button buttonRTLShell; >++// private Button buttonLTRShell; >++ >++ private CombineComposition composition1;// = new CombineComposition(this, getStyle() | SWT.LEFT_TO_RIGHT); >++ private CombineComposition composition2;// = new CombineComposition(this, getStyle() | SWT.RIGHT_TO_LEFT); >++ >++ public CombinedBasic(Composite parent, int style, CombinedOrientationExample instance) { >++ super(parent, style); >++ initGUI(instance); >++ } >++ >++ /** >++ * Initializes the GUI. >++ */ >++ private void initGUI(CombinedOrientationExample instance) { >++ /* Add the listeners */ >++ SelectionListener setOrientationListener = new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent event) { >++ int flag = event.widget == buttonRTLFocused ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >++ OS.GetFocus(); >++ } >++ }; >++ try { >++ this.setSize(1049, 612); >++ this.setBackground(new Color(Display.getDefault(),192, 192, 192)); >++ FormLayout thisLayout = new FormLayout(); >++ this.setLayout(thisLayout); >++ { >++ composition1 = new CombineComposition(this, getStyle() | SWT.LEFT_TO_RIGHT, instance); >++ FormLayout compositeGroupsLayout = new FormLayout(); >++ FormData compositeGroupsLData = new FormData(); >++ compositeGroupsLData.left = new FormAttachment(0, 1000, 10); >++ compositeGroupsLData.top = new FormAttachment(0, 1000, 7); >++ compositeGroupsLData.width = 612; >++ compositeGroupsLData.height = 605; >++ composition1.setLayoutData(compositeGroupsLData); >++ composition1.setLayout(compositeGroupsLayout); >++ } >++ { >++ composition2 = new CombineComposition(this, SWT.RIGHT_TO_LEFT, instance); >++ FormLayout compositeGroupsLayout = new FormLayout(); >++ FormData compositeGroupsLData = new FormData(); >++ compositeGroupsLData.left = new FormAttachment(0, 1000, 632); >++ compositeGroupsLData.top = new FormAttachment(0, 1000, 7); >++ compositeGroupsLData.width = 612; >++ compositeGroupsLData.height = 605; >++ composition2.setLayoutData(compositeGroupsLData); >++ composition2.setLayout(compositeGroupsLayout); >++ } >++ { >++ menu1 = new Menu(getShell(), SWT.BAR); >++ getShell().setMenuBar(menu1); >++ { >++ fileMenuItem = new MenuItem(menu1, SWT.CASCADE); >++ fileMenuItem.setText("File"); >++ { >++ fileMenu = new Menu(fileMenuItem); >++ { >++ openFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >++ openFileMenuItem.setText("Open"); >++ } >++ { >++ newFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >++ newFileMenuItem.setText("New"); >++ } >++ { >++ saveFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >++ saveFileMenuItem.setText("Save"); >++ } >++ { >++ closeFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >++ closeFileMenuItem.setText("Close"); >++ } >++ { >++ exitMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >++ exitMenuItem.setText("Exit"); >++ } >++ fileMenuItem.setMenu(fileMenu); >++ } >++ } >++ { >++ helpMenuItem = new MenuItem(menu1, SWT.CASCADE); >++ helpMenuItem.setText("Help"); >++ { >++ helpMenu = new Menu(helpMenuItem); >++ { >++ contentsMenuItem = new MenuItem(helpMenu, SWT.CASCADE); >++ contentsMenuItem.setText("Contents"); >++ } >++ { >++ aboutMenuItem = new MenuItem(helpMenu, SWT.CASCADE); >++ aboutMenuItem.setText("About"); >++ } >++ helpMenuItem.setMenu(helpMenu); >++ } >++ } >++ } >++ this.layout(); >++ } catch (Exception e) { >++ e.printStackTrace(); >++ } >++ } >++ >++ /** >++ * Auto-generated main method to display this >++ * org.eclipse.swt.widgets.Composite inside a new Shell. >++ >++ public static void main(String[] args) { >++ Display display = Display.getDefault(); >++ Shell shell = new Shell(display); >++ CombinedBasic inst = new CombinedBasic(shell, SWT.NULL); >++ Point size = inst.getSize(); >++ shell.setLayout(new FillLayout()); >++ shell.layout(); >++ if(size.x == 0 && size.y == 0) { >++ inst.pack(); >++ shell.pack(); >++ } else { >++ Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y); >++ shell.setSize(shellBounds.width, shellBounds.height); >++ } >++ shell.open(); >++ while (!shell.isDisposed()) { >++ if (!display.readAndDispatch()) >++ display.sleep(); >++ } >++ } >++*/ >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/CombinedOrientationExample.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CombinedOrientationExample.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CombinedOrientationExample.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CombinedOrientationExample.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,202 @@ >++package org.eclipse.swt.examples.mirroringTest; >++ >++import java.io.IOException; >++import java.io.InputStream; >++import java.text.MessageFormat; >++import java.util.MissingResourceException; >++import java.util.ResourceBundle; >++ >++import org.eclipse.swt.SWT; >++import org.eclipse.swt.events.SelectionAdapter; >++import org.eclipse.swt.events.SelectionEvent; >++import org.eclipse.swt.events.SelectionListener; >++import org.eclipse.swt.graphics.Image; >++import org.eclipse.swt.graphics.ImageData; >++import org.eclipse.swt.graphics.Point; >++import org.eclipse.swt.graphics.Rectangle; >++import org.eclipse.swt.layout.FormAttachment; >++import org.eclipse.swt.layout.FormData; >++import org.eclipse.swt.layout.FormLayout; >++import org.eclipse.swt.layout.RowLayout; >++import org.eclipse.swt.widgets.Button; >++import org.eclipse.swt.widgets.Composite; >++import org.eclipse.swt.widgets.Display; >++import org.eclipse.swt.widgets.Shell; >++import org.eclipse.swt.widgets.TabFolder; >++import org.eclipse.swt.widgets.TabItem; >++import java.util.HashMap; >++import java.util.Iterator; >++import java.util.Vector; >++ >++public class CombinedOrientationExample { >++ >++ protected static ResourceBundle resourceBundle = >++ ResourceBundle.getBundle("examples_control"); //$NON-NLS-1$ >++ protected CombinedBasic combineBasic; >++ Image images[]; >++ Shell shell; >++ >++ static final int ciClosedFolder = 0, ciOpenFolder = 1, ciTarget = 2, ciBackground = 3, ciParentBackground = 4; >++ static final String[] imageLocations = { >++ "/org/eclipse/swt/examples/controlexample/closedFolder.gif", //$NON-NLS-1$ >++ "/org/eclipse/swt/examples/controlexample/openFolder.gif", //$NON-NLS-1$ >++ "/org/eclipse/swt/examples/controlexample/target.gif", //$NON-NLS-1$ >++ "/org/eclipse/swt/examples/controlexample/backgroundImage.png", //$NON-NLS-1$ >++ "/org/eclipse/swt/examples/controlexample/parentBackgroundImage.png"}; //$NON-NLS-1$ >++ static final int[] imageTypes = { >++ SWT.ICON, >++ SWT.ICON, >++ SWT.ICON, >++ SWT.BITMAP, >++ SWT.BITMAP}; >++ boolean startup = true; >++ /** >++ * Creates an instance of a ControlExample embedded inside >++ * the supplied parent Composite. >++ * >++ * @param parent the container of the example >++ */ >++ public CombinedOrientationExample(Shell parent) { >++ initResources(); >++ this.shell = parent; >++ combineBasic = new CombinedBasic(parent, SWT.LEFT_TO_RIGHT, this); >++ startup = false; >++ } >++ /** >++ * Loads the resources >++ */ >++ void initResources() { >++ final Class clazz = ControlExample.class; >++ if (resourceBundle != null) { >++ try { >++ if (images == null) { >++ images = new Image[imageLocations.length]; >++ >++ for (int i = 0; i < imageLocations.length; ++i) { >++ InputStream sourceStream = clazz.getResourceAsStream(imageLocations[i]); >++ ImageData source = new ImageData(sourceStream); >++ if (imageTypes[i] == SWT.ICON) { >++ ImageData mask = source.getTransparencyMask(); >++ images[i] = new Image(null, source, mask); >++ } else { >++ images[i] = new Image(null, source); >++ } >++ try { >++ sourceStream.close(); >++ } catch (IOException e) { >++ e.printStackTrace(); >++ } >++ } >++ } >++ return; >++ } catch (Throwable t) { >++ } >++ } >++ String error = (resourceBundle != null) ? >++ getResourceString("error.CouldNotLoadResources") : >++ "Unable to load resources"; //$NON-NLS-1$ >++ freeResources(); >++ throw new RuntimeException(error); >++ } >++ /** >++ * Gets a string from the resource bundle. >++ * We don't want to crash because of a missing String. >++ * Returns the key if not found. >++ */ >++ static String getResourceString(String key) { >++ try { >++ return resourceBundle.getString(key)+"..."; >++ } catch (MissingResourceException e) { >++ return key; >++ } catch (NullPointerException e) { >++ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ >++ } >++ } >++ >++ /** >++ * Gets a string from the resource bundle and binds it >++ * with the given arguments. If the key is not found, >++ * return the key. >++ */ >++ static String getResourceString(String key, Object[] args) { >++ try { >++ return MessageFormat.format(getResourceString(key), args); >++ } catch (MissingResourceException e) { >++ return key; >++ } catch (NullPointerException e) { >++ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ >++ } >++ } >++ /** >++ * Disposes of all resources associated with a particular >++ * instance of the ControlExample. >++ */ >++ public void dispose() { >++ /* >++ * Destroy any shells that may have been created >++ * by the Shells tab. When a shell is disposed, >++ * all child shells are also disposed. Therefore >++ * it is necessary to check for disposed shells >++ * in the shells list to avoid disposing a shell >++ * twice. >++ */ >++// tabFolder = null; >++ freeResources(); >++ } >++ >++ /** >++ * Frees the resources >++ */ >++ void freeResources() { >++ if (images != null) { >++ for (int i = 0; i < images.length; ++i) { >++ final Image image = images[i]; >++ if (image != null) image.dispose(); >++ } >++ images = null; >++ } >++ } >++ /** >++ * @param args >++ */ >++ public static void main(String[] args) { >++ Display display = new Display(); >++ final Shell shell = new Shell(display, SWT.SHELL_TRIM); >++ shell.setLayout(new RowLayout()); >++ //CombinedBasic instance = new CombinedBasic(shell, 0, this); >++ CombinedOrientationExample instance = new CombinedOrientationExample(shell); >++ >++ final Button buttonRtl = new Button(shell, SWT.PUSH); >++ buttonRtl.setText("Shell RTL"); >++ final Button buttonLtr = new Button(shell, SWT.PUSH); >++ buttonLtr.setText("Shell LTR"); >++ >++ /* Add the listeners */ >++ SelectionListener setOrientationListener = new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent event) { >++ int flag = event.widget == buttonRtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >++ shell.setOrientation(flag); >++ } >++ }; >++ buttonRtl.addSelectionListener(setOrientationListener); >++ buttonLtr.addSelectionListener(setOrientationListener); >++ shell.setText(getResourceString("window.title")); >++ setShellSize(instance, shell); >++ shell.open(); >++ while (! shell.isDisposed()) { >++ if (! display.readAndDispatch()) display.sleep(); >++ } >++ instance.dispose(); >++ display.dispose(); >++ } >++ /** >++ * Sets the size of the shell to it's "packed" size, >++ * unless that makes it larger than the monitor it is being displayed on, >++ * in which case just set the shell size to be slightly smaller than the monitor. >++ */ >++ static void setShellSize(CombinedOrientationExample instance, Shell shell) { >++ Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); >++ Rectangle monitorArea = shell.getMonitor().getClientArea(); >++ shell.setSize(Math.min(size.x, monitorArea.width), Math.min(size.y, monitorArea.height)); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ComboTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ComboTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ComboTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ComboTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,148 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.events.*; >++import org.eclipse.swt.layout.*; >++ >++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 = {ControlExample.getResourceString("ListData0_0"), >++ ControlExample.getResourceString("ListData0_1"), >++ ControlExample.getResourceString("ListData0_2"), >++ ControlExample.getResourceString("ListData0_3"), >++ ControlExample.getResourceString("ListData0_4"), >++ ControlExample.getResourceString("ListData0_5"), >++ ControlExample.getResourceString("ListData0_6"), >++ ControlExample.getResourceString("ListData0_7"), >++ ControlExample.getResourceString("ListData0_8")}; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ComboTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the combo box */ >++ comboGroup = new Group (exampleGroup, SWT.NONE); >++ comboGroup.setLayout (new GridLayout ()); >++ comboGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ comboGroup.setText ("Combo"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (dropDownButton.getSelection ()) style |= SWT.DROP_DOWN; >++ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >++ if (simpleButton.getSelection ()) style |= SWT.SIMPLE; >++ >++ /* Create the example widgets */ >++ combo1 = new Combo (comboGroup, style); >++ combo1.setItems (ListData); >++ if (ListData.length >= 3) { >++ combo1.setText(ListData [2]); >++ } >++ } >++ >++ /** >++ * Creates the tab folder page. >++ * >++ * @param tabFolder org.eclipse.swt.widgets.TabFolder >++ * @return the new page for the tab folder >++ */ >++ Composite createTabFolderPage (TabFolder tabFolder) { >++ super.createTabFolderPage (tabFolder); >++ >++ /* >++ * Add a resize listener to the tabFolderPage so that >++ * if the user types into the example widget to change >++ * its preferred size, and then resizes the shell, we >++ * recalculate the preferred size correctly. >++ */ >++ tabFolderPage.addControlListener(new ControlAdapter() { >++ public void controlResized(ControlEvent e) { >++ setExampleWidgetSize (); >++ } >++ }); >++ >++ return tabFolderPage; >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup () { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ dropDownButton = new Button (styleGroup, SWT.RADIO); >++ dropDownButton.setText ("SWT.DROP_DOWN"); >++ simpleButton = new Button (styleGroup, SWT.RADIO); >++ simpleButton.setText("SWT.SIMPLE"); >++ readOnlyButton = new Button (styleGroup, SWT.CHECK); >++ readOnlyButton.setText ("SWT.READ_ONLY"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {combo1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Items", "Orientation", "Selection", "Text", "TextLimit", "ToolTipText", "VisibleItemCount"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "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); >++ readOnlyButton.setEnabled(!simpleButton.getSelection()); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ControlExample.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ControlExample.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ControlExample.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ControlExample.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,265 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.events.SelectionAdapter; >++import org.eclipse.swt.events.SelectionEvent; >++import org.eclipse.swt.events.SelectionListener; >++import org.eclipse.swt.graphics.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.examples.controlexample.*; >++ >++import java.io.*; >++import java.text.*; >++import java.util.*; >++ >++public class ControlExample { >++ protected static ResourceBundle resourceBundle = >++ ResourceBundle.getBundle("examples_control"); //$NON-NLS-1$ >++ protected ShellTab shellTab; >++ protected TabFolder tabFolder; >++ protected Tab [] tabs; >++ Image images[]; >++ >++ static final int ciClosedFolder = 0, ciOpenFolder = 1, ciTarget = 2, ciBackground = 3, ciParentBackground = 4; >++ static final String[] imageLocations = { >++ "/org/eclipse/swt/examples/controlexample/closedFolder.gif", //$NON-NLS-1$ >++ "/org/eclipse/swt/examples/controlexample/openFolder.gif", //$NON-NLS-1$ >++ "/org/eclipse/swt/examples/controlexample/target.gif", //$NON-NLS-1$ >++ "/org/eclipse/swt/examples/controlexample/backgroundImage.png", //$NON-NLS-1$ >++ "/org/eclipse/swt/examples/controlexample/parentBackgroundImage.png"}; //$NON-NLS-1$ >++ static final int[] imageTypes = { >++ SWT.ICON, >++ SWT.ICON, >++ SWT.ICON, >++ SWT.BITMAP, >++ SWT.BITMAP}; >++ >++ boolean startup = true; >++ >++ /** >++ * Creates an instance of a ControlExample embedded inside >++ * the supplied parent Composite. >++ * >++ * @param parent the container of the example >++ */ >++ public ControlExample(Composite parent) { >++ initResources(); >++ tabFolder = new TabFolder (parent, SWT.NONE); >++ tabs = createTabs(); >++ for (int i=0; i<tabs.length; i++) { >++ TabItem item = new TabItem (tabFolder, SWT.NONE); >++ item.setText (tabs [i].getTabText ()); >++ item.setControl (tabs [i].createTabFolderPage (tabFolder)); >++ item.setData (tabs [i]); >++ } >++ >++ /* Workaround: if the tab folder is wider than the screen, >++ * Mac platforms clip instead of somehow scrolling the tab items. >++ * We try to recover some width by using shorter tab names. */ >++ Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT); >++ Rectangle monitorArea = parent.getMonitor().getClientArea(); >++ boolean isMac = SWT.getPlatform().equals("carbon") || SWT.getPlatform().equals("cocoa"); >++ if (size.x > monitorArea.width && isMac) { >++ TabItem [] tabItems = tabFolder.getItems(); >++ for (int i=0; i<tabItems.length; i++) { >++ tabItems[i].setText (tabs [i].getShortTabText ()); >++ } >++ } >++ startup = false; >++ } >++ >++ /** >++ * Answers the set of example Tabs >++ */ >++ Tab[] createTabs() { >++ return new Tab [] { >++ new ButtonTab (this), >++ new CanvasTab (this), >++ new ComboTab (this), >++ new CoolBarTab (this), >++ new DateTimeTab (this), >++ new DialogTab (this), >++ new ExpandBarTab (this), >++ new GroupTab (this), >++ new LabelTab (this), >++ new LinkTab (this), >++ new ListTab (this), >++ new MenuTab (this), >++ new ProgressBarTab (this), >++ new SashTab (this), >++ new ScaleTab (this), >++ shellTab = new ShellTab(this), >++ new SliderTab (this), >++ new SpinnerTab (this), >++ new TabFolderTab (this), >++ new TableTab (this), >++ new TextTab (this), >++ new ToolBarTab (this), >++ new ToolTipTab (this), >++ new TreeTab (this), >++ new BrowserTab (this), >++ }; >++ } >++ >++ /** >++ * Disposes of all resources associated with a particular >++ * instance of the ControlExample. >++ */ >++ public void dispose() { >++ /* >++ * Destroy any shells that may have been created >++ * by the Shells tab. When a shell is disposed, >++ * all child shells are also disposed. Therefore >++ * it is necessary to check for disposed shells >++ * in the shells list to avoid disposing a shell >++ * twice. >++ */ >++ if (shellTab != null) shellTab.closeAllShells (); >++ shellTab = null; >++ tabFolder = null; >++ freeResources(); >++ } >++ >++ /** >++ * Frees the resources >++ */ >++ void freeResources() { >++ if (images != null) { >++ for (int i = 0; i < images.length; ++i) { >++ final Image image = images[i]; >++ if (image != null) image.dispose(); >++ } >++ images = null; >++ } >++ } >++ >++ /** >++ * Gets a string from the resource bundle. >++ * We don't want to crash because of a missing String. >++ * Returns the key if not found. >++ */ >++ static String getResourceString(String key) { >++ try { >++ return resourceBundle.getString(key)+"..."; >++ } catch (MissingResourceException e) { >++ return key; >++ } catch (NullPointerException e) { >++ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ >++ } >++ } >++ >++ /** >++ * Gets a string from the resource bundle and binds it >++ * with the given arguments. If the key is not found, >++ * return the key. >++ */ >++ static String getResourceString(String key, Object[] args) { >++ try { >++ return MessageFormat.format(getResourceString(key), args); >++ } catch (MissingResourceException e) { >++ return key; >++ } catch (NullPointerException e) { >++ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ >++ } >++ } >++ >++ /** >++ * Loads the resources >++ */ >++ void initResources() { >++ final Class clazz = ControlExample.class; >++ if (resourceBundle != null) { >++ try { >++ if (images == null) { >++ images = new Image[imageLocations.length]; >++ >++ for (int i = 0; i < imageLocations.length; ++i) { >++ InputStream sourceStream = clazz.getResourceAsStream(imageLocations[i]); >++ ImageData source = new ImageData(sourceStream); >++ if (imageTypes[i] == SWT.ICON) { >++ ImageData mask = source.getTransparencyMask(); >++ images[i] = new Image(null, source, mask); >++ } else { >++ images[i] = new Image(null, source); >++ } >++ try { >++ sourceStream.close(); >++ } catch (IOException e) { >++ e.printStackTrace(); >++ } >++ } >++ } >++ return; >++ } catch (Throwable t) { >++ } >++ } >++ String error = (resourceBundle != null) ? >++ getResourceString("error.CouldNotLoadResources") : >++ "Unable to load resources"; //$NON-NLS-1$ >++ freeResources(); >++ throw new RuntimeException(error); >++ } >++ >++ /** >++ * Invokes as a standalone program. >++ */ >++ public static void main(String[] args) { >++ Display display = new Display(); >++ final Shell shell = new Shell(display, SWT.SHELL_TRIM); >++ shell.setLayout(new RowLayout()); >++ ControlExample instance = new ControlExample(shell); >++ final Button buttonRtl = new Button(shell, SWT.PUSH); >++ buttonRtl.setText("Shell RTL"); >++ final Button buttonLtr = new Button(shell, SWT.PUSH); >++ buttonLtr.setText("Shell LTR"); >++ >++ /* Add the listeners */ >++ SelectionListener setOrientationListener = new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent event) { >++ int flag = event.widget == buttonRtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >++ shell.setOrientation(flag); >++ } >++ }; >++ buttonRtl.addSelectionListener(setOrientationListener); >++ buttonLtr.addSelectionListener(setOrientationListener); >++ shell.setText(getResourceString("window.title")); >++ setShellSize(instance, shell); >++ shell.open(); >++ while (! shell.isDisposed()) { >++ if (! display.readAndDispatch()) display.sleep(); >++ } >++ instance.dispose(); >++ display.dispose(); >++ } >++ >++ /** >++ * Grabs input focus. >++ */ >++ public void setFocus() { >++ tabFolder.setFocus(); >++ } >++ >++ /** >++ * Sets the size of the shell to it's "packed" size, >++ * unless that makes it larger than the monitor it is being displayed on, >++ * in which case just set the shell size to be slightly smaller than the monitor. >++ */ >++ static void setShellSize(ControlExample instance, Shell shell) { >++ Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); >++ Rectangle monitorArea = shell.getMonitor().getClientArea(); >++ shell.setSize(Math.min(size.x, monitorArea.width), Math.min(size.y, monitorArea.height)); >++ } >++} >++ >+Index: src/org/eclipse/swt/examples/mirroringTest/ControlExampleRTL.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ControlExampleRTL.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ControlExampleRTL.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ControlExampleRTL.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,79 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.events.SelectionAdapter; >++import org.eclipse.swt.events.SelectionEvent; >++import org.eclipse.swt.events.SelectionListener; >++import org.eclipse.swt.graphics.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++ >++import java.io.*; >++import java.text.*; >++import java.util.*; >++ >++public class ControlExampleRTL extends ControlExample{ >++ >++ /** >++ * Creates an instance of a ControlExample embedded inside >++ * the supplied parent Composite. >++ * >++ * @param parent the container of the example >++ */ >++ public ControlExampleRTL(Composite parent) { >++ super(parent); >++ >++ } >++ >++ >++ >++ /** >++ * Invokes as a standalone program. >++ */ >++ public static void main(String[] args) { >++ Display display = new Display(); >++ final Shell shell = new Shell(display, SWT.SHELL_TRIM); >++ shell.setOrientation(SWT.RIGHT_TO_LEFT); >++ shell.setLayout(new RowLayout()); >++ ControlExampleRTL instance = new ControlExampleRTL(shell); >++ >++ final Button buttonRtl = new Button(shell, SWT.PUSH); >++ buttonRtl.setText("Shell RTL"); >++ final Button buttonLtr = new Button(shell, SWT.PUSH); >++ buttonLtr.setText("Shell LTR"); >++ >++ /* Add the listeners */ >++ SelectionListener setOrientationListener = new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent event) { >++ int flag = event.widget == buttonRtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >++ shell.setOrientation(flag); >++ } >++ }; >++ buttonRtl.addSelectionListener(setOrientationListener); >++ buttonLtr.addSelectionListener(setOrientationListener); >++ >++ shell.setText(getResourceString("window.title")); >++ setShellSize(instance, shell); >++ shell.open(); >++ >++ while (! shell.isDisposed()) { >++ if (! display.readAndDispatch()) display.sleep(); >++ } >++ instance.dispose(); >++ display.dispose(); >++ } >++ >++ >++} >++ >+Index: src/org/eclipse/swt/examples/mirroringTest/CoolBarTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CoolBarTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CoolBarTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CoolBarTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,491 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++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 CoolBarTab extends Tab { >++ /* Example widgets and group that contains them */ >++ CoolBar coolBar; >++ CoolItem pushItem, dropDownItem, radioItem, checkItem, textItem; >++ Group coolBarGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button horizontalButton, verticalButton; >++ Button dropDownButton, flatButton; >++ >++ /* Other widgets added to the "Other" group */ >++ Button lockedButton; >++ >++ Point[] sizes; >++ int[] wrapIndices; >++ int[] order; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ CoolBarTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Other" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ >++ /* Create display controls specific to this example */ >++ lockedButton = new Button (otherGroup, SWT.CHECK); >++ lockedButton.setText (ControlExample.getResourceString("Locked")); >++ >++ /* Add the listeners */ >++ lockedButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetLocked (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ coolBarGroup = new Group (exampleGroup, SWT.NONE); >++ coolBarGroup.setLayout (new GridLayout ()); >++ coolBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ coolBarGroup.setText ("CoolBar"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ int style = getDefaultStyle(), itemStyle = 0; >++ >++ /* Compute the widget, item, and item toolBar styles */ >++ int toolBarStyle = SWT.FLAT; >++ boolean vertical = false; >++ if (horizontalButton.getSelection ()) { >++ style |= SWT.HORIZONTAL; >++ toolBarStyle |= SWT.HORIZONTAL; >++ } >++ if (verticalButton.getSelection ()) { >++ style |= SWT.VERTICAL; >++ toolBarStyle |= SWT.VERTICAL; >++ vertical = true; >++ } >++ if (borderButton.getSelection()) style |= SWT.BORDER; >++ if (flatButton.getSelection()) style |= SWT.FLAT; >++ if (dropDownButton.getSelection()) itemStyle |= SWT.DROP_DOWN; >++ >++ /* >++ * Create the example widgets. >++ */ >++ coolBar = new CoolBar (coolBarGroup, style); >++ >++ /* Create the push button toolbar cool item */ >++ ToolBar toolBar = new ToolBar (coolBar, toolBarStyle); >++ ToolItem item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[ControlExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[ControlExample.ciTarget]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (toolBar, SWT.SEPARATOR); >++ item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (toolBar, SWT.PUSH); >++ item.setImage (instance.images[ControlExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ pushItem = new CoolItem (coolBar, itemStyle); >++ pushItem.setControl (toolBar); >++ pushItem.addSelectionListener (new CoolItemSelectionListener()); >++ >++ /* Create the dropdown toolbar cool item */ >++ toolBar = new ToolBar (coolBar, toolBarStyle); >++ item = new ToolItem (toolBar, SWT.DROP_DOWN); >++ item.setImage (instance.images[ControlExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.DROP_DOWN"); >++ item.addSelectionListener (new DropDownSelectionListener()); >++ item = new ToolItem (toolBar, SWT.DROP_DOWN); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.DROP_DOWN"); >++ item.addSelectionListener (new DropDownSelectionListener()); >++ dropDownItem = new CoolItem (coolBar, itemStyle); >++ dropDownItem.setControl (toolBar); >++ dropDownItem.addSelectionListener (new CoolItemSelectionListener()); >++ >++ /* Create the radio button toolbar cool item */ >++ toolBar = new ToolBar (coolBar, toolBarStyle); >++ item = new ToolItem (toolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ item = new ToolItem (toolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ item = new ToolItem (toolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ radioItem = new CoolItem (coolBar, itemStyle); >++ radioItem.setControl (toolBar); >++ radioItem.addSelectionListener (new CoolItemSelectionListener()); >++ >++ /* Create the check button toolbar cool item */ >++ toolBar = new ToolBar (coolBar, toolBarStyle); >++ item = new ToolItem (toolBar, SWT.CHECK); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.CHECK"); >++ item = new ToolItem (toolBar, SWT.CHECK); >++ item.setImage (instance.images[ControlExample.ciTarget]); >++ item.setToolTipText ("SWT.CHECK"); >++ item = new ToolItem (toolBar, SWT.CHECK); >++ item.setImage (instance.images[ControlExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.CHECK"); >++ item = new ToolItem (toolBar, SWT.CHECK); >++ item.setImage (instance.images[ControlExample.ciTarget]); >++ item.setToolTipText ("SWT.CHECK"); >++ checkItem = new CoolItem (coolBar, itemStyle); >++ checkItem.setControl (toolBar); >++ checkItem.addSelectionListener (new CoolItemSelectionListener()); >++ >++ /* Create the text cool item */ >++ if (!vertical) { >++ Text text = new Text (coolBar, SWT.BORDER | SWT.SINGLE); >++ textItem = new CoolItem (coolBar, itemStyle); >++ textItem.setControl (text); >++ textItem.addSelectionListener (new CoolItemSelectionListener()); >++ Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); >++ textSize = textItem.computeSize(textSize.x, textSize.y); >++ textItem.setMinimumSize(textSize); >++ textItem.setPreferredSize(textSize); >++ textItem.setSize(textSize); >++ } >++ >++ /* Set the sizes after adding all cool items */ >++ CoolItem[] coolItems = coolBar.getItems(); >++ for (int i = 0; i < coolItems.length; i++) { >++ CoolItem coolItem = coolItems[i]; >++ Control control = coolItem.getControl(); >++ Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); >++ Point coolSize = coolItem.computeSize(size.x, size.y); >++ if (control instanceof ToolBar) { >++ ToolBar bar = (ToolBar)control; >++ if (bar.getItemCount() > 0) { >++ if (vertical) { >++ size.y = bar.getItem(0).getBounds().height; >++ } else { >++ size.x = bar.getItem(0).getWidth(); >++ } >++ } >++ } >++ coolItem.setMinimumSize(size); >++ coolItem.setPreferredSize(coolSize); >++ coolItem.setSize(coolSize); >++ } >++ >++ /* If we have saved state, restore it */ >++ if (order != null && order.length == coolBar.getItemCount()) { >++ coolBar.setItemLayout(order, wrapIndices, sizes); >++ } else { >++ coolBar.setWrapIndices(new int[] {1, 3}); >++ } >++ >++ /* Add a listener to resize the group box to match the coolbar */ >++ coolBar.addListener(SWT.Resize, new Listener() { >++ public void handleEvent(Event event) { >++ exampleGroup.layout(); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup(); >++ >++ /* Create the extra widgets */ >++ horizontalButton = new Button (styleGroup, SWT.RADIO); >++ horizontalButton.setText ("SWT.HORIZONTAL"); >++ verticalButton = new Button (styleGroup, SWT.RADIO); >++ verticalButton.setText ("SWT.VERTICAL"); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ flatButton = new Button (styleGroup, SWT.CHECK); >++ flatButton.setText ("SWT.FLAT"); >++ Group itemGroup = new Group(styleGroup, SWT.NONE); >++ itemGroup.setLayout (new GridLayout ()); >++ itemGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ itemGroup.setText(ControlExample.getResourceString("Item_Styles")); >++ dropDownButton = new Button (itemGroup, SWT.CHECK); >++ dropDownButton.setText ("SWT.DROP_DOWN"); >++ } >++ >++ /** >++ * Disposes the "Example" widgets. >++ */ >++ void disposeExampleWidgets () { >++ /* store the state of the toolbar if applicable */ >++ if (coolBar != null) { >++ sizes = coolBar.getItemSizes(); >++ wrapIndices = coolBar.getWrapIndices(); >++ order = coolBar.getItemOrder(); >++ } >++ super.disposeExampleWidgets(); >++ } >++ >++ /** >++ * Gets the "Example" widget children's items, if any. >++ * >++ * @return an array containing the example widget children's items >++ */ >++ Item [] getExampleWidgetItems () { >++ return coolBar.getItems(); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {coolBar}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"ToolTipText"}; >++ } >++ >++ /** >++ * Gets the short text for the tab folder item. >++ */ >++ String getShortTabText() { >++ return "CB"; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "CoolBar"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ horizontalButton.setSelection ((coolBar.getStyle () & SWT.HORIZONTAL) != 0); >++ verticalButton.setSelection ((coolBar.getStyle () & SWT.VERTICAL) != 0); >++ borderButton.setSelection ((coolBar.getStyle () & SWT.BORDER) != 0); >++ flatButton.setSelection ((coolBar.getStyle () & SWT.FLAT) != 0); >++ dropDownButton.setSelection ((coolBar.getItem(0).getStyle () & SWT.DROP_DOWN) != 0); >++ lockedButton.setSelection(coolBar.getLocked()); >++ if (!instance.startup) setWidgetLocked (); >++ } >++ >++ /** >++ * Sets the header visible state of the "Example" widgets. >++ */ >++ void setWidgetLocked () { >++ coolBar.setLocked (lockedButton.getSelection ()); >++ } >++ >++ /** >++ * Listens to widgetSelected() events on SWT.DROP_DOWN type ToolItems >++ * and opens/closes a menu when appropriate. >++ */ >++ class DropDownSelectionListener extends SelectionAdapter { >++ private Menu menu = null; >++ private boolean visible = false; >++ >++ public void widgetSelected(SelectionEvent event) { >++ // Create the menu if it has not already been created >++ if (menu == null) { >++ // Lazy create the menu. >++ menu = new Menu(shell, SWT.POP_UP | (coolBar.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT))); >++ menu.addMenuListener(new MenuAdapter() { >++ public void menuHidden(MenuEvent e) { >++ visible = false; >++ } >++ }); >++ for (int i = 0; i < 9; ++i) { >++ final String text = ControlExample.getResourceString("DropDownData_" + i); >++ if (text.length() != 0) { >++ MenuItem menuItem = new MenuItem(menu, SWT.NONE); >++ menuItem.setText(text); >++ /* >++ * Add a menu selection listener so that the menu is hidden >++ * when the user selects an item from the drop down menu. >++ */ >++ menuItem.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ setMenuVisible(false); >++ } >++ }); >++ } else { >++ new MenuItem(menu, SWT.SEPARATOR); >++ } >++ } >++ } >++ >++ /** >++ * 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. >++ */ >++ if (visible) { >++ // Hide the menu to give the Arrow the appearance of being a toggle button. >++ setMenuVisible(false); >++ } else { >++ // Position the menu below and vertically aligned with the the drop down tool button. >++ final ToolItem toolItem = (ToolItem) event.widget; >++ final ToolBar toolBar = toolItem.getParent(); >++ >++ Rectangle toolItemBounds = toolItem.getBounds(); >++ Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y)); >++ menu.setLocation(point.x, point.y + toolItemBounds.height); >++ setMenuVisible(true); >++ } >++ } else { >++ /* >++ * Main area of drop down tool item selected. >++ * An application would invoke the code to perform the action for the tool item. >++ */ >++ } >++ } >++ private void setMenuVisible(boolean visible) { >++ menu.setVisible(visible); >++ menu.setOrientation(menu.getParent().getOrientation()); >++ this.visible = visible; >++ } >++ } >++ >++ /** >++ * Listens to widgetSelected() events on SWT.DROP_DOWN type CoolItems >++ * and opens/closes a menu when appropriate. >++ */ >++ class CoolItemSelectionListener extends SelectionAdapter { >++ private Menu menu = null; >++ >++ public void widgetSelected(SelectionEvent event) { >++ /** >++ * A selection event will be fired when the cool item >++ * is selected by its gripper or if the drop down arrow >++ * (or 'chevron') is selected. Examine the event detail >++ * to determine where the widget was selected. >++ */ >++ if (event.detail == SWT.ARROW) { >++ /* If the popup menu is already up (i.e. user pressed arrow twice), >++ * then dispose it. >++ */ >++ if (menu != null) { >++ menu.dispose(); >++ menu = null; >++ return; >++ } >++ >++ /* Get the cool item and convert its bounds to display coordinates. */ >++ CoolItem coolItem = (CoolItem) event.widget; >++ Rectangle itemBounds = coolItem.getBounds (); >++ itemBounds.width = event.x - itemBounds.x; >++ Point pt = coolBar.toDisplay(new Point (itemBounds.x, itemBounds.y)); >++ itemBounds.x = pt.x; >++ itemBounds.y = pt.y; >++ >++ /* Get the toolbar from the cool item. */ >++ ToolBar toolBar = (ToolBar) coolItem.getControl (); >++ ToolItem[] tools = toolBar.getItems (); >++ int toolCount = tools.length; >++ >++ /* Convert the bounds of each tool item to display coordinates, >++ * and determine which ones are past the bounds of the cool item. >++ */ >++ int i = 0; >++ while (i < toolCount) { >++ Rectangle toolBounds = tools[i].getBounds (); >++ pt = toolBar.toDisplay(new Point(toolBounds.x, toolBounds.y)); >++ toolBounds.x = pt.x; >++ toolBounds.y = pt.y; >++ Rectangle intersection = itemBounds.intersection (toolBounds); >++ if (!intersection.equals (toolBounds)) break; >++ i++; >++ } >++ >++ /* Create a pop-up menu with items for each of the hidden buttons. */ >++ menu = new Menu (shell, SWT.POP_UP | (coolBar.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT))); >++ for (int j = i; j < toolCount; j++) { >++ ToolItem tool = tools[j]; >++ Image image = tool.getImage(); >++ if (image == null) { >++ new MenuItem (menu, SWT.SEPARATOR); >++ } else { >++ if ((tool.getStyle() & SWT.DROP_DOWN) != 0) { >++ MenuItem menuItem = new MenuItem (menu, SWT.CASCADE); >++ menuItem.setImage(image); >++ String text = tool.getToolTipText(); >++ if (text != null) menuItem.setText(text); >++ Menu m = new Menu(menu); >++ menuItem.setMenu(m); >++ for (int k = 0; k < 9; ++k) { >++ text = ControlExample.getResourceString("DropDownData_" + k); >++ if (text.length() != 0) { >++ MenuItem mi = new MenuItem(m, SWT.NONE); >++ mi.setText(text); >++ /* Application code to perform the action for the submenu item would go here. */ >++ } else { >++ new MenuItem(m, SWT.SEPARATOR); >++ } >++ } >++ } else { >++ MenuItem menuItem = new MenuItem (menu, SWT.NONE); >++ menuItem.setImage(image); >++ String text = tool.getToolTipText(); >++ if (text != null) menuItem.setText(text); >++ } >++ /* Application code to perform the action for the menu item would go here. */ >++ } >++ } >++ >++ /* Display the pop-up menu at the lower left corner of the arrow button. >++ * Dispose the menu when the user is done with it. >++ */ >++ pt = coolBar.toDisplay(new Point(event.x, event.y)); >++ menu.setLocation (pt.x, pt.y); >++ menu.setVisible (true); >++ while (menu != null && !menu.isDisposed() && menu.isVisible ()) { >++ if (!display.readAndDispatch ()) display.sleep (); >++ } >++ if (menu != null) { >++ menu.dispose (); >++ menu = null; >++ } >++ } >++ } >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/CustomControlExample.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/CustomControlExample.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/CustomControlExample.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/CustomControlExample.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,58 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2006 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++ >++ >++public class CustomControlExample extends ControlExample { >++ >++ /** >++ * Creates an instance of a CustomControlExample embedded >++ * inside the supplied parent Composite. >++ * >++ * @param parent the container of the example >++ */ >++ public CustomControlExample(Composite parent) { >++ super (parent); >++ } >++ >++ /** >++ * Answers the set of example Tabs >++ */ >++ Tab[] createTabs() { >++ return new Tab [] { >++ new CComboTab (this), >++ new CLabelTab (this), >++ new CTabFolderTab (this), >++ new SashFormTab (this), >++ new StyledTextTab (this), >++ }; >++ } >++ >++ /** >++ * Invokes as a standalone program. >++ */ >++ public static void main(String[] args) { >++ Display display = new Display(); >++ Shell shell = new Shell(display); >++ shell.setLayout(new FillLayout()); >++ CustomControlExample instance = new CustomControlExample(shell); >++ shell.setText(getResourceString("custom.window.title")); >++ setShellSize(instance, shell); >++ shell.open(); >++ while (! shell.isDisposed()) { >++ if (! display.readAndDispatch()) display.sleep(); >++ } >++ instance.dispose(); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/DateTimeTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/DateTimeTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/DateTimeTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/DateTimeTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,137 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++ >++class DateTimeTab extends Tab { >++ /* Example widgets and groups that contain them */ >++ DateTime dateTime1; >++ Group dateTimeGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ //Button /*dateButton, timeButton, calendarButton, shortButton, mediumButton, longButton, dropDownButton*/; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ DateTimeTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the list */ >++ dateTimeGroup = new Group (exampleGroup, SWT.NONE); >++ dateTimeGroup.setLayout (new GridLayout ()); >++ dateTimeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ dateTimeGroup.setText ("Calendar");//("DateTime"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ /* if (dateButton.getSelection ()) style |= SWT.DATE; >++ if (timeButton.getSelection ()) style |= SWT.TIME; >++ if (calendarButton.getSelection ()) style |= SWT.CALENDAR; >++*/ style |= SWT.CALENDAR; >++/* if (shortButton.getSelection ()) style |= SWT.SHORT; >++ if (mediumButton.getSelection ()) style |= SWT.MEDIUM; >++ if (longButton.getSelection ()) style |= SWT.LONG; >++ if (dropDownButton.getSelection ()) style |= SWT.DROP_DOWN; >++ */ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ >++ /* Create the example widgets */ >++ dateTime1 = new DateTime (dateTimeGroup, style); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++/* dateButton = new Button(styleGroup, SWT.RADIO); >++ dateButton.setText("SWT.DATE"); >++ timeButton = new Button(styleGroup, SWT.RADIO); >++ timeButton.setText("SWT.TIME"); >++ calendarButton = new Button(styleGroup, SWT.RADIO); >++ calendarButton.setText("SWT.CALENDAR"); >++ Group formatGroup = new Group(styleGroup, SWT.NONE); >++ formatGroup.setLayout(new GridLayout()); >++ shortButton = new Button(formatGroup, SWT.RADIO); >++ shortButton.setText("SWT.SHORT"); >++ mediumButton = new Button(formatGroup, SWT.RADIO); >++ mediumButton.setText("SWT.MEDIUM"); >++ longButton = new Button(formatGroup, SWT.RADIO); >++ longButton.setText("SWT.LONG"); >++ dropDownButton = new Button(styleGroup, SWT.CHECK); >++ dropDownButton.setText("SWT.DROP_DOWN"); >++*/ borderButton = new Button(styleGroup, SWT.CHECK); >++ borderButton.setText("SWT.BORDER"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {dateTime1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Day", "Hours", "Minutes", "Month", "Seconds", "Year"}; >++ } >++ >++ /** >++ * Gets the short text for the tab folder item. >++ */ >++ String getShortTabText() { >++ return "DT"; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "DateTime"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++/* dateButton.setSelection ((dateTime1.getStyle () & SWT.DATE) != 0); >++ timeButton.setSelection ((dateTime1.getStyle () & SWT.TIME) != 0); >++ calendarButton.setSelection ((dateTime1.getStyle () & SWT.CALENDAR) != 0); >++ shortButton.setSelection ((dateTime1.getStyle () & SWT.SHORT) != 0); >++ mediumButton.setSelection ((dateTime1.getStyle () & SWT.MEDIUM) != 0); >++ longButton.setSelection ((dateTime1.getStyle () & SWT.LONG) != 0); >++ dropDownButton.setSelection ((dateTime1.getStyle () & SWT.DROP_DOWN) != 0); >++*/ borderButton.setSelection ((dateTime1.getStyle () & SWT.BORDER) != 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/DialogTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/DialogTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/DialogTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/DialogTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,521 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.graphics.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.printing.*; >++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 createButton; >++ Button okButton, cancelButton; >++ Button yesButton, noButton; >++ Button retryButton; >++ Button abortButton, ignoreButton; >++ Button iconErrorButton, iconInformationButton, iconQuestionButton; >++ Button iconWarningButton, iconWorkingButton, noIconButton; >++ Button primaryModalButton, applicationModalButton, systemModalButton; >++ Button sheetButton; >++ Button saveButton, openButton, multiButton; >++ >++ static String [] FilterExtensions = {"*.txt", "*.bat", "*.doc", "*"}; >++ static String [] FilterNames = {ControlExample.getResourceString("FilterName_0"), >++ ControlExample.getResourceString("FilterName_1"), >++ ControlExample.getResourceString("FilterName_2"), >++ ControlExample.getResourceString("FilterName_3")}; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ DialogTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * 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. >++ */ >++ boolean ok = okButton.getSelection (); >++ boolean cancel = cancelButton.getSelection (); >++ boolean yes = yesButton.getSelection (); >++ boolean no = noButton.getSelection (); >++ boolean abort = abortButton.getSelection (); >++ boolean retry = retryButton.getSelection (); >++ boolean ignore = ignoreButton.getSelection (); >++ >++ okButton.setEnabled (!(yes || no || retry || abort || ignore)); >++ cancelButton.setEnabled (!(abort || ignore || (yes != no))); >++ yesButton.setEnabled (!(ok || retry || abort || ignore || (cancel && !yes && !no))); >++ noButton.setEnabled (!(ok || retry || abort || ignore || (cancel && !yes && !no))); >++ retryButton.setEnabled (!(ok || yes || no)); >++ abortButton.setEnabled (!(ok || cancel || yes || no)); >++ ignoreButton.setEnabled (!(ok || cancel || yes || no)); >++ >++ createButton.setEnabled ( >++ !(ok || cancel || yes || no || retry || abort || ignore) || >++ ok || >++ (ok && cancel) || >++ (yes && no) || >++ (yes && no && cancel) || >++ (retry && cancel) || >++ (abort && retry && ignore)); >++ >++ >++ } >++ >++ /** >++ * Handle the create button selection event. >++ * >++ * @param event org.eclipse.swt.events.SelectionEvent >++ */ >++ void createButtonSelected(SelectionEvent event) { >++ >++ /* Compute the appropriate dialog style */ >++ int style = getDefaultStyle(); >++ 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 (sheetButton.getSelection ()) style |= SWT.SHEET; >++ if (saveButton.getEnabled () && saveButton.getSelection ()) style |= SWT.SAVE; >++ if (openButton.getEnabled () && openButton.getSelection ()) style |= SWT.OPEN; >++ if (multiButton.getEnabled () && multiButton.getSelection ()) style |= SWT.MULTI; >++ >++ /* Open the appropriate dialog type */ >++ String name = dialogCombo.getText (); >++ >++ if (name.equals (ControlExample.getResourceString("ColorDialog"))) { >++ ColorDialog dialog = new ColorDialog (shell ,style); >++ dialog.setRGB (new RGB (100, 100, 100)); >++ dialog.setText (ControlExample.getResourceString("Title")); >++ RGB result = dialog.open (); >++ textWidget.append (ControlExample.getResourceString("ColorDialog") + Text.DELIMITER); >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); >++ textWidget.append ("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER); >++ return; >++ } >++ >++ if (name.equals (ControlExample.getResourceString("DirectoryDialog"))) { >++ DirectoryDialog dialog = new DirectoryDialog (shell, style); >++ dialog.setMessage (ControlExample.getResourceString("Example_string")); >++ dialog.setText (ControlExample.getResourceString("Title")); >++ String result = dialog.open (); >++ textWidget.append (ControlExample.getResourceString("DirectoryDialog") + Text.DELIMITER); >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER + Text.DELIMITER); >++ return; >++ } >++ >++ if (name.equals (ControlExample.getResourceString("FileDialog"))) { >++ FileDialog dialog = new FileDialog (shell, style); >++ dialog.setFileName (ControlExample.getResourceString("readme_txt")); >++ dialog.setFilterNames (FilterNames); >++ dialog.setFilterExtensions (FilterExtensions); >++ dialog.setText (ControlExample.getResourceString("Title")); >++ String result = dialog.open(); >++ textWidget.append (ControlExample.getResourceString("FileDialog") + Text.DELIMITER); >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); >++ textWidget.append ("getFilterPath() =" + dialog.getFilterPath() + Text.DELIMITER); >++ textWidget.append ("getFileName() =" + dialog.getFileName() + Text.DELIMITER); >++ textWidget.append ("getFileNames() =" + Text.DELIMITER); >++ String [] files = dialog.getFileNames (); >++ for (int i=0; i<files.length; i++) { >++ textWidget.append ("\t" + files [i] + Text.DELIMITER); >++ } >++ textWidget.append ("getFilterIndex() = " + dialog.getFilterIndex() + Text.DELIMITER + Text.DELIMITER); >++ return; >++ } >++ >++ if (name.equals (ControlExample.getResourceString("FontDialog"))) { >++ FontDialog dialog = new FontDialog (shell, style); >++ dialog.setText (ControlExample.getResourceString("Title")); >++ FontData result = dialog.open (); >++ textWidget.append (ControlExample.getResourceString("FontDialog") + Text.DELIMITER); >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); >++ textWidget.append ("getFontList() =" + Text.DELIMITER); >++ FontData [] fonts = dialog.getFontList (); >++ if (fonts != null) { >++ for (int i=0; i<fonts.length; i++) { >++ textWidget.append ("\t" + fonts [i] + Text.DELIMITER); >++ } >++ } >++ textWidget.append ("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER); >++ return; >++ } >++ >++ if (name.equals (ControlExample.getResourceString("PrintDialog"))) { >++ PrintDialog dialog = new PrintDialog (shell, style); >++ dialog.setText(ControlExample.getResourceString("Title")); >++ PrinterData result = dialog.open (); >++ textWidget.append (ControlExample.getResourceString("PrintDialog") + Text.DELIMITER); >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); >++ textWidget.append ("getScope() = " + dialog.getScope() + Text.DELIMITER); >++ textWidget.append ("getStartPage() = " + dialog.getStartPage() + Text.DELIMITER); >++ textWidget.append ("getEndPage() = " + dialog.getEndPage() + Text.DELIMITER); >++ textWidget.append ("getPrintToFile() = " + dialog.getPrintToFile() + Text.DELIMITER); >++ if (result != null) { >++ textWidget.append ("result.fileName = " + result.fileName + Text.DELIMITER); >++ textWidget.append ("result.orientation = " + (result.orientation == PrinterData.LANDSCAPE ? "PrinterData.LANDSCAPE" : "PrinterData.PORTRAIT") + Text.DELIMITER); >++ textWidget.append ("result.copyCount = " + result.copyCount + Text.DELIMITER); >++ textWidget.append ("result.collate = " + result.collate + Text.DELIMITER); >++ } >++ textWidget.append (Text.DELIMITER); >++ return; >++ } >++ >++ if (name.equals(ControlExample.getResourceString("MessageBox"))) { >++ MessageBox dialog = new MessageBox (shell, style); >++ dialog.setMessage (ControlExample.getResourceString("Example_string")); >++ dialog.setText (ControlExample.getResourceString("Title")); >++ int result = dialog.open (); >++ textWidget.append (ControlExample.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 (ControlExample.getResourceString("Result", new String [] {"SWT.OK"})); >++ break; >++ case SWT.YES: >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.YES"})); >++ break; >++ case SWT.NO: >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.NO"})); >++ break; >++ case SWT.CANCEL: >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.CANCEL"})); >++ break; >++ case SWT.ABORT: >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.ABORT"})); >++ break; >++ case SWT.RETRY: >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.RETRY"})); >++ break; >++ case SWT.IGNORE: >++ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.IGNORE"})); >++ break; >++ default: >++ textWidget.append(ControlExample.getResourceString("Result", new String [] {"" + result})); >++ break; >++ } >++ textWidget.append (Text.DELIMITER + Text.DELIMITER); >++ } >++ } >++ >++ /** >++ * Creates the "Control" group. >++ */ >++ void createControlGroup () { >++ /* >++ * Create the "Control" group. This is the group on the >++ * right 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 (ControlExample.getResourceString("Parameters")); >++ >++ /* >++ * Create a group to hold the dialog style combo box and >++ * create dialog button. >++ */ >++ dialogStyleGroup = new Group (controlGroup, SWT.NONE); >++ dialogStyleGroup.setLayout (new GridLayout ()); >++ GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER); >++ gridData.horizontalSpan = 2; >++ dialogStyleGroup.setLayoutData (gridData); >++ dialogStyleGroup.setText (ControlExample.getResourceString("Dialog_Type")); >++ } >++ >++ /** >++ * Creates the "Control" widget children. >++ */ >++ void createControlWidgets () { >++ >++ /* Create the combo */ >++ String [] strings = { >++ ControlExample.getResourceString("ColorDialog"), >++ ControlExample.getResourceString("DirectoryDialog"), >++ ControlExample.getResourceString("FileDialog"), >++ ControlExample.getResourceString("FontDialog"), >++ ControlExample.getResourceString("PrintDialog"), >++ ControlExample.getResourceString("MessageBox"), >++ }; >++ dialogCombo = new Combo (dialogStyleGroup, SWT.READ_ONLY); >++ dialogCombo.setItems (strings); >++ dialogCombo.setText (strings [0]); >++ dialogCombo.setVisibleItemCount(strings.length); >++ >++ /* Create the create dialog button */ >++ createButton = new Button(dialogStyleGroup, SWT.NONE); >++ createButton.setText (ControlExample.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.NONE); >++ buttonStyleGroup.setLayout (new GridLayout ()); >++ buttonStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ buttonStyleGroup.setText (ControlExample.getResourceString("Button_Styles")); >++ >++ /* Create the button style buttons */ >++ okButton = new Button (buttonStyleGroup, SWT.CHECK); >++ okButton.setText ("SWT.OK"); >++ cancelButton = new Button (buttonStyleGroup, SWT.CHECK); >++ cancelButton.setText ("SWT.CANCEL"); >++ yesButton = new Button (buttonStyleGroup, SWT.CHECK); >++ yesButton.setText ("SWT.YES"); >++ noButton = new Button (buttonStyleGroup, SWT.CHECK); >++ noButton.setText ("SWT.NO"); >++ retryButton = new Button (buttonStyleGroup, SWT.CHECK); >++ retryButton.setText ("SWT.RETRY"); >++ abortButton = new Button (buttonStyleGroup, SWT.CHECK); >++ abortButton.setText ("SWT.ABORT"); >++ ignoreButton = new Button (buttonStyleGroup, SWT.CHECK); >++ ignoreButton.setText ("SWT.IGNORE"); >++ >++ /* Create a group for the icon style controls */ >++ Group iconStyleGroup = new Group (controlGroup, SWT.NONE); >++ iconStyleGroup.setLayout (new GridLayout ()); >++ iconStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ iconStyleGroup.setText (ControlExample.getResourceString("Icon_Styles")); >++ >++ /* Create the icon style buttons */ >++ iconErrorButton = new Button (iconStyleGroup, SWT.RADIO); >++ iconErrorButton.setText ("SWT.ICON_ERROR"); >++ iconInformationButton = new Button (iconStyleGroup, SWT.RADIO); >++ iconInformationButton.setText ("SWT.ICON_INFORMATION"); >++ iconQuestionButton = new Button (iconStyleGroup, SWT.RADIO); >++ iconQuestionButton.setText ("SWT.ICON_QUESTION"); >++ iconWarningButton = new Button (iconStyleGroup, SWT.RADIO); >++ iconWarningButton.setText ("SWT.ICON_WARNING"); >++ iconWorkingButton = new Button (iconStyleGroup, SWT.RADIO); >++ iconWorkingButton.setText ("SWT.ICON_WORKING"); >++ noIconButton = new Button (iconStyleGroup, SWT.RADIO); >++ noIconButton.setText (ControlExample.getResourceString("No_Icon")); >++ >++ /* Create a group for the modal style controls */ >++ Group modalStyleGroup = new Group (controlGroup, SWT.NONE); >++ modalStyleGroup.setLayout (new GridLayout ()); >++ modalStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ modalStyleGroup.setText (ControlExample.getResourceString("Modal_Styles")); >++ >++ /* Create the modal style buttons */ >++ primaryModalButton = new Button (modalStyleGroup, SWT.RADIO); >++ primaryModalButton.setText ("SWT.PRIMARY_MODAL"); >++ applicationModalButton = new Button (modalStyleGroup, SWT.RADIO); >++ applicationModalButton.setText ("SWT.APPLICATION_MODAL"); >++ systemModalButton = new Button (modalStyleGroup, SWT.RADIO); >++ systemModalButton.setText ("SWT.SYSTEM_MODAL"); >++ >++ /* Create a group for other style controls */ >++ Group otherStyleGroup = new Group (controlGroup, SWT.NONE); >++ otherStyleGroup.setLayout (new GridLayout ()); >++ otherStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ otherStyleGroup.setText (ControlExample.getResourceString("Other_Styles")); >++ >++ /* Create the other style buttons */ >++ sheetButton = new Button(otherStyleGroup, SWT.CHECK); >++ sheetButton.setText("SWT.SHEET"); >++ >++ /* Create a group for the file dialog style controls */ >++ Group fileDialogStyleGroup = new Group (controlGroup, SWT.NONE); >++ fileDialogStyleGroup.setLayout (new GridLayout ()); >++ fileDialogStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ fileDialogStyleGroup.setText (ControlExample.getResourceString("File_Dialog_Styles")); >++ >++ /* Create the file dialog style buttons */ >++ openButton = new Button(fileDialogStyleGroup, SWT.RADIO); >++ openButton.setText("SWT.OPEN"); >++ saveButton = new Button (fileDialogStyleGroup, SWT.RADIO); >++ saveButton.setText ("SWT.SAVE"); >++ multiButton = new Button(fileDialogStyleGroup, SWT.CHECK); >++ multiButton.setText("SWT.MULTI"); >++ >++ /* Create the orientation group */ >++ if (RTL_SUPPORT_ENABLE) { >++ createOrientationGroup(); >++ } >++ >++ /* 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); >++ noIconButton.setEnabled (false); >++ saveButton.setEnabled (false); >++ openButton.setEnabled (false); >++ openButton.setSelection (true); >++ multiButton.setEnabled (false); >++ noIconButton.setSelection (true); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ >++ /* >++ * Create a group for the text widget to display >++ * the results returned by the example dialogs. >++ */ >++ resultGroup = new Group (exampleGroup, SWT.NONE); >++ resultGroup.setLayout (new GridLayout ()); >++ resultGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ resultGroup.setText (ControlExample.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.FILL_BOTH); >++ textWidget.setLayoutData (gridData); >++ } >++ >++ /** >++ * The platform dialogs do not have SWT listeners. >++ */ >++ void createListenersGroup () { >++ } >++ >++ /** >++ * 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 (ControlExample.getResourceString("MessageBox")); >++ boolean isFileDialog = name.equals (ControlExample.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); >++ noIconButton.setEnabled (isMessageBox); >++ saveButton.setEnabled (isFileDialog); >++ openButton.setEnabled (isFileDialog); >++ multiButton.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. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [0]; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Dialog"; >++ } >++ >++ /** >++ * Recreates the "Example" widgets. >++ */ >++ void recreateExampleWidgets () { >++ if (textWidget == null) { >++ super.recreateExampleWidgets (); >++ } >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ExpandBarTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ExpandBarTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ExpandBarTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ExpandBarTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,145 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++ >++class ExpandBarTab extends Tab { >++ /* Example widgets and groups that contain them */ >++ ExpandBar expandBar1; >++ Group expandBarGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button verticalButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ExpandBarTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the list */ >++ expandBarGroup = new Group (exampleGroup, SWT.NONE); >++ expandBarGroup.setLayout (new GridLayout ()); >++ expandBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ expandBarGroup.setText ("ExpandBar"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (verticalButton.getSelection()) style |= SWT.V_SCROLL; >++ >++ /* Create the example widgets */ >++ expandBar1 = new ExpandBar (expandBarGroup, style); >++ >++ // First item >++ Composite composite = new Composite (expandBar1, SWT.NONE); >++ composite.setLayout(new GridLayout ()); >++ new Button (composite, SWT.PUSH).setText("SWT.PUSH"); >++ new Button (composite, SWT.RADIO).setText("SWT.RADIO"); >++ new Button (composite, SWT.CHECK).setText("SWT.CHECK"); >++ new Button (composite, SWT.TOGGLE).setText("SWT.TOGGLE"); >++ ExpandItem item = new ExpandItem (expandBar1, SWT.NONE, 0); >++ item.setText(ControlExample.getResourceString("Item1_Text")); >++ item.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); >++ item.setControl(composite); >++ item.setImage(instance.images[ControlExample.ciClosedFolder]); >++ >++ // Second item >++ composite = new Composite (expandBar1, SWT.NONE); >++ composite.setLayout(new GridLayout (2, false)); >++ new Label (composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_ERROR)); >++ new Label (composite, SWT.NONE).setText("SWT.ICON_ERROR"); >++ new Label (composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_INFORMATION)); >++ new Label (composite, SWT.NONE).setText("SWT.ICON_INFORMATION"); >++ new Label (composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_WARNING)); >++ new Label (composite, SWT.NONE).setText("SWT.ICON_WARNING"); >++ new Label (composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_QUESTION)); >++ new Label (composite, SWT.NONE).setText("SWT.ICON_QUESTION"); >++ item = new ExpandItem (expandBar1, SWT.NONE, 1); >++ item.setText(ControlExample.getResourceString("Item2_Text")); >++ item.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); >++ item.setControl(composite); >++ item.setImage(instance.images[ControlExample.ciOpenFolder]); >++ item.setExpanded(true); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ verticalButton = new Button (styleGroup, SWT.CHECK); >++ verticalButton.setText ("SWT.V_SCROLL"); >++ verticalButton.setSelection(true); >++ borderButton = new Button(styleGroup, SWT.CHECK); >++ borderButton.setText("SWT.BORDER"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {expandBar1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Spacing"}; >++ } >++ >++ /** >++ * Gets the short text for the tab folder item. >++ */ >++ String getShortTabText() { >++ return "EB"; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "ExpandBar"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ Widget [] widgets = getExampleWidgets (); >++ if (widgets.length != 0){ >++ verticalButton.setSelection ((widgets [0].getStyle () & SWT.V_SCROLL) != 0); >++ borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0); >++ } >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/GroupTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/GroupTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/GroupTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/GroupTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,154 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.events.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++ >++class GroupTab extends Tab { >++ Button titleButton; >++ >++ /* Example widgets and groups that contain them */ >++ Group group1; >++ Group groupGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button shadowEtchedInButton, shadowEtchedOutButton, shadowInButton, shadowOutButton, shadowNoneButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ GroupTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Other" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ >++ /* Create display controls specific to this example */ >++ titleButton = new Button (otherGroup, SWT.CHECK); >++ titleButton.setText (ControlExample.getResourceString("Title_Text")); >++ >++ /* Add the listeners */ >++ titleButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setTitleText (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the Group */ >++ groupGroup = new Group (exampleGroup, SWT.NONE); >++ groupGroup.setLayout (new GridLayout ()); >++ groupGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ groupGroup.setText ("Group"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (shadowEtchedInButton.getSelection ()) style |= SWT.SHADOW_ETCHED_IN; >++ if (shadowEtchedOutButton.getSelection ()) style |= SWT.SHADOW_ETCHED_OUT; >++ if (shadowInButton.getSelection ()) style |= SWT.SHADOW_IN; >++ if (shadowOutButton.getSelection ()) style |= SWT.SHADOW_OUT; >++ if (shadowNoneButton.getSelection ()) style |= SWT.SHADOW_NONE; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ >++ /* Create the example widgets */ >++ group1 = new Group (groupGroup, style); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ shadowEtchedInButton = new Button (styleGroup, SWT.RADIO); >++ shadowEtchedInButton.setText ("SWT.SHADOW_ETCHED_IN"); >++ shadowEtchedInButton.setSelection(true); >++ shadowEtchedOutButton = new Button (styleGroup, SWT.RADIO); >++ shadowEtchedOutButton.setText ("SWT.SHADOW_ETCHED_OUT"); >++ shadowInButton = new Button (styleGroup, SWT.RADIO); >++ shadowInButton.setText ("SWT.SHADOW_IN"); >++ shadowOutButton = new Button (styleGroup, SWT.RADIO); >++ shadowOutButton.setText ("SWT.SHADOW_OUT"); >++ shadowNoneButton = new Button (styleGroup, SWT.RADIO); >++ shadowNoneButton.setText ("SWT.SHADOW_NONE"); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {group1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Text", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Group"; >++ } >++ >++ /** >++ * Sets the title text of the "Example" widgets. >++ */ >++ void setTitleText () { >++ if (titleButton.getSelection ()) { >++ group1.setText (ControlExample.getResourceString("Title_Text")); >++ } else { >++ group1.setText (""); >++ } >++ setExampleWidgetSize (); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ shadowEtchedInButton.setSelection ((group1.getStyle () & SWT.SHADOW_ETCHED_IN) != 0); >++ shadowEtchedOutButton.setSelection ((group1.getStyle () & SWT.SHADOW_ETCHED_OUT) != 0); >++ shadowInButton.setSelection ((group1.getStyle () & SWT.SHADOW_IN) != 0); >++ shadowOutButton.setSelection ((group1.getStyle () & SWT.SHADOW_OUT) != 0); >++ shadowNoneButton.setSelection ((group1.getStyle () & SWT.SHADOW_NONE) != 0); >++ borderButton.setSelection ((group1.getStyle () & SWT.BORDER) != 0); >++ if (!instance.startup) setTitleText (); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/LabelTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/LabelTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/LabelTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/LabelTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,183 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++ >++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 wrapButton, separatorButton, horizontalButton, verticalButton, shadowInButton, shadowOutButton, shadowNoneButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ LabelTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the text labels */ >++ textLabelGroup = new Group(exampleGroup, SWT.NONE); >++ GridLayout gridLayout = new GridLayout (); >++ textLabelGroup.setLayout (gridLayout); >++ gridLayout.numColumns = 3; >++ textLabelGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ textLabelGroup.setText (ControlExample.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 (SWT.FILL, SWT.FILL, true, true)); >++ imageLabelGroup.setText (ControlExample.getResourceString("Image_Labels")); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (wrapButton.getSelection ()) style |= SWT.WRAP; >++ 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 (shadowNoneButton.getSelection ()) style |= SWT.SHADOW_NONE; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (leftButton.getSelection ()) style |= SWT.LEFT; >++ if (centerButton.getSelection ()) style |= SWT.CENTER; >++ if (rightButton.getSelection ()) style |= SWT.RIGHT; >++ >++ /* Create the example widgets */ >++ label1 = new Label (textLabelGroup, style); >++ label1.setText(ControlExample.getResourceString("One")); >++ label2 = new Label (textLabelGroup, style); >++ label2.setText(ControlExample.getResourceString("Two")); >++ label3 = new Label (textLabelGroup, style); >++ if (wrapButton.getSelection ()) { >++ label3.setText (ControlExample.getResourceString("Wrap_Text")); >++ } else { >++ label3.setText (ControlExample.getResourceString("Three")); >++ } >++ label4 = new Label (imageLabelGroup, style); >++ label4.setImage (instance.images[ControlExample.ciClosedFolder]); >++ label5 = new Label (imageLabelGroup, style); >++ label6 = new Label(imageLabelGroup, style); >++ label6.setImage (instance.images[ControlExample.ciTarget]); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ wrapButton = new Button (styleGroup, SWT.CHECK); >++ wrapButton.setText ("SWT.WRAP"); >++ separatorButton = new Button (styleGroup, SWT.CHECK); >++ separatorButton.setText ("SWT.SEPARATOR"); >++ horizontalButton = new Button (styleGroup, SWT.RADIO); >++ horizontalButton.setText ("SWT.HORIZONTAL"); >++ verticalButton = new Button (styleGroup, SWT.RADIO); >++ verticalButton.setText ("SWT.VERTICAL"); >++ Group styleSubGroup = new Group (styleGroup, SWT.NONE); >++ styleSubGroup.setLayout (new GridLayout ()); >++ shadowInButton = new Button (styleSubGroup, SWT.RADIO); >++ shadowInButton.setText ("SWT.SHADOW_IN"); >++ shadowOutButton = new Button (styleSubGroup, SWT.RADIO); >++ shadowOutButton.setText ("SWT.SHADOW_OUT"); >++ shadowNoneButton = new Button (styleSubGroup, SWT.RADIO); >++ shadowNoneButton.setText ("SWT.SHADOW_NONE"); >++ borderButton = new Button(styleGroup, SWT.CHECK); >++ borderButton.setText("SWT.BORDER"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {label1, label2, label3, label4, label5, label6}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Text", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Label"; >++ } >++ >++ /** >++ * Sets the alignment of the "Example" widgets. >++ */ >++ void setExampleWidgetAlignment () { >++ int alignment = 0; >++ if (leftButton.getSelection ()) alignment = SWT.LEFT; >++ if (centerButton.getSelection ()) alignment = SWT.CENTER; >++ if (rightButton.getSelection ()) alignment = SWT.RIGHT; >++ label1.setAlignment (alignment); >++ label2.setAlignment (alignment); >++ label3.setAlignment (alignment); >++ label4.setAlignment (alignment); >++ label5.setAlignment (alignment); >++ label6.setAlignment (alignment); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ boolean isSeparator = (label1.getStyle () & SWT.SEPARATOR) != 0; >++ wrapButton.setSelection (!isSeparator && (label1.getStyle () & SWT.WRAP) != 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); >++ shadowNoneButton.setSelection (isSeparator && (label1.getStyle () & SWT.SHADOW_NONE) != 0); >++ horizontalButton.setSelection (isSeparator && (label1.getStyle () & SWT.HORIZONTAL) != 0); >++ verticalButton.setSelection (isSeparator && (label1.getStyle () & SWT.VERTICAL) != 0); >++ wrapButton.setEnabled (!isSeparator); >++ leftButton.setEnabled (!isSeparator); >++ centerButton.setEnabled (!isSeparator); >++ rightButton.setEnabled (!isSeparator); >++ shadowInButton.setEnabled (isSeparator); >++ shadowOutButton.setEnabled (isSeparator); >++ shadowNoneButton.setEnabled (isSeparator); >++ horizontalButton.setEnabled (isSeparator); >++ verticalButton.setEnabled (isSeparator); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/LinkTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/LinkTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/LinkTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/LinkTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,98 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++ >++class LinkTab extends Tab { >++ /* Example widgets and groups that contain them */ >++ Link link1; >++ Group linkGroup; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ LinkTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the list */ >++ linkGroup = new Group (exampleGroup, SWT.NONE); >++ linkGroup.setLayout (new GridLayout ()); >++ linkGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ linkGroup.setText ("Link"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ >++ /* Create the example widgets */ >++ try { >++ link1 = new Link (linkGroup, style); >++ link1.setText (ControlExample.getResourceString("LinkText")); >++ } catch (SWTError e) { >++ // temporary code for photon >++ Label label = new Label (linkGroup, SWT.CENTER | SWT.WRAP); >++ label.setText ("Link widget not suported"); >++ } >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ borderButton = new Button(styleGroup, SWT.CHECK); >++ borderButton.setText("SWT.BORDER"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++// temporary code for photon >++ if (link1 != null) return new Widget [] {link1}; >++ return new Widget[] {}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Text", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Link"; >++ } >++ >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ListTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ListTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ListTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ListTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,93 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++ >++class ListTab extends ScrollableTab { >++ >++ /* Example widgets and groups that contain them */ >++ List list1; >++ Group listGroup; >++ >++ static String [] ListData1 = {ControlExample.getResourceString("ListData1_0"), >++ ControlExample.getResourceString("ListData1_1"), >++ ControlExample.getResourceString("ListData1_2"), >++ ControlExample.getResourceString("ListData1_3"), >++ ControlExample.getResourceString("ListData1_4"), >++ ControlExample.getResourceString("ListData1_5"), >++ ControlExample.getResourceString("ListData1_6"), >++ ControlExample.getResourceString("ListData1_7"), >++ ControlExample.getResourceString("ListData1_8")}; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ListTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the list */ >++ listGroup = new Group (exampleGroup, SWT.NONE); >++ listGroup.setLayout (new GridLayout ()); >++ listGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ listGroup.setText ("List"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ 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. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {list1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Items", "Selection", "ToolTipText", "TopIndex"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "List"; >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/MenuTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/MenuTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/MenuTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/MenuTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,319 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2005 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.events.*; >++ >++class MenuTab extends Tab { >++ /* Widgets added to the "Menu Style", "MenuItem Style" and "Other" groups */ >++ Button barButton, dropDownButton, popUpButton, noRadioGroupButton, leftToRightButton, rightToLeftButton; >++ Button checkButton, cascadeButton, pushButton, radioButton, separatorButton; >++ Button imagesButton, acceleratorsButton, mnemonicsButton, subMenuButton, subSubMenuButton; >++ Button createButton, closeAllButton, enabledButton; >++ Group menuItemStyleGroup; >++ >++ /* Variables used to track the open shells */ >++ int shellCount = 0; >++ Shell [] shells = new Shell [4]; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ MenuTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * 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; >++ } >++ >++ int orientation = 0; >++ if (leftToRightButton.getSelection()) orientation |= SWT.LEFT_TO_RIGHT; >++ if (rightToLeftButton.getSelection()) orientation |= SWT.RIGHT_TO_LEFT; >++ int radioBehavior = 0; >++ if (noRadioGroupButton.getSelection()) radioBehavior |= SWT.NO_RADIO_GROUP; >++ >++ /* Create the shell and menu(s) */ >++ Shell shell = new Shell (SWT.SHELL_TRIM | orientation); >++ shells [shellCount] = shell; >++ if (barButton.getSelection ()) { >++ /* Create menu bar. */ >++ Menu menuBar = new Menu(shell, SWT.BAR | radioBehavior ); >++ shell.setMenuBar(menuBar); >++ hookListeners(menuBar); >++ >++ if (dropDownButton.getSelection() && cascadeButton.getSelection()) { >++ /* Create cascade button and drop-down menu in menu bar. */ >++ MenuItem item = new MenuItem(menuBar, SWT.CASCADE); >++ item.setText(getMenuItemText("Cascade")); >++ item.setEnabled(enabledButton.getSelection()); >++ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]); >++ hookListeners(item); >++ Menu dropDownMenu = new Menu(shell, SWT.DROP_DOWN | radioBehavior); >++ item.setMenu(dropDownMenu); >++ hookListeners(dropDownMenu); >++ >++ /* Create various menu items, depending on selections. */ >++ createMenuItems(dropDownMenu, subMenuButton.getSelection(), subSubMenuButton.getSelection()); >++ } >++ } >++ >++ if (popUpButton.getSelection()) { >++ /* Create pop-up menu. */ >++ Menu popUpMenu = new Menu(shell, SWT.POP_UP | radioBehavior); >++ shell.setMenu(popUpMenu); >++ hookListeners(popUpMenu); >++ >++ /* Create various menu items, depending on selections. */ >++ createMenuItems(popUpMenu, subMenuButton.getSelection(), subSubMenuButton.getSelection()); >++ } >++ >++ /* Set the size, title and open the shell. */ >++ shell.setSize (300, 100); >++ shell.setText (ControlExample.getResourceString("Title") + shellCount); >++ shell.addPaintListener(new PaintListener() { >++ public void paintControl(PaintEvent e) { >++ e.gc.drawString(ControlExample.getResourceString("PopupMenuHere"), 20, 20); >++ } >++ }); >++ shell.open (); >++ shellCount++; >++ } >++ >++ /** >++ * Creates the "Control" group. >++ */ >++ void createControlGroup () { >++ /* >++ * Create the "Control" group. This is the group on the >++ * right half of each example tab. For MenuTab, it consists of >++ * the Menu style group, the MenuItem style group and the 'other' group. >++ */ >++ controlGroup = new Group (tabFolderPage, SWT.NONE); >++ controlGroup.setLayout (new GridLayout (2, true)); >++ controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ controlGroup.setText (ControlExample.getResourceString("Parameters")); >++ >++ /* Create a group for the menu style controls */ >++ styleGroup = new Group (controlGroup, SWT.NONE); >++ styleGroup.setLayout (new GridLayout ()); >++ styleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ styleGroup.setText (ControlExample.getResourceString("Menu_Styles")); >++ >++ /* Create a group for the menu item style controls */ >++ menuItemStyleGroup = new Group (controlGroup, SWT.NONE); >++ menuItemStyleGroup.setLayout (new GridLayout ()); >++ menuItemStyleGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ menuItemStyleGroup.setText (ControlExample.getResourceString("MenuItem_Styles")); >++ >++ /* Create a group for the 'other' controls */ >++ otherGroup = new Group (controlGroup, SWT.NONE); >++ otherGroup.setLayout (new GridLayout ()); >++ otherGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ otherGroup.setText (ControlExample.getResourceString("Other")); >++ } >++ >++ /** >++ * Creates the "Control" widget children. >++ */ >++ void createControlWidgets () { >++ >++ /* Create the menu style buttons */ >++ barButton = new Button (styleGroup, SWT.CHECK); >++ barButton.setText ("SWT.BAR"); >++ dropDownButton = new Button (styleGroup, SWT.CHECK); >++ dropDownButton.setText ("SWT.DROP_DOWN"); >++ popUpButton = new Button (styleGroup, SWT.CHECK); >++ popUpButton.setText ("SWT.POP_UP"); >++ noRadioGroupButton = new Button (styleGroup, SWT.CHECK); >++ noRadioGroupButton.setText ("SWT.NO_RADIO_GROUP"); >++ leftToRightButton = new Button (styleGroup, SWT.RADIO); >++ leftToRightButton.setText ("SWT.LEFT_TO_RIGHT"); >++ leftToRightButton.setSelection(true); >++ rightToLeftButton = new Button (styleGroup, SWT.RADIO); >++ rightToLeftButton.setText ("SWT.RIGHT_TO_LEFT"); >++ >++ /* Create the menu item style buttons */ >++ cascadeButton = new Button (menuItemStyleGroup, SWT.CHECK); >++ cascadeButton.setText ("SWT.CASCADE"); >++ checkButton = new Button (menuItemStyleGroup, SWT.CHECK); >++ checkButton.setText ("SWT.CHECK"); >++ pushButton = new Button (menuItemStyleGroup, SWT.CHECK); >++ pushButton.setText ("SWT.PUSH"); >++ radioButton = new Button (menuItemStyleGroup, SWT.CHECK); >++ radioButton.setText ("SWT.RADIO"); >++ separatorButton = new Button (menuItemStyleGroup, SWT.CHECK); >++ separatorButton.setText ("SWT.SEPARATOR"); >++ >++ /* Create the 'other' buttons */ >++ imagesButton = new Button (otherGroup, SWT.CHECK); >++ imagesButton.setText (ControlExample.getResourceString("Images")); >++ acceleratorsButton = new Button (otherGroup, SWT.CHECK); >++ acceleratorsButton.setText (ControlExample.getResourceString("Accelerators")); >++ mnemonicsButton = new Button (otherGroup, SWT.CHECK); >++ mnemonicsButton.setText (ControlExample.getResourceString("Mnemonics")); >++ subMenuButton = new Button (otherGroup, SWT.CHECK); >++ subMenuButton.setText (ControlExample.getResourceString("SubMenu")); >++ subSubMenuButton = new Button (otherGroup, SWT.CHECK); >++ subSubMenuButton.setText (ControlExample.getResourceString("SubSubMenu")); >++ enabledButton = new Button(otherGroup, SWT.CHECK); >++ enabledButton.setText(ControlExample.getResourceString("Cascade Menu Enabled")); >++ >++ >++ /* Create the "create" and "closeAll" buttons (and a 'filler' label to place them) */ >++ new Label(controlGroup, SWT.NONE); >++ createButton = new Button (controlGroup, SWT.NONE); >++ createButton.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_END)); >++ createButton.setText (ControlExample.getResourceString("Create_Shell")); >++ closeAllButton = new Button (controlGroup, SWT.NONE); >++ closeAllButton.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING)); >++ closeAllButton.setText (ControlExample.getResourceString("Close_All_Shells")); >++ >++ /* Add the listeners */ >++ enabledButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleWidgetEnabled (); >++ } >++ }); >++ >++ createButton.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ createButtonSelected(e); >++ } >++ }); >++ closeAllButton.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ closeAllShells (); >++ } >++ }); >++ subMenuButton.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ subSubMenuButton.setEnabled (subMenuButton.getSelection ()); >++ } >++ }); >++ >++ /* Set the default state */ >++ barButton.setSelection (true); >++ dropDownButton.setSelection (true); >++ popUpButton.setSelection (true); >++ cascadeButton.setSelection (true); >++ checkButton.setSelection (true); >++ pushButton.setSelection (true); >++ radioButton.setSelection (true); >++ separatorButton.setSelection (true); >++ subSubMenuButton.setEnabled (subMenuButton.getSelection ()); >++ } >++ >++ /* Create various menu items, depending on selections. */ >++ void createMenuItems(Menu menu, boolean createSubMenu, boolean createSubSubMenu) { >++ MenuItem item; >++ if (pushButton.getSelection()) { >++ item = new MenuItem(menu, SWT.PUSH); >++ item.setText(getMenuItemText("Push")); >++ if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + 'P'); >++ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciClosedFolder]); >++ hookListeners(item); >++ } >++ >++ if (separatorButton.getSelection()) { >++ new MenuItem(menu, SWT.SEPARATOR); >++ } >++ >++ if (checkButton.getSelection()) { >++ item = new MenuItem(menu, SWT.CHECK); >++ item.setText(getMenuItemText("Check")); >++ if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + 'C'); >++ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]); >++ hookListeners(item); >++ } >++ >++ if (radioButton.getSelection()) { >++ item = new MenuItem(menu, SWT.RADIO); >++ item.setText(getMenuItemText("1Radio")); >++ if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + '1'); >++ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciTarget]); >++ item.setSelection(true); >++ hookListeners(item); >++ >++ item = new MenuItem(menu, SWT.RADIO); >++ item.setText(getMenuItemText("2Radio")); >++ if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + '2'); >++ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciTarget]); >++ hookListeners(item); >++ } >++ >++ if (createSubMenu && cascadeButton.getSelection()) { >++ /* Create cascade button and drop-down menu for the sub-menu. */ >++ item = new MenuItem(menu, SWT.CASCADE); >++ item.setText(getMenuItemText("Cascade")); >++ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]); >++ hookListeners(item); >++ Menu subMenu = new Menu(menu.getShell(), SWT.DROP_DOWN); >++ item.setMenu(subMenu); >++ hookListeners(subMenu); >++ >++ createMenuItems(subMenu, createSubSubMenu, false); >++ } >++ } >++ >++ String getMenuItemText(String item) { >++ boolean cascade = item.equals("Cascade"); >++ boolean mnemonic = mnemonicsButton.getSelection(); >++ boolean accelerator = acceleratorsButton.getSelection(); >++ char acceleratorKey = item.charAt(0); >++ if (mnemonic && accelerator && !cascade) { >++ return ControlExample.getResourceString(item + "WithMnemonic") + "\tCtrl+Shift+" + acceleratorKey; >++ } >++ if (accelerator && !cascade) { >++ return ControlExample.getResourceString(item) + "\tCtrl+Shift+" + acceleratorKey; >++ } >++ if (mnemonic) { >++ return ControlExample.getResourceString(item + "WithMnemonic"); >++ } >++ return ControlExample.getResourceString(item); >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Menu"; >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ProgressBarTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ProgressBarTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ProgressBarTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ProgressBarTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,178 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++ >++class ProgressBarTab extends RangeTab { >++ /* Example widgets and groups that contain them */ >++ ProgressBar progressBar1; >++ Group progressBarGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button smoothButton; >++ Button indeterminateButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ProgressBarTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup() { >++ super.createExampleGroup (); >++ >++ /* Create a group for the progress bar */ >++ progressBarGroup = new Group (exampleGroup, SWT.NONE); >++ progressBarGroup.setLayout (new GridLayout ()); >++ progressBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ progressBarGroup.setText ("ProgressBar"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL; >++ if (verticalButton.getSelection ()) style |= SWT.VERTICAL; >++ if (smoothButton.getSelection ()) style |= SWT.SMOOTH; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (indeterminateButton.getSelection ()) style |= SWT.INDETERMINATE; >++ >++ /* Create the example widgets */ >++ progressBar1 = new ProgressBar (progressBarGroup, style); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup () { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ smoothButton = new Button (styleGroup, SWT.CHECK); >++ smoothButton.setText ("SWT.SMOOTH"); >++ indeterminateButton = new Button (styleGroup, SWT.CHECK); >++ indeterminateButton.setText ("SWT.INDETERMINATE"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {progressBar1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Selection", "State", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the short text for the tab folder item. >++ */ >++ String getShortTabText() { >++ return "PB"; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "ProgressBar"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ if (indeterminateButton.getSelection ()) { >++ selectionSpinner.setEnabled (false); >++ minimumSpinner.setEnabled (false); >++ maximumSpinner.setEnabled (false); >++ } else { >++ selectionSpinner.setEnabled (true); >++ minimumSpinner.setEnabled (true); >++ maximumSpinner.setEnabled (true); >++ } >++ smoothButton.setSelection ((progressBar1.getStyle () & SWT.SMOOTH) != 0); >++ indeterminateButton.setSelection ((progressBar1.getStyle () & SWT.INDETERMINATE) != 0); >++ } >++ >++ /** >++ * Gets the default maximum of the "Example" widgets. >++ */ >++ int getDefaultMaximum () { >++ return progressBar1.getMaximum(); >++ } >++ >++ /** >++ * Gets the default minimim of the "Example" widgets. >++ */ >++ int getDefaultMinimum () { >++ return progressBar1.getMinimum(); >++ } >++ >++ /** >++ * Gets the default selection of the "Example" widgets. >++ */ >++ int getDefaultSelection () { >++ return progressBar1.getSelection(); >++ } >++ >++ /** >++ * Sets the maximum of the "Example" widgets. >++ */ >++ void setWidgetMaximum () { >++ progressBar1.setMaximum (maximumSpinner.getSelection ()); >++ updateSpinners (); >++ } >++ >++ /** >++ * Sets the minimim of the "Example" widgets. >++ */ >++ void setWidgetMinimum () { >++ progressBar1.setMinimum (minimumSpinner.getSelection ()); >++ updateSpinners (); >++ } >++ >++ /** >++ * Sets the selection of the "Example" widgets. >++ */ >++ void setWidgetSelection () { >++ progressBar1.setSelection (selectionSpinner.getSelection ()); >++ updateSpinners (); >++ } >++ >++ /** >++ * Update the Spinner widgets to reflect the actual value set >++ * on the "Example" widget. >++ */ >++ void updateSpinners () { >++ minimumSpinner.setSelection (progressBar1.getMinimum ()); >++ selectionSpinner.setSelection (progressBar1.getSelection ()); >++ maximumSpinner.setSelection (progressBar1.getMaximum ()); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/RangeTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/RangeTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/RangeTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/RangeTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,197 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++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; >++ boolean orientationButtons = true; >++ >++ /* Scale widgets added to the "Control" group */ >++ Spinner minimumSpinner, selectionSpinner, maximumSpinner; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ RangeTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Control" widget children. >++ */ >++ void createControlWidgets () { >++ /* 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.NONE); >++ maximumGroup.setLayout (new GridLayout ()); >++ maximumGroup.setText (ControlExample.getResourceString("Maximum")); >++ maximumGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create a Spinner widget */ >++ maximumSpinner = new Spinner (maximumGroup, SWT.BORDER); >++ maximumSpinner.setMaximum (100000); >++ maximumSpinner.setSelection (getDefaultMaximum()); >++ maximumSpinner.setPageIncrement (100); >++ maximumSpinner.setIncrement (1); >++ maximumSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ maximumSpinner.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.NONE); >++ minimumGroup.setLayout (new GridLayout ()); >++ minimumGroup.setText (ControlExample.getResourceString("Minimum")); >++ minimumGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create a Spinner widget */ >++ minimumSpinner = new Spinner (minimumGroup, SWT.BORDER); >++ minimumSpinner.setMaximum (100000); >++ minimumSpinner.setSelection(getDefaultMinimum()); >++ minimumSpinner.setPageIncrement (100); >++ minimumSpinner.setIncrement (1); >++ minimumSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ minimumSpinner.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.NONE); >++ selectionGroup.setLayout(new GridLayout()); >++ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, false, false); >++ selectionGroup.setLayoutData(gridData); >++ selectionGroup.setText(ControlExample.getResourceString("Selection")); >++ >++ /* Create a Spinner widget */ >++ selectionSpinner = new Spinner (selectionGroup, SWT.BORDER); >++ selectionSpinner.setMaximum (100000); >++ selectionSpinner.setSelection (getDefaultSelection()); >++ selectionSpinner.setPageIncrement (100); >++ selectionSpinner.setIncrement (1); >++ selectionSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ selectionSpinner.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent event) { >++ setWidgetSelection (); >++ } >++ }); >++ >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup () { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ if (orientationButtons) { >++ horizontalButton = new Button (styleGroup, SWT.RADIO); >++ horizontalButton.setText ("SWT.HORIZONTAL"); >++ verticalButton = new Button (styleGroup, SWT.RADIO); >++ verticalButton.setText ("SWT.VERTICAL"); >++ } >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ if (!instance.startup) { >++ setWidgetMinimum (); >++ setWidgetMaximum (); >++ setWidgetSelection (); >++ } >++ Widget [] widgets = getExampleWidgets (); >++ if (widgets.length != 0) { >++ if (orientationButtons) { >++ horizontalButton.setSelection ((widgets [0].getStyle () & SWT.HORIZONTAL) != 0); >++ verticalButton.setSelection ((widgets [0].getStyle () & SWT.VERTICAL) != 0); >++ } >++ borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0); >++ } >++ } >++ >++ /** >++ * Gets the default maximum of the "Example" widgets. >++ */ >++ abstract int getDefaultMaximum (); >++ >++ /** >++ * Gets the default minimim of the "Example" widgets. >++ */ >++ abstract int getDefaultMinimum (); >++ >++ /** >++ * Gets the default selection of the "Example" widgets. >++ */ >++ abstract int getDefaultSelection (); >++ >++ /** >++ * 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 (); >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/SashFormTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/SashFormTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/SashFormTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/SashFormTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,122 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.custom.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++ >++class SashFormTab extends Tab { >++ /* Example widgets and groups that contain them */ >++ Group sashFormGroup; >++ SashForm form; >++ List list1, list2; >++ Text text; >++ >++ /* Style widgets added to the "Style" group */ >++ Button horizontalButton, verticalButton, smoothButton; >++ >++ static String [] ListData0 = {ControlExample.getResourceString("ListData0_0"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData0_1"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData0_2"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData0_3"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData0_4"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData0_5"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData0_6"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData0_7")}; //$NON-NLS-1$ >++ >++ static String [] ListData1 = {ControlExample.getResourceString("ListData1_0"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData1_1"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData1_2"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData1_3"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData1_4"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData1_5"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData1_6"), //$NON-NLS-1$ >++ ControlExample.getResourceString("ListData1_7")}; //$NON-NLS-1$ >++ >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ SashFormTab(ControlExample instance) { >++ super(instance); >++ } >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the sashform widget */ >++ sashFormGroup = new Group (exampleGroup, SWT.NONE); >++ sashFormGroup.setLayout (new GridLayout ()); >++ sashFormGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ sashFormGroup.setText ("SashForm"); >++ } >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL; >++ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL; >++ if (smoothButton.getSelection ()) style |= SWT.SMOOTH; >++ >++ /* Create the example widgets */ >++ form = new SashForm (sashFormGroup, style); >++ list1 = new List (form, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >++ list1.setItems (ListData0); >++ list2 = new List (form, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >++ list2.setItems (ListData1); >++ text = new Text (form, SWT.MULTI | SWT.BORDER); >++ text.setText (ControlExample.getResourceString("Multi_line")); //$NON-NLS-1$ >++ form.setWeights(new int[] {1, 1, 1}); >++ } >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup(); >++ >++ /* Create the extra widgets */ >++ horizontalButton = new Button (styleGroup, SWT.RADIO); >++ horizontalButton.setText ("SWT.HORIZONTAL"); >++ horizontalButton.setSelection(true); >++ verticalButton = new Button (styleGroup, SWT.RADIO); >++ verticalButton.setText ("SWT.VERTICAL"); >++ verticalButton.setSelection(false); >++ smoothButton = new Button (styleGroup, SWT.CHECK); >++ smoothButton.setText ("SWT.SMOOTH"); >++ smoothButton.setSelection(false); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {form}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "SashForm"; //$NON-NLS-1$ >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ horizontalButton.setSelection ((form.getStyle () & SWT.H_SCROLL) != 0); >++ verticalButton.setSelection ((form.getStyle () & SWT.V_SCROLL) != 0); >++ smoothButton.setSelection ((form.getStyle () & SWT.SMOOTH) != 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/SashTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/SashTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/SashTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/SashTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,241 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.graphics.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.events.*; >++ >++class SashTab extends Tab { >++ /* Example widgets and groups that contain them */ >++ Sash hSash, vSash; >++ Composite sashComp; >++ Group sashGroup; >++ List list1, list2, list3; >++ Text text; >++ Button smoothButton; >++ >++ static String [] ListData0 = {ControlExample.getResourceString("ListData0_0"), >++ ControlExample.getResourceString("ListData0_1"), >++ ControlExample.getResourceString("ListData0_2"), >++ ControlExample.getResourceString("ListData0_3"), >++ ControlExample.getResourceString("ListData0_4"), >++ ControlExample.getResourceString("ListData0_5"), >++ ControlExample.getResourceString("ListData0_6"), >++ ControlExample.getResourceString("ListData0_7"), >++ ControlExample.getResourceString("ListData0_8")}; >++ >++ static String [] ListData1 = {ControlExample.getResourceString("ListData1_0"), >++ ControlExample.getResourceString("ListData1_1"), >++ ControlExample.getResourceString("ListData1_2"), >++ ControlExample.getResourceString("ListData1_3"), >++ ControlExample.getResourceString("ListData1_4"), >++ ControlExample.getResourceString("ListData1_5"), >++ ControlExample.getResourceString("ListData1_6"), >++ ControlExample.getResourceString("ListData1_7"), >++ ControlExample.getResourceString("ListData1_8")}; >++ >++ /* Constants */ >++ static final int SASH_WIDTH = 3; >++ static final int SASH_LIMIT = 20; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ SashTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ exampleGroup.setLayout(new FillLayout()); >++ >++ /* Create a group for the sash widgets */ >++ sashGroup = new Group (exampleGroup, SWT.NONE); >++ FillLayout layout = new FillLayout(); >++ layout.marginHeight = layout.marginWidth = 5; >++ sashGroup.setLayout(layout); >++ sashGroup.setText ("Sash"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ /* >++ * Create the page. This example does not use layouts. >++ */ >++ int style = getDefaultStyle(); >++ sashComp = new Composite(sashGroup, SWT.BORDER | style); >++ >++ /* Create the list and text widgets */ >++ list1 = new List (sashComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >++ list1.setItems (ListData0); >++ list2 = new List (sashComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >++ list2.setItems (ListData1); >++ text = new Text (sashComp, SWT.MULTI | SWT.BORDER); >++ text.setText (ControlExample.getResourceString("Multi_line")); >++ >++ /* Create the sashes */ >++ style = smoothButton.getSelection() ? SWT.SMOOTH : SWT.NONE; >++ vSash = new Sash (sashComp, SWT.VERTICAL | style); >++ hSash = new Sash (sashComp, SWT.HORIZONTAL | style); >++ >++ /* Add the listeners */ >++ hSash.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ Rectangle rect = vSash.getParent().getClientArea(); >++ event.y = Math.min (Math.max (event.y, SASH_LIMIT), rect.height - SASH_LIMIT); >++ 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) { >++ Rectangle rect = vSash.getParent().getClientArea(); >++ event.x = Math.min (Math.max (event.x, SASH_LIMIT), rect.width - SASH_LIMIT); >++ if (event.detail != SWT.DRAG) { >++ vSash.setBounds (event.x, event.y, event.width, event.height); >++ layout (); >++ } >++ } >++ }); >++ sashComp.addControlListener (new ControlAdapter () { >++ public void controlResized (ControlEvent event) { >++ resized (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Size" group. The "Size" group contains >++ * controls that allow the user to change the size of >++ * the example widgets. >++ */ >++ void createSizeGroup () { >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ smoothButton = new Button (styleGroup, SWT.CHECK); >++ smoothButton.setText("SWT.SMOOTH"); >++ } >++ >++ void disposeExampleWidgets () { >++ sashComp.dispose(); >++ sashComp = null; >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {hSash, vSash}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Sash"; >++ } >++ >++ /** >++ * Layout the list and text widgets according to the new >++ * positions of the sashes..events.SelectionEvent >++ */ >++ void layout () { >++ >++ Rectangle clientArea = sashComp.getClientArea (); >++ Rectangle hSashBounds = hSash.getBounds (); >++ Rectangle vSashBounds = vSash.getBounds (); >++ >++ list1.setBounds (0, 0, vSashBounds.x, hSashBounds.y); >++ list2.setBounds (vSashBounds.x + vSashBounds.width, 0, clientArea.width - (vSashBounds.x + vSashBounds.width), hSashBounds.y); >++ text.setBounds (0, hSashBounds.y + hSashBounds.height, clientArea.width, clientArea.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); >++ } >++ /** >++ * Sets the size of the "Example" widgets. >++ */ >++ void setExampleWidgetSize () { >++ sashGroup.layout (true); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ smoothButton.setSelection ((hSash.getStyle () & SWT.SMOOTH) != 0); >++ } >++ >++ /** >++ * Handle the shell resized event. >++ */ >++ void resized () { >++ >++ /* Get the client area for the shell */ >++ Rectangle clientArea = sashComp.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, (clientArea.width - SASH_WIDTH) / 2, (clientArea.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, clientArea.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, clientArea.width, clientArea.height - (list1Bounds.height + SASH_WIDTH)); >++ >++ /* Position the sashes */ >++ vSash.setBounds (list1Bounds.width, 0, SASH_WIDTH, list1Bounds.height); >++ hSash.setBounds (0, list1Bounds.height, clientArea.width, SASH_WIDTH); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ScaleTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ScaleTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ScaleTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ScaleTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,230 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.events.*; >++ >++class ScaleTab extends RangeTab { >++ /* Example widgets and groups that contain them */ >++ Scale scale1; >++ Group scaleGroup; >++ >++ /* Spinner widgets added to the "Control" group */ >++ Spinner incrementSpinner, pageIncrementSpinner; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ScaleTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Control" widget children. >++ */ >++ void createControlWidgets () { >++ super.createControlWidgets (); >++ createIncrementGroup (); >++ createPageIncrementGroup (); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the scale */ >++ scaleGroup = new Group (exampleGroup, SWT.NONE); >++ scaleGroup.setLayout (new GridLayout ()); >++ scaleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ scaleGroup.setText ("Scale"); >++ >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ 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); >++ } >++ >++ /** >++ * 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.NONE); >++ incrementGroup.setLayout (new GridLayout ()); >++ incrementGroup.setText (ControlExample.getResourceString("Increment")); >++ incrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create the Spinner widget */ >++ incrementSpinner = new Spinner (incrementGroup, SWT.BORDER); >++ incrementSpinner.setMaximum (100000); >++ incrementSpinner.setSelection (getDefaultIncrement()); >++ incrementSpinner.setPageIncrement (100); >++ incrementSpinner.setIncrement (1); >++ incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ incrementSpinner.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.NONE); >++ pageIncrementGroup.setLayout (new GridLayout ()); >++ pageIncrementGroup.setText (ControlExample.getResourceString("Page_Increment")); >++ pageIncrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create the Spinner widget */ >++ pageIncrementSpinner = new Spinner (pageIncrementGroup, SWT.BORDER); >++ pageIncrementSpinner.setMaximum (100000); >++ pageIncrementSpinner.setSelection (getDefaultPageIncrement()); >++ pageIncrementSpinner.setPageIncrement (100); >++ pageIncrementSpinner.setIncrement (1); >++ pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ pageIncrementSpinner.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetPageIncrement (); >++ } >++ }); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {scale1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Selection", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Scale"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ if (!instance.startup) { >++ setWidgetIncrement (); >++ setWidgetPageIncrement (); >++ } >++ } >++ >++ /** >++ * Gets the default maximum of the "Example" widgets. >++ */ >++ int getDefaultMaximum () { >++ return scale1.getMaximum(); >++ } >++ >++ /** >++ * Gets the default minimim of the "Example" widgets. >++ */ >++ int getDefaultMinimum () { >++ return scale1.getMinimum(); >++ } >++ >++ /** >++ * Gets the default selection of the "Example" widgets. >++ */ >++ int getDefaultSelection () { >++ return scale1.getSelection(); >++ } >++ >++ /** >++ * Gets the default increment of the "Example" widgets. >++ */ >++ int getDefaultIncrement () { >++ return scale1.getIncrement(); >++ } >++ >++ /** >++ * Gets the default page increment of the "Example" widgets. >++ */ >++ int getDefaultPageIncrement () { >++ return scale1.getPageIncrement(); >++ } >++ >++ /** >++ * Sets the increment of the "Example" widgets. >++ */ >++ void setWidgetIncrement () { >++ scale1.setIncrement (incrementSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the minimim of the "Example" widgets. >++ */ >++ void setWidgetMaximum () { >++ scale1.setMaximum (maximumSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the minimim of the "Example" widgets. >++ */ >++ void setWidgetMinimum () { >++ scale1.setMinimum (minimumSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the page increment of the "Example" widgets. >++ */ >++ void setWidgetPageIncrement () { >++ scale1.setPageIncrement (pageIncrementSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the selection of the "Example" widgets. >++ */ >++ void setWidgetSelection () { >++ scale1.setSelection (selectionSpinner.getSelection ()); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ScrollableTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ScrollableTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ScrollableTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ScrollableTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,63 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++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; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ScrollableTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup () { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ singleButton = new Button (styleGroup, SWT.RADIO); >++ singleButton.setText ("SWT.SINGLE"); >++ multiButton = new Button (styleGroup, SWT.RADIO); >++ multiButton.setText ("SWT.MULTI"); >++ horizontalButton = new Button (styleGroup, SWT.CHECK); >++ horizontalButton.setText ("SWT.H_SCROLL"); >++ horizontalButton.setSelection(true); >++ verticalButton = new Button (styleGroup, SWT.CHECK); >++ verticalButton.setText ("SWT.V_SCROLL"); >++ verticalButton.setSelection(true); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ Widget [] widgets = getExampleWidgets (); >++ if (widgets.length != 0){ >++ singleButton.setSelection ((widgets [0].getStyle () & SWT.SINGLE) != 0); >++ multiButton.setSelection ((widgets [0].getStyle () & SWT.MULTI) != 0); >++ horizontalButton.setSelection ((widgets [0].getStyle () & SWT.H_SCROLL) != 0); >++ verticalButton.setSelection ((widgets [0].getStyle () & SWT.V_SCROLL) != 0); >++ borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0); >++ } >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ShellTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ShellTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ShellTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ShellTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,341 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2006 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++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" groups, and "Other" group */ >++ Button noParentButton, parentButton; >++ Button noTrimButton, closeButton, titleButton, minButton, maxButton, borderButton, resizeButton, onTopButton, toolButton, sheetButton, shellTrimButton, dialogTrimButton; >++ Button createButton, closeAllButton; >++ Button modelessButton, primaryModalButton, applicationModalButton, systemModalButton; >++ Button imageButton; >++ Group parentStyleGroup, modalStyleGroup; >++ >++ /* Variables used to track the open shells */ >++ int shellCount = 0; >++ Shell [] shells = new Shell [4]; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ShellTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Close all the example shells. >++ */ >++ void closeAllShells() { >++ for (int i = 0; i<shellCount; i++) { >++ if (shells [i] != null & !shells [i].isDisposed ()) { >++ shells [i].dispose(); >++ shells [i] = null; >++ } >++ } >++ 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; >++ if (onTopButton.getSelection()) style |= SWT.ON_TOP; >++ if (toolButton.getSelection()) style |= SWT.TOOL; >++ if (sheetButton.getSelection()) style |= SWT.SHEET; >++ if (modelessButton.getSelection()) style |= SWT.MODELESS; >++ if (primaryModalButton.getSelection()) style |= SWT.PRIMARY_MODAL; >++ if (applicationModalButton.getSelection()) style |= SWT.APPLICATION_MODAL; >++ if (systemModalButton.getSelection()) style |= SWT.SYSTEM_MODAL; >++ >++ /* Create the shell with or without a parent */ >++ if (noParentButton.getSelection ()) { >++ shells [shellCount] = new Shell (style); >++ } else { >++ shells [shellCount] = new Shell (shell, style); >++ } >++ final Shell currentShell = shells [shellCount]; >++ currentShell.setBackgroundMode(SWT.INHERIT_DEFAULT); >++ final Button button = new Button(currentShell, SWT.CHECK); >++ button.setBounds(20, 20, 120, 30); >++ button.setText(ControlExample.getResourceString("FullScreen")); >++ button.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ currentShell.setFullScreen(button.getSelection()); >++ } >++ }); >++ Button close = new Button(currentShell, SWT.PUSH); >++ close.setBounds(160, 20, 120, 30); >++ close.setText(ControlExample.getResourceString("Close")); >++ close.addListener(SWT.Selection, new Listener() { >++ public void handleEvent(Event event) { >++ currentShell.dispose(); >++ } >++ }); >++ >++ /* Set the size, title, and image, and open the shell */ >++ currentShell.setSize (300, 100); >++ currentShell.setText (ControlExample.getResourceString("Title") + shellCount); >++ if (imageButton.getSelection()) currentShell.setImage(instance.images[ControlExample.ciTarget]); >++ if (backgroundImageButton.getSelection()) currentShell.setBackgroundImage(instance.images[ControlExample.ciBackground]); >++ hookListeners (currentShell); >++ currentShell.open (); >++ shellCount++; >++ } >++ >++ /** >++ * Creates the "Control" group. >++ */ >++ void createControlGroup () { >++ /* >++ * Create the "Control" group. This is the group on the >++ * right half of each example tab. It consists of the >++ * style group, the 'other' group and the size group. >++ */ >++ controlGroup = new Group (tabFolderPage, SWT.NONE); >++ controlGroup.setLayout (new GridLayout (2, true)); >++ controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ controlGroup.setText (ControlExample.getResourceString("Parameters")); >++ >++ /* Create a group for the decoration style controls */ >++ styleGroup = new Group (controlGroup, SWT.NONE); >++ styleGroup.setLayout (new GridLayout ()); >++ styleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false, 1, 3)); >++ styleGroup.setText (ControlExample.getResourceString("Decoration_Styles")); >++ >++ /* Create a group for the modal style controls */ >++ modalStyleGroup = new Group (controlGroup, SWT.NONE); >++ modalStyleGroup.setLayout (new GridLayout ()); >++ modalStyleGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >++ modalStyleGroup.setText (ControlExample.getResourceString("Modal_Styles")); >++ >++ /* Create a group for the 'other' controls */ >++ otherGroup = new Group (controlGroup, SWT.NONE); >++ otherGroup.setLayout (new GridLayout ()); >++ otherGroup.setLayoutData (new GridData(SWT.FILL, SWT.FILL, false, false)); >++ otherGroup.setText (ControlExample.getResourceString("Other")); >++ >++ /* Create a group for the parent style controls */ >++ parentStyleGroup = new Group (controlGroup, SWT.NONE); >++ parentStyleGroup.setLayout (new GridLayout ()); >++ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >++ parentStyleGroup.setLayoutData (gridData); >++ parentStyleGroup.setText (ControlExample.getResourceString("Parent")); >++ } >++ >++ /** >++ * Creates the "Control" widget children. >++ */ >++ void createControlWidgets () { >++ >++ /* Create the parent style buttons */ >++ noParentButton = new Button (parentStyleGroup, SWT.RADIO); >++ noParentButton.setText (ControlExample.getResourceString("No_Parent")); >++ parentButton = new Button (parentStyleGroup, SWT.RADIO); >++ parentButton.setText (ControlExample.getResourceString("Parent")); >++ >++ /* Create the decoration style buttons */ >++ noTrimButton = new Button (styleGroup, SWT.CHECK); >++ noTrimButton.setText ("SWT.NO_TRIM"); >++ closeButton = new Button (styleGroup, SWT.CHECK); >++ closeButton.setText ("SWT.CLOSE"); >++ titleButton = new Button (styleGroup, SWT.CHECK); >++ titleButton.setText ("SWT.TITLE"); >++ minButton = new Button (styleGroup, SWT.CHECK); >++ minButton.setText ("SWT.MIN"); >++ maxButton = new Button (styleGroup, SWT.CHECK); >++ maxButton.setText ("SWT.MAX"); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ resizeButton = new Button (styleGroup, SWT.CHECK); >++ resizeButton.setText ("SWT.RESIZE"); >++ onTopButton = new Button (styleGroup, SWT.CHECK); >++ onTopButton.setText ("SWT.ON_TOP"); >++ toolButton = new Button (styleGroup, SWT.CHECK); >++ toolButton.setText ("SWT.TOOL"); >++ sheetButton = new Button (styleGroup, SWT.CHECK); >++ sheetButton.setText ("SWT.SHEET"); >++ Label separator = new Label(styleGroup, SWT.SEPARATOR | SWT.HORIZONTAL); >++ separator.setLayoutData(new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ shellTrimButton = new Button (styleGroup, SWT.CHECK); >++ shellTrimButton.setText ("SWT.SHELL_TRIM"); >++ dialogTrimButton = new Button (styleGroup, SWT.CHECK); >++ dialogTrimButton.setText ("SWT.DIALOG_TRIM"); >++ >++ /* Create the modal style buttons */ >++ modelessButton = new Button (modalStyleGroup, SWT.RADIO); >++ modelessButton.setText ("SWT.MODELESS"); >++ primaryModalButton = new Button (modalStyleGroup, SWT.RADIO); >++ primaryModalButton.setText ("SWT.PRIMARY_MODAL"); >++ applicationModalButton = new Button (modalStyleGroup, SWT.RADIO); >++ applicationModalButton.setText ("SWT.APPLICATION_MODAL"); >++ systemModalButton = new Button (modalStyleGroup, SWT.RADIO); >++ systemModalButton.setText ("SWT.SYSTEM_MODAL"); >++ >++ /* Create the 'other' buttons */ >++ imageButton = new Button (otherGroup, SWT.CHECK); >++ imageButton.setText (ControlExample.getResourceString("Image")); >++ backgroundImageButton = new Button(otherGroup, SWT.CHECK); >++ backgroundImageButton.setText(ControlExample.getResourceString("BackgroundImage")); >++ >++ /* Create the "create" and "closeAll" buttons */ >++ createButton = new Button (controlGroup, SWT.NONE); >++ GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_END); >++ createButton.setLayoutData (gridData); >++ createButton.setText (ControlExample.getResourceString("Create_Shell")); >++ closeAllButton = new Button (controlGroup, SWT.NONE); >++ gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING); >++ closeAllButton.setText (ControlExample.getResourceString("Close_All_Shells")); >++ closeAllButton.setLayoutData (gridData); >++ >++ /* 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); >++ dialogTrimButton.addSelectionListener (decorationButtonListener); >++ shellTrimButton.addSelectionListener (decorationButtonListener); >++ applicationModalButton.addSelectionListener (decorationButtonListener); >++ systemModalButton.addSelectionListener (decorationButtonListener); >++ >++ /* Set the default state */ >++ noParentButton.setSelection (true); >++ modelessButton.setSelection (true); >++ } >++ >++ /** >++ * Handle a decoration button selection event. >++ * >++ * @param event org.eclipse.swt.events.SelectionEvent >++ */ >++ public void decorationButtonSelected(SelectionEvent event) { >++ Button widget = (Button) event.widget; >++ >++ /* >++ * Make sure that if the modal style is SWT.APPLICATION_MODAL >++ * or SWT.SYSTEM_MODAL the style SWT.CLOSE is also selected. >++ * This is to make sure the user can close the shell. >++ */ >++ if (widget == applicationModalButton || widget == systemModalButton) { >++ if (widget.getSelection()) { >++ closeButton.setSelection (true); >++ noTrimButton.setSelection (false); >++ } >++ return; >++ } >++ if (widget == closeButton) { >++ if (applicationModalButton.getSelection() || systemModalButton.getSelection()) { >++ closeButton.setSelection (true); >++ } >++ } >++ /* >++ * Make sure that if the SWT.NO_TRIM button is selected >++ * then all other decoration buttons are deselected. >++ */ >++ if (widget.getSelection()) { >++ if (widget == noTrimButton) { >++ if (applicationModalButton.getSelection() || systemModalButton.getSelection()) { >++ noTrimButton.setSelection (false); >++ return; >++ } >++ closeButton.setSelection (false); >++ titleButton.setSelection (false); >++ minButton.setSelection (false); >++ maxButton.setSelection (false); >++ borderButton.setSelection (false); >++ resizeButton.setSelection (false); >++ } else { >++ noTrimButton.setSelection (false); >++ } >++ } >++ >++ /* >++ * Make sure that the SWT.DIALOG_TRIM and SWT.SHELL_TRIM buttons >++ * are consistent. >++ */ >++ if (widget == dialogTrimButton || widget == shellTrimButton) { >++ if (widget.getSelection() && widget == dialogTrimButton) { >++ shellTrimButton.setSelection(false); >++ } else { >++ dialogTrimButton.setSelection(false); >++ } >++ //SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE; >++ //DIALOG_TRIM = TITLE | CLOSE | BORDER; >++ closeButton.setSelection (widget.getSelection ()); >++ titleButton.setSelection (widget.getSelection ()); >++ minButton.setSelection (widget == shellTrimButton && widget.getSelection( )); >++ maxButton.setSelection (widget == shellTrimButton && widget.getSelection ()); >++ borderButton.setSelection (widget == dialogTrimButton && widget.getSelection ()); >++ resizeButton.setSelection (widget == shellTrimButton && widget.getSelection ()); >++ } else { >++ boolean title = titleButton.getSelection (); >++ boolean close = closeButton.getSelection (); >++ boolean min = minButton.getSelection (); >++ boolean max = maxButton.getSelection (); >++ boolean border = borderButton.getSelection (); >++ boolean resize = resizeButton.getSelection (); >++ dialogTrimButton.setSelection(title && close && border && !min && !max && !resize); >++ shellTrimButton.setSelection(title && close && min && max && resize && !border); >++ } >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Shell"; >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/SliderTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/SliderTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/SliderTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/SliderTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,273 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++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 */ >++ Slider slider1; >++ Group sliderGroup; >++ >++ /* Spinner widgets added to the "Control" group */ >++ Spinner incrementSpinner, pageIncrementSpinner, thumbSpinner; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ SliderTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * 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.NONE); >++ sliderGroup.setLayout (new GridLayout ()); >++ sliderGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ sliderGroup.setText ("Slider"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL; >++ if (verticalButton.getSelection ()) style |= SWT.VERTICAL; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ >++ /* Create the example widgets */ >++ slider1 = new Slider(sliderGroup, style); >++ } >++ >++ /** >++ * 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.NONE); >++ incrementGroup.setLayout (new GridLayout ()); >++ incrementGroup.setText (ControlExample.getResourceString("Increment")); >++ incrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create the Spinner widget */ >++ incrementSpinner = new Spinner (incrementGroup, SWT.BORDER); >++ incrementSpinner.setMaximum (100000); >++ incrementSpinner.setSelection (getDefaultIncrement()); >++ incrementSpinner.setPageIncrement (100); >++ incrementSpinner.setIncrement (1); >++ incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ incrementSpinner.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.NONE); >++ pageIncrementGroup.setLayout (new GridLayout ()); >++ pageIncrementGroup.setText (ControlExample.getResourceString("Page_Increment")); >++ pageIncrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create the Spinner widget */ >++ pageIncrementSpinner = new Spinner (pageIncrementGroup, SWT.BORDER); >++ pageIncrementSpinner.setMaximum (100000); >++ pageIncrementSpinner.setSelection (getDefaultPageIncrement()); >++ pageIncrementSpinner.setPageIncrement (100); >++ pageIncrementSpinner.setIncrement (1); >++ pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ pageIncrementSpinner.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetPageIncrement (); >++ } >++ }); >++ } >++ >++ /** >++ * 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.NONE); >++ thumbGroup.setLayout (new GridLayout ()); >++ thumbGroup.setText (ControlExample.getResourceString("Thumb")); >++ thumbGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create the Spinner widget */ >++ thumbSpinner = new Spinner (thumbGroup, SWT.BORDER); >++ thumbSpinner.setMaximum (100000); >++ thumbSpinner.setSelection (getDefaultThumb()); >++ thumbSpinner.setPageIncrement (100); >++ thumbSpinner.setIncrement (1); >++ thumbSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ thumbSpinner.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetThumb (); >++ } >++ }); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {slider1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Selection", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Slider"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ if (!instance.startup) { >++ setWidgetIncrement (); >++ setWidgetPageIncrement (); >++ setWidgetThumb (); >++ } >++ } >++ >++ /** >++ * Gets the default maximum of the "Example" widgets. >++ */ >++ int getDefaultMaximum () { >++ return slider1.getMaximum(); >++ } >++ >++ /** >++ * Gets the default minimim of the "Example" widgets. >++ */ >++ int getDefaultMinimum () { >++ return slider1.getMinimum(); >++ } >++ >++ /** >++ * Gets the default selection of the "Example" widgets. >++ */ >++ int getDefaultSelection () { >++ return slider1.getSelection(); >++ } >++ >++ /** >++ * Gets the default increment of the "Example" widgets. >++ */ >++ int getDefaultIncrement () { >++ return slider1.getIncrement(); >++ } >++ >++ /** >++ * Gets the default page increment of the "Example" widgets. >++ */ >++ int getDefaultPageIncrement () { >++ return slider1.getPageIncrement(); >++ } >++ >++ /** >++ * Gets the default thumb of the "Example" widgets. >++ */ >++ int getDefaultThumb () { >++ return slider1.getThumb(); >++ } >++ >++ /** >++ * Sets the increment of the "Example" widgets. >++ */ >++ void setWidgetIncrement () { >++ slider1.setIncrement (incrementSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the minimim of the "Example" widgets. >++ */ >++ void setWidgetMaximum () { >++ slider1.setMaximum (maximumSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the minimim of the "Example" widgets. >++ */ >++ void setWidgetMinimum () { >++ slider1.setMinimum (minimumSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the page increment of the "Example" widgets. >++ */ >++ void setWidgetPageIncrement () { >++ slider1.setPageIncrement (pageIncrementSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the selection of the "Example" widgets. >++ */ >++ void setWidgetSelection () { >++ slider1.setSelection (selectionSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the thumb of the "Example" widgets. >++ */ >++ void setWidgetThumb () { >++ slider1.setThumb (thumbSpinner.getSelection ()); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/SpinnerTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/SpinnerTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/SpinnerTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/SpinnerTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,317 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.events.*; >++import org.eclipse.swt.layout.*; >++ >++class SpinnerTab extends RangeTab { >++ >++ /* Example widgets and groups that contain them */ >++ Spinner spinner1; >++ Group spinnerGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button readOnlyButton, wrapButton; >++ >++ /* Spinner widgets added to the "Control" group */ >++ Spinner incrementSpinner, pageIncrementSpinner, digitsSpinner; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ SpinnerTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Control" widget children. >++ */ >++ void createControlWidgets () { >++ super.createControlWidgets (); >++ createIncrementGroup (); >++ createPageIncrementGroup (); >++ createDigitsGroup (); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the spinner */ >++ spinnerGroup = new Group (exampleGroup, SWT.NONE); >++ spinnerGroup.setLayout (new GridLayout ()); >++ spinnerGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ spinnerGroup.setText ("Spinner"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (wrapButton.getSelection ()) style |= SWT.WRAP; >++ >++ /* Create the example widgets */ >++ spinner1 = new Spinner (spinnerGroup, style); >++ } >++ >++ /** >++ * 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.NONE); >++ incrementGroup.setLayout (new GridLayout ()); >++ incrementGroup.setText (ControlExample.getResourceString("Increment")); >++ incrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create the Spinner widget */ >++ incrementSpinner = new Spinner (incrementGroup, SWT.BORDER); >++ incrementSpinner.setMaximum (100000); >++ incrementSpinner.setSelection (getDefaultIncrement()); >++ incrementSpinner.setPageIncrement (100); >++ incrementSpinner.setIncrement (1); >++ incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ incrementSpinner.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.NONE); >++ pageIncrementGroup.setLayout (new GridLayout ()); >++ pageIncrementGroup.setText (ControlExample.getResourceString("Page_Increment")); >++ pageIncrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create the Spinner widget */ >++ pageIncrementSpinner = new Spinner (pageIncrementGroup, SWT.BORDER); >++ pageIncrementSpinner.setMaximum (100000); >++ pageIncrementSpinner.setSelection (getDefaultPageIncrement()); >++ pageIncrementSpinner.setPageIncrement (100); >++ pageIncrementSpinner.setIncrement (1); >++ pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ pageIncrementSpinner.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetPageIncrement (); >++ } >++ }); >++ } >++ >++ /** >++ * Create a group of widgets to control the digits >++ * attribute of the example widget. >++ */ >++ void createDigitsGroup() { >++ >++ /* Create the group */ >++ Group digitsGroup = new Group (controlGroup, SWT.NONE); >++ digitsGroup.setLayout (new GridLayout ()); >++ digitsGroup.setText (ControlExample.getResourceString("Digits")); >++ digitsGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >++ >++ /* Create the Spinner widget */ >++ digitsSpinner = new Spinner (digitsGroup, SWT.BORDER); >++ digitsSpinner.setMaximum (100000); >++ digitsSpinner.setSelection (getDefaultDigits()); >++ digitsSpinner.setPageIncrement (100); >++ digitsSpinner.setIncrement (1); >++ digitsSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ >++ /* Add the listeners */ >++ digitsSpinner.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent e) { >++ setWidgetDigits (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the tab folder page. >++ * >++ * @param tabFolder org.eclipse.swt.widgets.TabFolder >++ * @return the new page for the tab folder >++ */ >++ Composite createTabFolderPage (TabFolder tabFolder) { >++ super.createTabFolderPage (tabFolder); >++ >++ /* >++ * Add a resize listener to the tabFolderPage so that >++ * if the user types into the example widget to change >++ * its preferred size, and then resizes the shell, we >++ * recalculate the preferred size correctly. >++ */ >++ tabFolderPage.addControlListener(new ControlAdapter() { >++ public void controlResized(ControlEvent e) { >++ setExampleWidgetSize (); >++ } >++ }); >++ >++ return tabFolderPage; >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup () { >++ orientationButtons = false; >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ readOnlyButton = new Button (styleGroup, SWT.CHECK); >++ readOnlyButton.setText ("SWT.READ_ONLY"); >++ wrapButton = new Button (styleGroup, SWT.CHECK); >++ wrapButton.setText ("SWT.WRAP"); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {spinner1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Selection", "TextLimit", "ToolTipText"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Spinner"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ readOnlyButton.setSelection ((spinner1.getStyle () & SWT.READ_ONLY) != 0); >++ wrapButton.setSelection ((spinner1.getStyle () & SWT.WRAP) != 0); >++ if (!instance.startup) { >++ setWidgetIncrement (); >++ setWidgetPageIncrement (); >++ setWidgetDigits (); >++ } >++ } >++ >++ /** >++ * Gets the default maximum of the "Example" widgets. >++ */ >++ int getDefaultMaximum () { >++ return spinner1.getMaximum(); >++ } >++ >++ /** >++ * Gets the default minimim of the "Example" widgets. >++ */ >++ int getDefaultMinimum () { >++ return spinner1.getMinimum(); >++ } >++ >++ /** >++ * Gets the default selection of the "Example" widgets. >++ */ >++ int getDefaultSelection () { >++ return spinner1.getSelection(); >++ } >++ >++ /** >++ * Gets the default increment of the "Example" widgets. >++ */ >++ int getDefaultIncrement () { >++ return spinner1.getIncrement(); >++ } >++ >++ /** >++ * Gets the default page increment of the "Example" widgets. >++ */ >++ int getDefaultPageIncrement () { >++ return spinner1.getPageIncrement(); >++ } >++ >++ /** >++ * Gets the default digits of the "Example" widgets. >++ */ >++ int getDefaultDigits () { >++ return spinner1.getDigits(); >++ } >++ >++ /** >++ * Sets the increment of the "Example" widgets. >++ */ >++ void setWidgetIncrement () { >++ spinner1.setIncrement (incrementSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the minimim of the "Example" widgets. >++ */ >++ void setWidgetMaximum () { >++ spinner1.setMaximum (maximumSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the minimim of the "Example" widgets. >++ */ >++ void setWidgetMinimum () { >++ spinner1.setMinimum (minimumSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the page increment of the "Example" widgets. >++ */ >++ void setWidgetPageIncrement () { >++ spinner1.setPageIncrement (pageIncrementSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the digits of the "Example" widgets. >++ */ >++ void setWidgetDigits () { >++ spinner1.setDigits (digitsSpinner.getSelection ()); >++ } >++ >++ /** >++ * Sets the selection of the "Example" widgets. >++ */ >++ void setWidgetSelection () { >++ spinner1.setSelection (selectionSpinner.getSelection ()); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/StyledTextTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/StyledTextTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/StyledTextTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/StyledTextTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,413 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2009 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import java.io.*; >++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 StyledTextTab extends ScrollableTab { >++ /* Example widgets and groups that contain them */ >++ StyledText styledText; >++ Group styledTextGroup, styledTextStyleGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button wrapButton, readOnlyButton, fullSelectionButton; >++ >++ /* Buttons for adding StyleRanges to StyledText */ >++ Button boldButton, italicButton, redButton, yellowButton, underlineButton, strikeoutButton; >++ Image boldImage, italicImage, redImage, yellowImage, underlineImage, strikeoutImage; >++ >++ /* Variables for saving state. */ >++ String text; >++ StyleRange[] styleRanges; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ StyledTextTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates a bitmap image. >++ */ >++ Image createBitmapImage (Display display, String name) { >++ InputStream sourceStream = ControlExample.class.getResourceAsStream (name + ".bmp"); >++ InputStream maskStream = ControlExample.class.getResourceAsStream (name + "_mask.bmp"); >++ ImageData source = new ImageData (sourceStream); >++ ImageData mask = new ImageData (maskStream); >++ Image result = new Image (display, source, mask); >++ try { >++ sourceStream.close (); >++ maskStream.close (); >++ } catch (IOException e) { >++ e.printStackTrace (); >++ } >++ return result; >++ } >++ >++ /** >++ * Creates the "Control" widget children. >++ */ >++ void createControlWidgets () { >++ super.createControlWidgets (); >++ >++ /* Add a group for modifying the StyledText widget */ >++ createStyledTextStyleGroup (); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the styled text widget */ >++ styledTextGroup = new Group (exampleGroup, SWT.NONE); >++ styledTextGroup.setLayout (new GridLayout ()); >++ styledTextGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ styledTextGroup.setText ("StyledText"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ 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 (wrapButton.getSelection ()) style |= SWT.WRAP; >++ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (fullSelectionButton.getSelection ()) style |= SWT.FULL_SELECTION; >++ >++ /* Create the example widgets */ >++ styledText = new StyledText (styledTextGroup, style); >++ styledText.setText (ControlExample.getResourceString("Example_string")); >++ styledText.append ("\n"); >++ styledText.append (ControlExample.getResourceString("One_Two_Three")); >++ >++ if (text != null) { >++ styledText.setText(text); >++ text = null; >++ } >++ if (styleRanges != null) { >++ styledText.setStyleRanges(styleRanges); >++ styleRanges = null; >++ } >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup(); >++ >++ /* Create the extra widgets */ >++ wrapButton = new Button (styleGroup, SWT.CHECK); >++ wrapButton.setText ("SWT.WRAP"); >++ readOnlyButton = new Button (styleGroup, SWT.CHECK); >++ readOnlyButton.setText ("SWT.READ_ONLY"); >++ fullSelectionButton = new Button (styleGroup, SWT.CHECK); >++ fullSelectionButton.setText ("SWT.FULL_SELECTION"); >++ } >++ >++ /** >++ * Creates the "StyledText Style" group. >++ */ >++ void createStyledTextStyleGroup () { >++ styledTextStyleGroup = new Group (controlGroup, SWT.NONE); >++ styledTextStyleGroup.setText (ControlExample.getResourceString ("StyledText_Styles")); >++ styledTextStyleGroup.setLayout (new GridLayout(6, false)); >++ GridData data = new GridData (GridData.HORIZONTAL_ALIGN_FILL); >++ data.horizontalSpan = 2; >++ styledTextStyleGroup.setLayoutData (data); >++ >++ /* Get images */ >++ boldImage = createBitmapImage (display, "bold"); >++ italicImage = createBitmapImage (display, "italic"); >++ redImage = createBitmapImage (display, "red"); >++ yellowImage = createBitmapImage (display, "yellow"); >++ underlineImage = createBitmapImage (display, "underline"); >++ strikeoutImage = createBitmapImage (display, "strikeout"); >++ >++ /* Create controls to modify the StyledText */ >++ Label label = new Label (styledTextStyleGroup, SWT.NONE); >++ label.setText (ControlExample.getResourceString ("StyledText_Style_Instructions")); >++ label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 6, 1)); >++ label = new Label (styledTextStyleGroup, SWT.NONE); >++ label.setText (ControlExample.getResourceString ("Bold")); >++ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >++ boldButton = new Button (styledTextStyleGroup, SWT.PUSH); >++ boldButton.setImage (boldImage); >++ label = new Label (styledTextStyleGroup, SWT.NONE); >++ label.setText (ControlExample.getResourceString ("Underline")); >++ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >++ underlineButton = new Button (styledTextStyleGroup, SWT.PUSH); >++ underlineButton.setImage (underlineImage); >++ label = new Label (styledTextStyleGroup, SWT.NONE); >++ label.setText (ControlExample.getResourceString ("Foreground_Style")); >++ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >++ redButton = new Button (styledTextStyleGroup, SWT.PUSH); >++ redButton.setImage (redImage); >++ label = new Label (styledTextStyleGroup, SWT.NONE); >++ label.setText (ControlExample.getResourceString ("Italic")); >++ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >++ italicButton = new Button (styledTextStyleGroup, SWT.PUSH); >++ italicButton.setImage (italicImage); >++ label = new Label (styledTextStyleGroup, SWT.NONE); >++ label.setText (ControlExample.getResourceString ("Strikeout")); >++ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >++ strikeoutButton = new Button (styledTextStyleGroup, SWT.PUSH); >++ strikeoutButton.setImage (strikeoutImage); >++ label = new Label (styledTextStyleGroup, SWT.NONE); >++ label.setText (ControlExample.getResourceString ("Background_Style")); >++ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >++ yellowButton = new Button (styledTextStyleGroup, SWT.PUSH); >++ yellowButton.setImage (yellowImage); >++ SelectionListener styleListener = new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent e) { >++ Point sel = styledText.getSelectionRange(); >++ if ((sel == null) || (sel.y == 0)) return; >++ StyleRange style; >++ for (int i = sel.x; i<sel.x+sel.y; i++) { >++ StyleRange range = styledText.getStyleRangeAtOffset(i); >++ if (range != null) { >++ style = (StyleRange)range.clone(); >++ style.start = i; >++ style.length = 1; >++ } else { >++ style = new StyleRange(i, 1, null, null, SWT.NORMAL); >++ } >++ if (e.widget == boldButton) { >++ style.fontStyle ^= SWT.BOLD; >++ } else if (e.widget == italicButton) { >++ style.fontStyle ^= SWT.ITALIC; >++ } else if (e.widget == underlineButton) { >++ style.underline = !style.underline; >++ } else if (e.widget == strikeoutButton) { >++ style.strikeout = !style.strikeout; >++ } >++ styledText.setStyleRange(style); >++ } >++ styledText.setSelectionRange(sel.x + sel.y, 0); >++ } >++ }; >++ SelectionListener colorListener = new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent e) { >++ Point sel = styledText.getSelectionRange(); >++ if ((sel == null) || (sel.y == 0)) return; >++ Color fg = null, bg = null; >++ if (e.widget == redButton) { >++ fg = display.getSystemColor (SWT.COLOR_RED); >++ } else if (e.widget == yellowButton) { >++ bg = display.getSystemColor (SWT.COLOR_YELLOW); >++ } >++ StyleRange style; >++ for (int i = sel.x; i<sel.x+sel.y; i++) { >++ StyleRange range = styledText.getStyleRangeAtOffset(i); >++ if (range != null) { >++ style = (StyleRange)range.clone(); >++ style.start = i; >++ style.length = 1; >++ style.foreground = style.foreground != null ? null : fg; >++ style.background = style.background != null ? null : bg; >++ } else { >++ style = new StyleRange (i, 1, fg, bg, SWT.NORMAL); >++ } >++ styledText.setStyleRange(style); >++ } >++ styledText.setSelectionRange(sel.x + sel.y, 0); >++ } >++ }; >++ boldButton.addSelectionListener(styleListener); >++ italicButton.addSelectionListener(styleListener); >++ underlineButton.addSelectionListener(styleListener); >++ strikeoutButton.addSelectionListener(styleListener); >++ redButton.addSelectionListener(colorListener); >++ yellowButton.addSelectionListener(colorListener); >++ yellowButton.addDisposeListener(new DisposeListener () { >++ public void widgetDisposed (DisposeEvent e) { >++ boldImage.dispose(); >++ italicImage.dispose(); >++ redImage.dispose(); >++ yellowImage.dispose(); >++ underlineImage.dispose(); >++ strikeoutImage.dispose(); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the tab folder page. >++ * >++ * @param tabFolder org.eclipse.swt.widgets.TabFolder >++ * @return the new page for the tab folder >++ */ >++ Composite createTabFolderPage (TabFolder tabFolder) { >++ super.createTabFolderPage (tabFolder); >++ >++ /* >++ * Add a resize listener to the tabFolderPage so that >++ * if the user types into the example widget to change >++ * its preferred size, and then resizes the shell, we >++ * recalculate the preferred size correctly. >++ */ >++ tabFolderPage.addControlListener(new ControlAdapter() { >++ public void controlResized(ControlEvent e) { >++ setExampleWidgetSize (); >++ } >++ }); >++ >++ return tabFolderPage; >++ } >++ >++ /** >++ * Disposes the "Example" widgets. >++ */ >++ void disposeExampleWidgets () { >++ /* store the state of the styledText if applicable */ >++ if (styledText != null) { >++ styleRanges = styledText.getStyleRanges(); >++ text = styledText.getText(); >++ } >++ super.disposeExampleWidgets(); >++ } >++ >++ /** >++ * Gets the list of custom event names. >++ * >++ * @return an array containing custom event names >++ */ >++ String [] getCustomEventNames () { >++ return new String [] { >++ "ExtendedModifyListener", "BidiSegmentListener", "LineBackgroundListener", >++ "LineStyleListener", "PaintObjectListener", "TextChangeListener", >++ "VerifyKeyListener", "WordMovementListener"}; >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {styledText}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Alignment", "BlockSelection", "BottomMargin", "CaretOffset", "DoubleClickEnabled", "Editable", "HorizontalIndex", "HorizontalPixel", "Indent", "Justify", "LeftMargin", "LineSpacing", "Orientation", "RightMargin", "Selection", "Tabs", "Text", "TextLimit", "ToolTipText", "TopIndex", "TopMargin", "TopPixel", "WordWrap"}; >++ } >++ >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "StyledText"; >++ } >++ >++ /** >++ * Hooks the custom listener specified by eventName. >++ */ >++ void hookCustomListener (final String eventName) { >++ if (eventName == "ExtendedModifyListener") { >++ styledText.addExtendedModifyListener (new ExtendedModifyListener() { >++ public void modifyText(ExtendedModifyEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "BidiSegmentListener") { >++ styledText.addBidiSegmentListener (new BidiSegmentListener() { >++ public void lineGetSegments(BidiSegmentEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "LineBackgroundListener") { >++ styledText.addLineBackgroundListener (new LineBackgroundListener() { >++ public void lineGetBackground(LineBackgroundEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "LineStyleListener") { >++ styledText.addLineStyleListener (new LineStyleListener() { >++ public void lineGetStyle(LineStyleEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "PaintObjectListener") { >++ styledText.addPaintObjectListener (new PaintObjectListener() { >++ public void paintObject(PaintObjectEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "TextChangeListener") { >++ styledText.getContent().addTextChangeListener (new TextChangeListener() { >++ public void textChanged(TextChangedEvent event) { >++ log (eventName + ".textChanged", event); >++ } >++ public void textChanging(TextChangingEvent event) { >++ log (eventName + ".textChanging", event); >++ } >++ public void textSet(TextChangedEvent event) { >++ log (eventName + ".textSet", event); >++ } >++ }); >++ } >++ if (eventName == "VerifyKeyListener") { >++ styledText.addVerifyKeyListener (new VerifyKeyListener() { >++ public void verifyKey(VerifyEvent event) { >++ log (eventName, event); >++ } >++ }); >++ } >++ if (eventName == "WordMovementListener") { >++ styledText.addWordMovementListener (new MovementListener() { >++ public void getNextOffset(MovementEvent event) { >++ log (eventName + ".getNextOffset", event); >++ } >++ public void getPreviousOffset(MovementEvent event) { >++ log (eventName + ".getPreviousOffset", event); >++ } >++ }); >++ } >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ wrapButton.setSelection ((styledText.getStyle () & SWT.WRAP) != 0); >++ readOnlyButton.setSelection ((styledText.getStyle () & SWT.READ_ONLY) != 0); >++ fullSelectionButton.setSelection ((styledText.getStyle () & SWT.FULL_SELECTION) != 0); >++ horizontalButton.setEnabled ((styledText.getStyle () & SWT.MULTI) != 0); >++ verticalButton.setEnabled ((styledText.getStyle () & SWT.MULTI) != 0); >++ wrapButton.setEnabled ((styledText.getStyle () & SWT.MULTI) != 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/Tab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/Tab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/Tab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/Tab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,1831 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++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>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", "Other" and "Size" group. Subclasses >++ * can override these defaults to augment a group or stop >++ * a group from being created. >++ */ >++abstract class Tab { >++ Shell shell; >++ Display display; >++ >++ /* Common control buttons */ >++ Button borderButton, enabledButton, visibleButton, backgroundImageButton, popupMenuButton; >++ Button preferredButton, tooSmallButton, smallButton, largeButton, fillHButton, fillVButton; >++ >++ /* Common groups and composites */ >++ Composite tabFolderPage; >++ Group exampleGroup, controlGroup, listenersGroup, otherGroup, sizeGroup, styleGroup, colorGroup, backgroundModeGroup; >++ >++ /* Controlling instance */ >++ final ControlExample instance; >++ >++ /* 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; >++ >++ /* Right-to-left support */ >++ static final boolean RTL_SUPPORT_ENABLE = "win32".equals(SWT.getPlatform()) || "gtk".equals(SWT.getPlatform()); >++ Group orientationGroup; >++ Button rtlButtonRecreate, rtlButtonSet, ltrButtonRecreate, ltrButtonSet, defaultOrietationButton; >++ >++ /* Controls and resources for the "Colors & Fonts" group */ >++ static final int IMAGE_SIZE = 12; >++ static final int FOREGROUND_COLOR = 0; >++ static final int BACKGROUND_COLOR = 1; >++ static final int FONT = 2; >++ Table colorAndFontTable; >++ ColorDialog colorDialog; >++ FontDialog fontDialog; >++ Color foregroundColor, backgroundColor; >++ Font font; >++ >++ /* Controls and resources for the "Background Mode" group */ >++ Combo backgroundModeCombo; >++ Button backgroundModeImageButton, backgroundModeColorButton; >++ >++ boolean samplePopup = false; >++ >++ /* Set/Get API controls */ >++ Combo nameCombo; >++ Label returnTypeLabel; >++ Button getButton, setButton; >++ Text setText, getText; >++ Shell setGetDialog; >++ >++ /* Event logging variables and controls */ >++ Text eventConsole; >++ boolean logging = false; >++ boolean [] eventsFilter; >++ int setFieldsMask = 0; >++ Event setFieldsEvent = new Event (); >++ boolean ignore = false; >++ >++ /* Event logging constants */ >++ static final int DOIT = 0x0100; >++ static final int DETAIL = 0x0200; >++ static final int TEXT = 0x0400; >++ static final int X = 0x0800; >++ static final int Y = 0x1000; >++ static final int WIDTH = 0x2000; >++ static final int HEIGHT = 0x4000; >++ >++ static final int DETAIL_IME = 0; >++ static final int DETAIL_ERASE_ITEM = 1; >++ static final int DETAIL_TRAVERSE = 2; >++ >++ static class EventInfo { >++ String name; >++ int type; >++ int settableFields; >++ int setFields; >++ Event event; >++ EventInfo (String name, int type, int settableFields, int setFields, Event event) { >++ this.name = name; >++ this.type = type; >++ this.settableFields = settableFields; >++ this.setFields = setFields; >++ this.event = event; >++ } >++ } >++ >++ final EventInfo [] EVENT_INFO = { >++ new EventInfo ("Activate", SWT.Activate, 0, 0, new Event()), >++ new EventInfo ("Arm", SWT.Arm, 0, 0, new Event()), >++ new EventInfo ("Close", SWT.Close, DOIT, 0, new Event()), >++ new EventInfo ("Collapse", SWT.Collapse, 0, 0, new Event()), >++ new EventInfo ("Deactivate", SWT.Deactivate, 0, 0, new Event()), >++ new EventInfo ("DefaultSelection", SWT.DefaultSelection, 0, 0, new Event()), >++ new EventInfo ("Deiconify", SWT.Deiconify, 0, 0, new Event()), >++ new EventInfo ("Dispose", SWT.Dispose, 0, 0, new Event()), >++ new EventInfo ("DragDetect", SWT.DragDetect, 0, 0, new Event()), >++ new EventInfo ("EraseItem", SWT.EraseItem, DETAIL | DETAIL_ERASE_ITEM, 0, new Event()), >++ new EventInfo ("Expand", SWT.Expand, 0, 0, new Event()), >++ new EventInfo ("FocusIn", SWT.FocusIn, 0, 0, new Event()), >++ new EventInfo ("FocusOut", SWT.FocusOut, 0, 0, new Event()), >++ new EventInfo ("HardKeyDown", SWT.HardKeyDown, 0, 0, new Event()), >++ new EventInfo ("HardKeyUp", SWT.HardKeyUp, 0, 0, new Event()), >++ new EventInfo ("Help", SWT.Help, 0, 0, new Event()), >++ new EventInfo ("Hide", SWT.Hide, 0, 0, new Event()), >++ new EventInfo ("Iconify", SWT.Iconify, 0, 0, new Event()), >++ new EventInfo ("KeyDown", SWT.KeyDown, DOIT, 0, new Event()), >++ new EventInfo ("KeyUp", SWT.KeyUp, DOIT, 0, new Event()), >++ new EventInfo ("MeasureItem", SWT.MeasureItem, 0, 0, new Event()), >++ new EventInfo ("MenuDetect", SWT.MenuDetect, X | Y | DOIT, 0, new Event()), >++ new EventInfo ("Modify", SWT.Modify, 0, 0, new Event()), >++ new EventInfo ("MouseDoubleClick", SWT.MouseDoubleClick, 0, 0, new Event()), >++ new EventInfo ("MouseDown", SWT.MouseDown, 0, 0, new Event()), >++ new EventInfo ("MouseEnter", SWT.MouseEnter, 0, 0, new Event()), >++ new EventInfo ("MouseExit", SWT.MouseExit, 0, 0, new Event()), >++ new EventInfo ("MouseHover", SWT.MouseHover, 0, 0, new Event()), >++ new EventInfo ("MouseMove", SWT.MouseMove, 0, 0, new Event()), >++ new EventInfo ("MouseUp", SWT.MouseUp, 0, 0, new Event()), >++ new EventInfo ("MouseWheel", SWT.MouseWheel, 0, 0, new Event()), >++ new EventInfo ("Move", SWT.Move, 0, 0, new Event()), >++ new EventInfo ("Paint", SWT.Paint, 0, 0, new Event()), >++ new EventInfo ("PaintItem", SWT.PaintItem, 0, 0, new Event()), >++ new EventInfo ("Resize", SWT.Resize, 0, 0, new Event()), >++ new EventInfo ("Selection", SWT.Selection, X | Y | DOIT, 0, new Event()), // sash >++ new EventInfo ("SetData", SWT.SetData, 0, 0, new Event()), >++// new EventInfo ("Settings", SWT.Settings, 0, 0, new Event()), // note: this event only goes to Display >++ new EventInfo ("Show", SWT.Show, 0, 0, new Event()), >++ new EventInfo ("Traverse", SWT.Traverse, DETAIL | DETAIL_TRAVERSE | DOIT, 0, new Event()), >++ new EventInfo ("Verify", SWT.Verify, TEXT | DOIT, 0, new Event()), >++ new EventInfo ("ImeComposition", SWT.ImeComposition, DETAIL | DETAIL_IME | TEXT | DOIT, 0, new Event()), >++ }; >++ >++ static final String [][] DETAIL_CONSTANTS = { >++ { // DETAIL_IME = 0 >++ "SWT.COMPOSITION_CHANGED", >++ "SWT.COMPOSITION_OFFSET", >++ "SWT.COMPOSITION_SELECTION", >++ }, >++ { // DETAIL_ERASE_ITEM = 1 >++ "SWT.SELECTED", >++ "SWT.FOCUSED", >++ "SWT.BACKGROUND", >++ "SWT.FOREGROUND", >++ "SWT.HOT", >++ }, >++ { // DETAIL_TRAVERSE = 2 >++ "SWT.TRAVERSE_NONE", >++ "SWT.TRAVERSE_ESCAPE", >++ "SWT.TRAVERSE_RETURN", >++ "SWT.TRAVERSE_TAB_PREVIOUS", >++ "SWT.TRAVERSE_TAB_NEXT", >++ "SWT.TRAVERSE_ARROW_PREVIOUS", >++ "SWT.TRAVERSE_ARROW_NEXT", >++ "SWT.TRAVERSE_MNEMONIC", >++ "SWT.TRAVERSE_PAGE_PREVIOUS", >++ "SWT.TRAVERSE_PAGE_NEXT", >++ }, >++ }; >++ >++ static final Object [] DETAIL_VALUES = { >++ "SWT.COMPOSITION_CHANGED", new Integer(SWT.COMPOSITION_CHANGED), >++ "SWT.COMPOSITION_OFFSET", new Integer(SWT.COMPOSITION_OFFSET), >++ "SWT.COMPOSITION_SELECTION", new Integer(SWT.COMPOSITION_SELECTION), >++ "SWT.SELECTED", new Integer(SWT.SELECTED), >++ "SWT.FOCUSED", new Integer(SWT.FOCUSED), >++ "SWT.BACKGROUND", new Integer(SWT.BACKGROUND), >++ "SWT.FOREGROUND", new Integer(SWT.FOREGROUND), >++ "SWT.HOT", new Integer(SWT.HOT), >++ "SWT.TRAVERSE_NONE", new Integer(SWT.TRAVERSE_NONE), >++ "SWT.TRAVERSE_ESCAPE", new Integer(SWT.TRAVERSE_ESCAPE), >++ "SWT.TRAVERSE_RETURN", new Integer(SWT.TRAVERSE_RETURN), >++ "SWT.TRAVERSE_TAB_PREVIOUS", new Integer(SWT.TRAVERSE_TAB_PREVIOUS), >++ "SWT.TRAVERSE_TAB_NEXT", new Integer(SWT.TRAVERSE_TAB_NEXT), >++ "SWT.TRAVERSE_ARROW_PREVIOUS", new Integer(SWT.TRAVERSE_ARROW_PREVIOUS), >++ "SWT.TRAVERSE_ARROW_NEXT", new Integer(SWT.TRAVERSE_ARROW_NEXT), >++ "SWT.TRAVERSE_MNEMONIC", new Integer(SWT.TRAVERSE_MNEMONIC), >++ "SWT.TRAVERSE_PAGE_PREVIOUS", new Integer(SWT.TRAVERSE_PAGE_PREVIOUS), >++ "SWT.TRAVERSE_PAGE_NEXT", new Integer(SWT.TRAVERSE_PAGE_NEXT), >++ }; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ Tab(ControlExample instance) { >++ this.instance = instance; >++ } >++ >++ /** >++ * 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 >++ * right half of each example tab. It consists of the >++ * "Style" group, the "Other" group and the "Size" group. >++ */ >++ controlGroup = new Group (tabFolderPage, SWT.NONE); >++ controlGroup.setLayout (new GridLayout (2, true)); >++ controlGroup.setLayoutData (new GridData(SWT.FILL, SWT.FILL, false, false)); >++ controlGroup.setText (ControlExample.getResourceString("Parameters")); >++ >++ /* Create individual groups inside the "Control" group */ >++ createStyleGroup (); >++ createOtherGroup (); >++ createSetGetGroup(); >++ createSizeGroup (); >++ createColorAndFontGroup (); >++ if (rtlSupport()) { >++ createOrientationGroup (); >++ } >++// createBackgroundModeGroup (); >++ >++ /* >++ * 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 current 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); >++ } else { >++ if (children [i] instanceof Composite) { >++ /* Look down one more level of children in the style group. */ >++ Composite composite = (Composite) children [i]; >++ Control [] grandchildren = composite.getChildren (); >++ for (int j=0; j<grandchildren.length; j++) { >++ if (grandchildren [j] instanceof Button) { >++ Button button = (Button) grandchildren [j]; >++ button.addSelectionListener (selectionListener); >++ } >++ } >++ } >++ } >++ } >++ if (rtlSupport()) { >++ rtlButtonRecreate.addSelectionListener (selectionListener); >++ ltrButtonRecreate.addSelectionListener (selectionListener); >++ defaultOrietationButton.addSelectionListener (selectionListener); >++ >++ SelectionListener bidiListener = new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ Control [] controls = getExampleControls (); >++ int flag = event.widget == rtlButtonSet ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >++ for (int i=0; i<controls.length; i++) { >++ controls [i].setOrientation(flag); >++ //controls [i].setTextDirectionRTL(); >++ } >++ } >++ }; >++ rtlButtonSet.addSelectionListener (bidiListener); >++ ltrButtonSet.addSelectionListener (bidiListener); >++ } >++ } >++ >++ /** >++ * Append the Set/Get API controls to the "Other" group. >++ */ >++ void createSetGetGroup() { >++ /* >++ * Create the button to access set/get API functionality. >++ */ >++ final String [] methodNames = getMethodNames (); >++ if (methodNames != null) { >++ final Button setGetButton = new Button (otherGroup, SWT.PUSH); >++ setGetButton.setText (ControlExample.getResourceString ("Set_Get")); >++ setGetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >++ setGetButton.addSelectionListener (new SelectionAdapter() { >++ public void widgetSelected (SelectionEvent e) { >++ if (getExampleWidgets().length > 0) { >++ if (setGetDialog == null) { >++ setGetDialog = createSetGetDialog(methodNames); >++ } >++ Point pt = setGetButton.getLocation(); >++ pt = display.map(setGetButton.getParent(), null, pt); >++ setGetDialog.setLocation(pt.x, pt.y); >++ setGetDialog.open(); >++ } >++ } >++ }); >++ } >++ } >++ >++ /** >++ * Creates the "Control" widget children. >++ * Subclasses override this method to augment >++ * the standard controls created in the "Style", >++ * "Other" and "Size" groups. >++ */ >++ void createControlWidgets () { >++ } >++ >++ /** >++ * Creates the "Colors and Fonts" group. This is typically >++ * a child of the "Control" group. Subclasses override >++ * this method to customize color and font settings. >++ */ >++ void createColorAndFontGroup () { >++ /* Create the group. */ >++ colorGroup = new Group(controlGroup, SWT.NONE); >++ colorGroup.setLayout (new GridLayout (2, true)); >++ colorGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >++ colorGroup.setText (ControlExample.getResourceString ("Colors")); >++ colorAndFontTable = new Table(colorGroup, SWT.BORDER | SWT.V_SCROLL); >++ colorAndFontTable.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1)); >++ TableItem item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Foreground_Color")); >++ colorAndFontTable.setSelection(0); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Background_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Font")); >++ Button changeButton = new Button (colorGroup, SWT.PUSH); >++ changeButton.setText(ControlExample.getResourceString("Change")); >++ changeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >++ Button defaultsButton = new Button (colorGroup, SWT.PUSH); >++ defaultsButton.setText(ControlExample.getResourceString("Defaults")); >++ defaultsButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >++ >++ /* Add listeners to set/reset colors and fonts. */ >++ colorDialog = new ColorDialog (shell); >++ fontDialog = new FontDialog (shell); >++ colorAndFontTable.addSelectionListener(new SelectionAdapter() { >++ public void widgetDefaultSelected(SelectionEvent event) { >++ changeFontOrColor (colorAndFontTable.getSelectionIndex()); >++ } >++ }); >++ changeButton.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent event) { >++ changeFontOrColor (colorAndFontTable.getSelectionIndex()); >++ } >++ }); >++ defaultsButton.addSelectionListener(new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent e) { >++ resetColorsAndFonts (); >++ } >++ }); >++ shell.addDisposeListener(new DisposeListener() { >++ public void widgetDisposed(DisposeEvent event) { >++ if (foregroundColor != null) foregroundColor.dispose(); >++ if (backgroundColor != null) backgroundColor.dispose(); >++ if (font != null) font.dispose(); >++ foregroundColor = null; >++ backgroundColor = null; >++ font = null; >++ if (colorAndFontTable != null && !colorAndFontTable.isDisposed()) { >++ TableItem [] items = colorAndFontTable.getItems(); >++ for (int i = 0; i < items.length; i++) { >++ Image image = items[i].getImage(); >++ if (image != null) image.dispose(); >++ } >++ } >++ } >++ }); >++ } >++ >++ void changeFontOrColor(int index) { >++ switch (index) { >++ case FOREGROUND_COLOR: { >++ Color oldColor = foregroundColor; >++ if (oldColor == null) { >++ Control [] controls = getExampleControls (); >++ if (controls.length > 0) oldColor = controls [0].getForeground (); >++ } >++ if (oldColor != null) colorDialog.setRGB(oldColor.getRGB()); // seed dialog with current color >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = foregroundColor; // save old foreground color to dispose when done >++ foregroundColor = new Color (display, rgb); >++ setExampleWidgetForeground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case BACKGROUND_COLOR: { >++ Color oldColor = backgroundColor; >++ if (oldColor == null) { >++ Control [] controls = getExampleControls (); >++ if (controls.length > 0) oldColor = controls [0].getBackground (); // seed dialog with current color >++ } >++ if (oldColor != null) colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = backgroundColor; // save old background color to dispose when done >++ backgroundColor = new Color (display, rgb); >++ setExampleWidgetBackground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case FONT: { >++ Font oldFont = font; >++ if (oldFont == null) { >++ Control [] controls = getExampleControls (); >++ if (controls.length > 0) oldFont = controls [0].getFont (); >++ } >++ if (oldFont != null) fontDialog.setFontList(oldFont.getFontData()); // seed dialog with current font >++ FontData fontData = fontDialog.open (); >++ if (fontData == null) return; >++ oldFont = font; // dispose old font when done >++ font = new Font (display, fontData); >++ setExampleWidgetFont (); >++ setExampleWidgetSize (); >++ if (oldFont != null) oldFont.dispose (); >++ } >++ break; >++ } >++ } >++ >++ /** >++ * Creates the "Other" group. This is typically >++ * a child of the "Control" group. >++ */ >++ void createOtherGroup () { >++ /* Create the group */ >++ otherGroup = new Group (controlGroup, SWT.NONE); >++ otherGroup.setLayout (new GridLayout ()); >++ otherGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >++ otherGroup.setText (ControlExample.getResourceString("Other")); >++ >++ /* Create the controls */ >++ enabledButton = new Button(otherGroup, SWT.CHECK); >++ enabledButton.setText(ControlExample.getResourceString("Enabled")); >++ visibleButton = new Button(otherGroup, SWT.CHECK); >++ visibleButton.setText(ControlExample.getResourceString("Visible")); >++ backgroundImageButton = new Button(otherGroup, SWT.CHECK); >++ backgroundImageButton.setText(ControlExample.getResourceString("BackgroundImage")); >++ popupMenuButton = new Button(otherGroup, SWT.CHECK); >++ popupMenuButton.setText(ControlExample.getResourceString("PopupMenu")); >++ >++ /* Add the listeners */ >++ enabledButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleWidgetEnabled (); >++ } >++ }); >++ visibleButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleWidgetVisibility (); >++ } >++ }); >++ backgroundImageButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleWidgetBackgroundImage (); >++ } >++ }); >++ popupMenuButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleWidgetPopupMenu (); >++ } >++ }); >++ >++ /* Set the default state */ >++ enabledButton.setSelection(true); >++ visibleButton.setSelection(true); >++ backgroundImageButton.setSelection(false); >++ popupMenuButton.setSelection(false); >++ } >++ >++ /** >++ * Creates the "Background Mode" group. >++ */ >++ void createBackgroundModeGroup () { >++ /* Create the group */ >++ backgroundModeGroup = new Group (controlGroup, SWT.NONE); >++ backgroundModeGroup.setLayout (new GridLayout ()); >++ backgroundModeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >++ backgroundModeGroup.setText (ControlExample.getResourceString("Background_Mode")); >++ >++ /* Create the controls */ >++ backgroundModeCombo = new Combo(backgroundModeGroup, SWT.READ_ONLY); >++ backgroundModeCombo.setItems(new String[] {"SWT.INHERIT_NONE", "SWT.INHERIT_DEFAULT", "SWT.INHERIT_FORCE"}); >++ backgroundModeImageButton = new Button(backgroundModeGroup, SWT.CHECK); >++ backgroundModeImageButton.setText(ControlExample.getResourceString("BackgroundImage")); >++ backgroundModeColorButton = new Button(backgroundModeGroup, SWT.CHECK); >++ backgroundModeColorButton.setText(ControlExample.getResourceString("BackgroundColor")); >++ >++ /* Add the listeners */ >++ backgroundModeCombo.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleGroupBackgroundMode (); >++ } >++ }); >++ backgroundModeImageButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleGroupBackgroundImage (); >++ } >++ }); >++ backgroundModeColorButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleGroupBackgroundColor (); >++ } >++ }); >++ >++ /* Set the default state */ >++ backgroundModeCombo.setText(backgroundModeCombo.getItem(0)); >++ backgroundModeImageButton.setSelection(false); >++ backgroundModeColorButton.setSelection(false); >++ } >++ >++ void createEditEventDialog(Shell parent, int x, int y, final int index) { >++ final Shell dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); >++ dialog.setLayout(new GridLayout()); >++ dialog.setText(ControlExample.getResourceString ("Edit_Event")); >++ Label label = new Label (dialog, SWT.NONE); >++ label.setText (ControlExample.getResourceString ("Edit_Event_Fields", new String [] {EVENT_INFO[index].name})); >++ >++ Group group = new Group (dialog, SWT.NONE); >++ group.setLayout(new GridLayout(2, false)); >++ group.setLayoutData(new GridData (SWT.FILL, SWT.FILL, true, true)); >++ >++ final int fields = EVENT_INFO[index].settableFields; >++ final int eventType = EVENT_INFO[index].type; >++ setFieldsMask = EVENT_INFO[index].setFields; >++ setFieldsEvent = EVENT_INFO[index].event; >++ >++ if ((fields & DOIT) != 0) { >++ new Label (group, SWT.NONE).setText ("doit"); >++ final Combo doitCombo = new Combo (group, SWT.READ_ONLY); >++ doitCombo.setItems (new String [] {"", "true", "false"}); >++ if ((setFieldsMask & DOIT) != 0) doitCombo.setText(Boolean.toString(setFieldsEvent.doit)); >++ doitCombo.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ doitCombo.addSelectionListener(new SelectionAdapter () { >++ public void widgetSelected(SelectionEvent e) { >++ String newValue = doitCombo.getText(); >++ if (newValue.length() == 0) { >++ setFieldsMask &= ~DOIT; >++ } else { >++ setFieldsEvent.type = eventType; >++ setFieldsEvent.doit = newValue.equals("true"); >++ setFieldsMask |= DOIT; >++ } >++ } >++ }); >++ } >++ >++ if ((fields & DETAIL) != 0) { >++ new Label (group, SWT.NONE).setText ("detail"); >++ int detailType = fields & 0xFF; >++ final Combo detailCombo = new Combo (group, SWT.READ_ONLY); >++ detailCombo.setItems (DETAIL_CONSTANTS[detailType]); >++ detailCombo.add ("", 0); >++ detailCombo.setVisibleItemCount(detailCombo.getItemCount()); >++ if ((setFieldsMask & DETAIL) != 0) detailCombo.setText (DETAIL_CONSTANTS[detailType][setFieldsEvent.detail]); >++ detailCombo.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ detailCombo.addSelectionListener(new SelectionAdapter () { >++ public void widgetSelected(SelectionEvent e) { >++ String newValue = detailCombo.getText(); >++ if (newValue.length() == 0) { >++ setFieldsMask &= ~DETAIL; >++ } else { >++ setFieldsEvent.type = eventType; >++ for (int i = 0; i < DETAIL_VALUES.length; i += 2) { >++ if (newValue.equals (DETAIL_VALUES [i])) { >++ setFieldsEvent.detail = ((Integer) DETAIL_VALUES [i + 1]).intValue(); >++ break; >++ } >++ } >++ setFieldsMask |= DETAIL; >++ } >++ } >++ }); >++ } >++ >++ if ((fields & TEXT) != 0) { >++ new Label (group, SWT.NONE).setText ("text"); >++ final Text textText = new Text (group, SWT.BORDER); >++ if ((setFieldsMask & TEXT) != 0) textText.setText(setFieldsEvent.text); >++ textText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ textText.addModifyListener(new ModifyListener () { >++ public void modifyText(ModifyEvent e) { >++ String newValue = textText.getText(); >++ if (newValue.length() == 0) { >++ setFieldsMask &= ~TEXT; >++ } else { >++ setFieldsEvent.type = eventType; >++ setFieldsEvent.text = newValue; >++ setFieldsMask |= TEXT; >++ } >++ } >++ }); >++ } >++ >++ if ((fields & X) != 0) { >++ new Label (group, SWT.NONE).setText ("x"); >++ final Text xText = new Text (group, SWT.BORDER); >++ if ((setFieldsMask & X) != 0) xText.setText(Integer.toString(setFieldsEvent.x)); >++ xText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ xText.addModifyListener(new ModifyListener () { >++ public void modifyText(ModifyEvent e) { >++ String newValue = xText.getText (); >++ try { >++ int newIntValue = Integer.parseInt (newValue); >++ setFieldsEvent.type = eventType; >++ setFieldsEvent.x = newIntValue; >++ setFieldsMask |= X; >++ } catch (NumberFormatException ex) { >++ setFieldsMask &= ~X; >++ } >++ } >++ }); >++ } >++ >++ if ((fields & Y) != 0) { >++ new Label (group, SWT.NONE).setText ("y"); >++ final Text yText = new Text (group, SWT.BORDER); >++ if ((setFieldsMask & Y) != 0) yText.setText(Integer.toString(setFieldsEvent.y)); >++ yText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ yText.addModifyListener(new ModifyListener () { >++ public void modifyText(ModifyEvent e) { >++ String newValue = yText.getText (); >++ try { >++ int newIntValue = Integer.parseInt (newValue); >++ setFieldsEvent.type = eventType; >++ setFieldsEvent.y = newIntValue; >++ setFieldsMask |= Y; >++ } catch (NumberFormatException ex) { >++ setFieldsMask &= ~Y; >++ } >++ } >++ }); >++ } >++ >++ if ((fields & WIDTH) != 0) { >++ new Label (group, SWT.NONE).setText ("width"); >++ final Text widthText = new Text (group, SWT.BORDER); >++ if ((setFieldsMask & WIDTH) != 0) widthText.setText(Integer.toString(setFieldsEvent.width)); >++ widthText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ widthText.addModifyListener(new ModifyListener () { >++ public void modifyText(ModifyEvent e) { >++ String newValue = widthText.getText (); >++ try { >++ int newIntValue = Integer.parseInt (newValue); >++ setFieldsEvent.type = eventType; >++ setFieldsEvent.width = newIntValue; >++ setFieldsMask |= WIDTH; >++ } catch (NumberFormatException ex) { >++ setFieldsMask &= ~WIDTH; >++ } >++ } >++ }); >++ } >++ >++ if ((fields & HEIGHT) != 0) { >++ new Label (group, SWT.NONE).setText ("height"); >++ final Text heightText = new Text (group, SWT.BORDER); >++ if ((setFieldsMask & HEIGHT) != 0) heightText.setText(Integer.toString(setFieldsEvent.height)); >++ heightText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >++ heightText.addModifyListener(new ModifyListener () { >++ public void modifyText(ModifyEvent e) { >++ String newValue = heightText.getText (); >++ try { >++ int newIntValue = Integer.parseInt (newValue); >++ setFieldsEvent.type = eventType; >++ setFieldsEvent.height = newIntValue; >++ setFieldsMask |= HEIGHT; >++ } catch (NumberFormatException ex) { >++ setFieldsMask &= ~HEIGHT; >++ } >++ } >++ }); >++ } >++ >++ Button ok = new Button (dialog, SWT.PUSH); >++ ok.setText (ControlExample.getResourceString("OK")); >++ GridData data = new GridData (70, SWT.DEFAULT); >++ data.horizontalAlignment = SWT.RIGHT; >++ ok.setLayoutData (data); >++ ok.addSelectionListener (new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ EVENT_INFO[index].setFields = setFieldsMask; >++ EVENT_INFO[index].event = setFieldsEvent; >++ dialog.dispose(); >++ } >++ }); >++ >++ dialog.setDefaultButton(ok); >++ dialog.pack(); >++ dialog.setLocation(x, y); >++ dialog.open(); >++ } >++ >++ /** >++ * Create the event console popup menu. >++ */ >++ void createEventConsolePopup () { >++ Menu popup = new Menu (shell, SWT.POP_UP); >++ eventConsole.setMenu (popup); >++ >++ MenuItem cut = new MenuItem (popup, SWT.PUSH); >++ cut.setText (ControlExample.getResourceString("MenuItem_Cut")); >++ cut.addListener (SWT.Selection, new Listener () { >++ public void handleEvent (Event event) { >++ eventConsole.cut (); >++ } >++ }); >++ MenuItem copy = new MenuItem (popup, SWT.PUSH); >++ copy.setText (ControlExample.getResourceString("MenuItem_Copy")); >++ copy.addListener (SWT.Selection, new Listener () { >++ public void handleEvent (Event event) { >++ eventConsole.copy (); >++ } >++ }); >++ MenuItem paste = new MenuItem (popup, SWT.PUSH); >++ paste.setText (ControlExample.getResourceString("MenuItem_Paste")); >++ paste.addListener (SWT.Selection, new Listener () { >++ public void handleEvent (Event event) { >++ eventConsole.paste (); >++ } >++ }); >++ new MenuItem (popup, SWT.SEPARATOR); >++ MenuItem selectAll = new MenuItem (popup, SWT.PUSH); >++ selectAll.setText(ControlExample.getResourceString("MenuItem_SelectAll")); >++ selectAll.addListener (SWT.Selection, new Listener () { >++ public void handleEvent (Event event) { >++ eventConsole.selectAll (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Example" group. The "Example" group >++ * is typically the left hand column in the tab. >++ */ >++ void createExampleGroup () { >++ exampleGroup = new Group (tabFolderPage, SWT.NONE); >++ exampleGroup.setLayout (new GridLayout ()); >++ exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ } >++ >++ /** >++ * Creates the "Example" widget children of the "Example" group. >++ * Subclasses override this method to create the particular >++ * example control. >++ */ >++ void createExampleWidgets () { >++ /* Do nothing */ >++ } >++ >++ /** >++ * Creates and opens the "Listener selection" dialog. >++ */ >++ void createListenerSelectionDialog () { >++ final Shell dialog = new Shell (shell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); >++ dialog.setText (ControlExample.getResourceString ("Select_Listeners")); >++ dialog.setLayout (new GridLayout (2, false)); >++ final Table table = new Table (dialog, SWT.BORDER | SWT.V_SCROLL | SWT.CHECK); >++ GridData data = new GridData(GridData.FILL_BOTH); >++ data.verticalSpan = 3; >++ table.setLayoutData(data); >++ for (int i = 0; i < EVENT_INFO.length; i++) { >++ TableItem item = new TableItem (table, SWT.NONE); >++ item.setText (EVENT_INFO[i].name); >++ item.setChecked (eventsFilter[i]); >++ } >++ final String [] customNames = getCustomEventNames (); >++ for (int i = 0; i < customNames.length; i++) { >++ TableItem item = new TableItem (table, SWT.NONE); >++ item.setText (customNames[i]); >++ item.setChecked (eventsFilter[EVENT_INFO.length + i]); >++ } >++ Button selectAll = new Button (dialog, SWT.PUSH); >++ selectAll.setText(ControlExample.getResourceString ("Select_All")); >++ selectAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >++ selectAll.addSelectionListener (new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ TableItem [] items = table.getItems(); >++ for (int i = 0; i < EVENT_INFO.length; i++) { >++ items[i].setChecked(true); >++ } >++ for (int i = 0; i < customNames.length; i++) { >++ items[EVENT_INFO.length + i].setChecked(true); >++ } >++ } >++ }); >++ Button deselectAll = new Button (dialog, SWT.PUSH); >++ deselectAll.setText(ControlExample.getResourceString ("Deselect_All")); >++ deselectAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >++ deselectAll.addSelectionListener (new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ TableItem [] items = table.getItems(); >++ for (int i = 0; i < EVENT_INFO.length; i++) { >++ items[i].setChecked(false); >++ } >++ for (int i = 0; i < customNames.length; i++) { >++ items[EVENT_INFO.length + i].setChecked(false); >++ } >++ } >++ }); >++ final Button editEvent = new Button (dialog, SWT.PUSH); >++ editEvent.setText (ControlExample.getResourceString ("Edit_Event")); >++ editEvent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING)); >++ editEvent.addSelectionListener (new SelectionAdapter() { >++ public void widgetSelected (SelectionEvent e) { >++ Point pt = editEvent.getLocation(); >++ pt = e.display.map(editEvent, null, pt); >++ int index = table.getSelectionIndex(); >++ if (getExampleWidgets().length > 0 && index != -1) { >++ createEditEventDialog(dialog, pt.x, pt.y, index); >++ } >++ } >++ }); >++ editEvent.setEnabled(false); >++ table.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ int fields = 0; >++ int index = table.getSelectionIndex(); >++ if (index != -1 && index < EVENT_INFO.length) { // TODO: Allow custom widgets to specify event info >++ fields = (EVENT_INFO[index].settableFields); >++ } >++ editEvent.setEnabled(fields != 0); >++ } >++ public void widgetDefaultSelected(SelectionEvent e) { >++ if (editEvent.getEnabled()) { >++ Point pt = editEvent.getLocation(); >++ pt = e.display.map(editEvent, null, pt); >++ int index = table.getSelectionIndex(); >++ if (getExampleWidgets().length > 0 && index != -1 && index < EVENT_INFO.length) { >++ createEditEventDialog(dialog, pt.x, pt.y, index); >++ } >++ } >++ } >++ }); >++ >++ new Label(dialog, SWT.NONE); /* Filler */ >++ Button ok = new Button (dialog, SWT.PUSH); >++ ok.setText(ControlExample.getResourceString ("OK")); >++ dialog.setDefaultButton(ok); >++ ok.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >++ ok.addSelectionListener (new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ TableItem [] items = table.getItems(); >++ for (int i = 0; i < EVENT_INFO.length; i++) { >++ eventsFilter[i] = items[i].getChecked(); >++ } >++ for (int i = 0; i < customNames.length; i++) { >++ eventsFilter[EVENT_INFO.length + i] = items[EVENT_INFO.length + i].getChecked(); >++ } >++ dialog.dispose(); >++ } >++ }); >++ dialog.pack (); >++ /* >++ * If the preferred size of the dialog is too tall for the display, >++ * then reduce the height, so that the vertical scrollbar will appear. >++ */ >++ Rectangle bounds = dialog.getBounds(); >++ Rectangle trim = dialog.computeTrim(0, 0, 0, 0); >++ Rectangle clientArea = display.getClientArea(); >++ if (bounds.height > clientArea.height) { >++ dialog.setSize(bounds.width, clientArea.height - trim.height); >++ } >++ dialog.setLocation(bounds.x, clientArea.y); >++ dialog.open (); >++ while (! dialog.isDisposed()) { >++ if (! display.readAndDispatch()) display.sleep(); >++ } >++ } >++ >++ /** >++ * Creates the "Listeners" group. The "Listeners" group >++ * goes below the "Example" and "Control" groups. >++ */ >++ void createListenersGroup () { >++ listenersGroup = new Group (tabFolderPage, SWT.NONE); >++ listenersGroup.setLayout (new GridLayout (3, false)); >++ listenersGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true, 2, 1)); >++ listenersGroup.setText (ControlExample.getResourceString ("Listeners")); >++ >++ /* >++ * Create the button to access the 'Listeners' dialog. >++ */ >++ Button listenersButton = new Button (listenersGroup, SWT.PUSH); >++ listenersButton.setText (ControlExample.getResourceString ("Select_Listeners")); >++ listenersButton.addSelectionListener (new SelectionAdapter() { >++ public void widgetSelected (SelectionEvent e) { >++ createListenerSelectionDialog (); >++ recreateExampleWidgets (); >++ } >++ }); >++ >++ /* >++ * Create the checkbox to add/remove listeners to/from the example widgets. >++ */ >++ final Button listenCheckbox = new Button (listenersGroup, SWT.CHECK); >++ listenCheckbox.setText (ControlExample.getResourceString ("Listen")); >++ listenCheckbox.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected(SelectionEvent e) { >++ logging = listenCheckbox.getSelection (); >++ recreateExampleWidgets (); >++ } >++ }); >++ >++ /* >++ * Create the button to clear the text. >++ */ >++ Button clearButton = new Button (listenersGroup, SWT.PUSH); >++ clearButton.setText (ControlExample.getResourceString ("Clear")); >++ clearButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); >++ clearButton.addSelectionListener (new SelectionAdapter() { >++ public void widgetSelected (SelectionEvent e) { >++ eventConsole.setText (""); >++ } >++ }); >++ >++ /* Initialize the eventsFilter to log all events. */ >++ int customEventCount = getCustomEventNames ().length; >++ eventsFilter = new boolean [EVENT_INFO.length + customEventCount]; >++ for (int i = 0; i < EVENT_INFO.length + customEventCount; i++) { >++ eventsFilter [i] = true; >++ } >++ >++ /* Create the event console Text. */ >++ eventConsole = new Text (listenersGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); >++ GridData data = new GridData (GridData.FILL_BOTH); >++ data.horizontalSpan = 3; >++ data.heightHint = 80; >++ eventConsole.setLayoutData (data); >++ createEventConsolePopup (); >++ eventConsole.addKeyListener (new KeyAdapter () { >++ public void keyPressed (KeyEvent e) { >++ if ((e.keyCode == 'A' || e.keyCode == 'a') && (e.stateMask & SWT.MOD1) != 0) { >++ eventConsole.selectAll (); >++ e.doit = false; >++ } >++ } >++ }); >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return null; >++ } >++ >++ Shell createSetGetDialog(String[] methodNames) { >++ final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MODELESS); >++ dialog.setLayout(new GridLayout(2, false)); >++ dialog.setText(getTabText() + " " + ControlExample.getResourceString ("Set_Get")); >++ nameCombo = new Combo(dialog, SWT.READ_ONLY); >++ nameCombo.setItems(methodNames); >++ nameCombo.setText(methodNames[0]); >++ nameCombo.setVisibleItemCount(methodNames.length); >++ nameCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >++ nameCombo.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ resetLabels(); >++ } >++ }); >++ returnTypeLabel = new Label(dialog, SWT.NONE); >++ returnTypeLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false)); >++ setButton = new Button(dialog, SWT.PUSH); >++ setButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false)); >++ setButton.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ setValue(); >++ setText.selectAll(); >++ setText.setFocus(); >++ } >++ }); >++ setText = new Text(dialog, SWT.SINGLE | SWT.BORDER); >++ setText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >++ getButton = new Button(dialog, SWT.PUSH); >++ getButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false)); >++ getButton.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ getValue(); >++ } >++ }); >++ getText = new Text(dialog, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL); >++ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); >++ data.widthHint = 240; >++ data.heightHint = 200; >++ getText.setLayoutData(data); >++ resetLabels(); >++ dialog.setDefaultButton(setButton); >++ dialog.pack(); >++ dialog.addDisposeListener(new DisposeListener() { >++ public void widgetDisposed(DisposeEvent e) { >++ setGetDialog = null; >++ } >++ }); >++ return dialog; >++ } >++ >++ void resetLabels() { >++ String methodRoot = nameCombo.getText(); >++ returnTypeLabel.setText(parameterInfo(methodRoot)); >++ setButton.setText(setMethodName(methodRoot)); >++ getButton.setText("get" + methodRoot); >++ setText.setText(""); >++ getText.setText(""); >++ getValue(); >++ setText.setFocus(); >++ } >++ >++ String setMethodName(String methodRoot) { >++ return "set" + methodRoot; >++ } >++ >++ String parameterInfo(String methodRoot) { >++ String typeName = null; >++ Class returnType = getReturnType(methodRoot); >++ boolean isArray = returnType.isArray(); >++ if (isArray) { >++ typeName = returnType.getComponentType().getName(); >++ } else { >++ typeName = returnType.getName(); >++ } >++ String typeNameString = typeName; >++ int index = typeName.lastIndexOf('.'); >++ if (index != -1 && index+1 < typeName.length()) typeNameString = typeName.substring(index+1); >++ String info = ControlExample.getResourceString("Info_" + typeNameString + (isArray ? "A" : "")); >++ if (isArray) { >++ typeNameString += "[]"; >++ } >++ return ControlExample.getResourceString("Parameter_Info", new Object[] {typeNameString, info}); >++ } >++ >++ void getValue() { >++ String methodName = "get" + nameCombo.getText(); >++ getText.setText(""); >++ Widget[] widgets = getExampleWidgets(); >++ for (int i = 0; i < widgets.length; i++) { >++ try { >++ java.lang.reflect.Method method = widgets[i].getClass().getMethod(methodName, null); >++ Object result = method.invoke(widgets[i], null); >++ if (result == null) { >++ getText.append("null"); >++ } else if (result.getClass().isArray()) { >++ int length = java.lang.reflect.Array.getLength(result); >++ if (length == 0) { >++ getText.append(result.getClass().getComponentType() + "[0]"); >++ } >++ for (int j = 0; j < length; j++) { >++ getText.append(java.lang.reflect.Array.get(result,j).toString() + "\n"); >++ } >++ } else { >++ getText.append(result.toString()); >++ } >++ } catch (Exception e) { >++ getText.append(e.toString()); >++ } >++ if (i + 1 < widgets.length) { >++ getText.append("\n\n"); >++ } >++ } >++ } >++ >++ Class getReturnType(String methodRoot) { >++ Class returnType = null; >++ String methodName = "get" + methodRoot; >++ Widget[] widgets = getExampleWidgets(); >++ try { >++ java.lang.reflect.Method method = widgets[0].getClass().getMethod(methodName, null); >++ returnType = method.getReturnType(); >++ } catch (Exception e) { >++ } >++ return returnType; >++ } >++ >++ void setValue() { >++ /* The parameter type must be the same as the get method's return type */ >++ String methodRoot = nameCombo.getText(); >++ Class returnType = getReturnType(methodRoot); >++ String methodName = setMethodName(methodRoot); >++ String value = setText.getText(); >++ Widget[] widgets = getExampleWidgets(); >++ for (int i = 0; i < widgets.length; i++) { >++ try { >++ java.lang.reflect.Method method = widgets[i].getClass().getMethod(methodName, new Class[] {returnType}); >++ String typeName = returnType.getName(); >++ Object[] parameter = null; >++ if (value.equals("null")) { >++ parameter = new Object[] {null}; >++ } else if (typeName.equals("int")) { >++ parameter = new Object[] {new Integer(value)}; >++ } else if (typeName.equals("long")) { >++ parameter = new Object[] {new Long(value)}; >++ } else if (typeName.equals("char")) { >++ parameter = new Object[] {value.length() == 1 ? new Character(value.charAt(0)) : new Character('\0')}; >++ } else if (typeName.equals("boolean")) { >++ parameter = new Object[] {new Boolean(value)}; >++ } else if (typeName.equals("java.lang.String")) { >++ parameter = new Object[] {value}; >++ } else if (typeName.equals("org.eclipse.swt.graphics.Point")) { >++ String xy[] = split(value, ','); >++ parameter = new Object[] {new Point(new Integer(xy[0]).intValue(),new Integer(xy[1]).intValue())}; >++ } else if (typeName.equals("[I")) { >++ String strings[] = split(value, ','); >++ int[] ints = new int[strings.length]; >++ for (int j = 0; j < strings.length; j++) { >++ ints[j] = new Integer(strings[j]).intValue(); >++ } >++ parameter = new Object[] {ints}; >++ } else if (typeName.equals("[Ljava.lang.String;")) { >++ parameter = new Object[] {split(value, ',')}; >++ } else { >++ parameter = parameterForType(typeName, value, widgets[i]); >++ } >++ method.invoke(widgets[i], parameter); >++ } catch (Exception e) { >++ Throwable cause = e.getCause(); >++ String message = e.getMessage(); >++ getText.setText(e.toString()); >++ if (cause != null) getText.append(", cause=\n" + cause.toString()); >++ if (message != null) getText.append(", message=\n" + message); >++ } >++ } >++ } >++ >++ Object[] parameterForType(String typeName, String value, Widget widget) { >++ return new Object[] {value}; >++ } >++ >++ void createOrientationGroup () { >++ /* Create Orientation group*/ >++ orientationGroup = new Group (controlGroup, SWT.NONE); >++ orientationGroup.setLayout (new GridLayout()); >++ orientationGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >++ orientationGroup.setText (ControlExample.getResourceString("Orientation")); >++ defaultOrietationButton = new Button (orientationGroup, SWT.RADIO); >++ defaultOrietationButton.setText (ControlExample.getResourceString("Default")); >++ defaultOrietationButton.setSelection (true); >++ ltrButtonRecreate = new Button (orientationGroup, SWT.RADIO); >++ ltrButtonRecreate.setText ("create new SWT.LEFT_TO_RIGHT"); >++ rtlButtonRecreate = new Button (orientationGroup, SWT.RADIO); >++ rtlButtonRecreate.setText ("create new SWT.RIGHT_TO_LEFT"); >++ ltrButtonSet= new Button (orientationGroup, SWT.RADIO); >++ ltrButtonSet.setText ("set orientation SWT.LEFT_TO_RIGHT"); >++ rtlButtonSet = new Button (orientationGroup, SWT.RADIO); >++ rtlButtonSet.setText ("set orientation SWT.RIGHT_TO_LEFT"); >++ >++ >++ } >++ >++ /** >++ * 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 (SWT.FILL, SWT.FILL, false, false)); >++ sizeGroup.setText (ControlExample.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 (ControlExample.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); >++ fillHButton = new Button (sizeGroup, SWT.CHECK); >++ fillHButton.setText (ControlExample.getResourceString("Fill_X")); >++ fillVButton = new Button (sizeGroup, SWT.CHECK); >++ fillVButton.setText (ControlExample.getResourceString("Fill_Y")); >++ >++ /* Add the listeners */ >++ SelectionAdapter selectionListener = new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleWidgetSize (); >++ } >++ }; >++ preferredButton.addSelectionListener(selectionListener); >++ tooSmallButton.addSelectionListener(selectionListener); >++ smallButton.addSelectionListener(selectionListener); >++ largeButton.addSelectionListener(selectionListener); >++ fillHButton.addSelectionListener(selectionListener); >++ fillVButton.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 (SWT.FILL, SWT.FILL, false, false)); >++ styleGroup.setText (ControlExample.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) { >++ /* Cache the shell and display. */ >++ shell = tabFolder.getShell (); >++ display = shell.getDisplay (); >++ >++ /* Create a two column page. */ >++ tabFolderPage = new Composite (tabFolder, SWT.NONE); >++ tabFolderPage.setLayout (new GridLayout (2, false)); >++ >++ /* Create the "Example" and "Control" groups. */ >++ createExampleGroup (); >++ createControlGroup (); >++ >++ /* Create the "Listeners" group under the "Control" group. */ >++ createListenersGroup (); >++ >++ /* Create and initialize the example and control widgets. */ >++ createExampleWidgets (); >++ hookExampleWidgetListeners (); >++ createControlWidgets (); >++ setExampleWidgetState (); >++ >++ return tabFolderPage; >++ } >++ >++ void setExampleWidgetPopupMenu() { >++ Control[] controls = getExampleControls(); >++ for (int i = 0; i < controls.length; i++) { >++ final Control control = controls [i]; >++ control.addListener(SWT.MenuDetect, new Listener() { >++ public void handleEvent(Event event) { >++ Menu menu = control.getMenu(); >++ if (menu != null && samplePopup) { >++ menu.dispose(); >++ menu = null; >++ } >++ if (menu == null && popupMenuButton.getSelection()) { >++ menu = new Menu(shell, SWT.POP_UP | (control.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT))); >++ MenuItem item = new MenuItem(menu, SWT.PUSH); >++ item.setText("Sample popup menu item"); >++ specialPopupMenuItems(menu, event); >++ control.setMenu(menu); >++ samplePopup = true; >++ } >++ } >++ }); >++ } >++ } >++ >++ protected void specialPopupMenuItems(final Menu menu, final Event event) { >++ } >++ >++ /** >++ * Disposes the "Example" widgets. >++ */ >++ void disposeExampleWidgets () { >++ Widget [] widgets = getExampleWidgets (); >++ for (int i=0; i<widgets.length; i++) { >++ widgets [i].dispose (); >++ } >++ } >++ >++ Image colorImage (Color color) { >++ Image image = new Image (display, IMAGE_SIZE, IMAGE_SIZE); >++ GC gc = new GC(image); >++ gc.setBackground(color); >++ Rectangle bounds = image.getBounds(); >++ gc.fillRectangle(0, 0, bounds.width, bounds.height); >++ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); >++ gc.drawRectangle(0, 0, bounds.width - 1, bounds.height - 1); >++ gc.dispose(); >++ return image; >++ } >++ >++ Image fontImage (Font font) { >++ Image image = new Image (display, IMAGE_SIZE, IMAGE_SIZE); >++ GC gc = new GC(image); >++ Rectangle bounds = image.getBounds(); >++ gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); >++ gc.fillRectangle(0, 0, bounds.width, bounds.height); >++ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); >++ gc.drawRectangle(0, 0, bounds.width - 1, bounds.height - 1); >++ FontData data[] = font.getFontData(); >++ int style = data[0].getStyle(); >++ switch (style) { >++ case SWT.NORMAL: >++ gc.drawLine(3, 3, 3, 8); >++ gc.drawLine(4, 3, 7, 8); >++ gc.drawLine(8, 3, 8, 8); >++ break; >++ case SWT.BOLD: >++ gc.drawLine(3, 2, 3, 9); >++ gc.drawLine(4, 2, 4, 9); >++ gc.drawLine(5, 2, 7, 2); >++ gc.drawLine(5, 3, 8, 3); >++ gc.drawLine(5, 5, 7, 5); >++ gc.drawLine(5, 6, 7, 6); >++ gc.drawLine(5, 8, 8, 8); >++ gc.drawLine(5, 9, 7, 9); >++ gc.drawLine(7, 4, 8, 4); >++ gc.drawLine(7, 7, 8, 7); >++ break; >++ case SWT.ITALIC: >++ gc.drawLine(6, 2, 8, 2); >++ gc.drawLine(7, 3, 4, 8); >++ gc.drawLine(3, 9, 5, 9); >++ break; >++ case SWT.BOLD | SWT.ITALIC: >++ gc.drawLine(5, 2, 8, 2); >++ gc.drawLine(5, 3, 8, 3); >++ gc.drawLine(6, 4, 4, 7); >++ gc.drawLine(7, 4, 5, 7); >++ gc.drawLine(3, 8, 6, 8); >++ gc.drawLine(3, 9, 6, 9); >++ break; >++ } >++ gc.dispose(); >++ return image; >++ } >++ >++ /** >++ * Gets the list of custom event names. >++ * Subclasses override this method to allow adding of custom events. >++ * >++ * @return an array containing custom event names >++ * @see hookCustomListener >++ */ >++ String [] getCustomEventNames () { >++ return new String [0]; >++ } >++ >++ /** >++ * Gets the default style for a widget >++ * >++ * @return the default style bit >++ */ >++ int getDefaultStyle () { >++ if (ltrButtonRecreate != null && ltrButtonRecreate.getSelection()) { >++ return SWT.LEFT_TO_RIGHT; >++ } >++ if (rtlButtonRecreate != null && rtlButtonRecreate.getSelection()) { >++ return SWT.RIGHT_TO_LEFT; >++ } >++ if (rtlButtonSet != null && rtlButtonSet.getSelection()) { >++ return SWT.RIGHT_TO_LEFT; >++ } >++ if (ltrButtonSet != null && ltrButtonSet.getSelection()) { >++ return SWT.LEFT_TO_RIGHT; >++ } >++ return SWT.NONE; >++ } >++ >++ /** >++ * Gets the "Example" widgets. >++ * >++ * @return an array containing the example widgets >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [0]; >++ } >++ >++ /** >++ * Gets the "Example" controls. >++ * This is the subset of "Example" widgets that are controls. >++ * >++ * @return an array containing the example controls >++ */ >++ Control [] getExampleControls () { >++ Widget [] widgets = getExampleWidgets (); >++ Control [] controls = new Control [0]; >++ for (int i = 0; i < widgets.length; i++) { >++ if (widgets[i] instanceof Control) { >++ Control[] newControls = new Control[controls.length + 1]; >++ System.arraycopy(controls, 0, newControls, 0, controls.length); >++ controls = newControls; >++ controls[controls.length - 1] = (Control)widgets[i]; >++ } >++ } >++ return controls; >++ } >++ >++ /** >++ * Gets the "Example" widget's items, if any. >++ * >++ * @return an array containing the example widget's items >++ */ >++ Item [] getExampleWidgetItems () { >++ return new Item [0]; >++ } >++ >++ /** >++ * Gets the short text for the tab folder item. >++ * >++ * @return the short text for the tab item >++ */ >++ String getShortTabText() { >++ return getTabText(); >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ * >++ * @return the text for the tab item >++ */ >++ String getTabText () { >++ return ""; >++ } >++ >++ /** >++ * Hooks all listeners to all example controls >++ * and example control items. >++ */ >++ void hookExampleWidgetListeners () { >++ if (logging) { >++ Widget[] widgets = getExampleWidgets (); >++ for (int i = 0; i < widgets.length; i++) { >++ hookListeners (widgets [i]); >++ } >++ Item[] exampleItems = getExampleWidgetItems (); >++ for (int i = 0; i < exampleItems.length; i++) { >++ hookListeners (exampleItems [i]); >++ } >++ String [] customNames = getCustomEventNames (); >++ for (int i = 0; i < customNames.length; i++) { >++ if (eventsFilter [EVENT_INFO.length + i]) { >++ hookCustomListener (customNames[i]); >++ } >++ } >++ } >++ } >++ >++ /** >++ * Hooks the custom listener specified by eventName. >++ * Subclasses override this method to add custom listeners. >++ * @see getCustomEventNames >++ */ >++ void hookCustomListener (String eventName) { >++ } >++ >++ /** >++ * Hooks all listeners to the specified widget. >++ */ >++ void hookListeners (Widget widget) { >++ if (logging) { >++ Listener listener = new Listener() { >++ public void handleEvent (Event event) { >++ log (event); >++ } >++ }; >++ for (int i = 0; i < EVENT_INFO.length; i++) { >++ if (eventsFilter [i]) { >++ widget.addListener (EVENT_INFO[i].type, listener); >++ } >++ } >++ } >++ } >++ >++ /** >++ * Logs an untyped event to the event console. >++ */ >++ void log(Event event) { >++ int i = 0; >++ while (i < EVENT_INFO.length) { >++ if (EVENT_INFO[i].type == event.type) break; >++ i++; >++ } >++ String toString = EVENT_INFO[i].name + " [" + event.type + "]: "; >++ switch (event.type) { >++ case SWT.KeyDown: >++ case SWT.KeyUp: toString += new KeyEvent (event).toString (); break; >++ case SWT.MouseDown: >++ case SWT.MouseUp: >++ case SWT.MouseMove: >++ case SWT.MouseEnter: >++ case SWT.MouseExit: >++ case SWT.MouseDoubleClick: >++ case SWT.MouseWheel: >++ case SWT.MouseHover: toString += new MouseEvent (event).toString (); break; >++ case SWT.Paint: toString += new PaintEvent (event).toString (); break; >++ case SWT.Move: >++ case SWT.Resize: toString += new ControlEvent (event).toString (); break; >++ case SWT.Dispose: toString += new DisposeEvent (event).toString (); break; >++ case SWT.Selection: >++ case SWT.DefaultSelection: toString += new SelectionEvent (event).toString (); break; >++ case SWT.FocusIn: >++ case SWT.FocusOut: toString += new FocusEvent (event).toString (); break; >++ case SWT.Expand: >++ case SWT.Collapse: toString += new TreeEvent (event).toString (); break; >++ case SWT.Iconify: >++ case SWT.Deiconify: >++ case SWT.Close: >++ case SWT.Activate: >++ case SWT.Deactivate: toString += new ShellEvent (event).toString (); break; >++ case SWT.Show: >++ case SWT.Hide: toString += (event.widget instanceof Menu) ? new MenuEvent (event).toString () : event.toString(); break; >++ case SWT.Modify: toString += new ModifyEvent (event).toString (); break; >++ case SWT.Verify: toString += new VerifyEvent (event).toString (); break; >++ case SWT.Help: toString += new HelpEvent (event).toString (); break; >++ case SWT.Arm: toString += new ArmEvent (event).toString (); break; >++ case SWT.Traverse: toString += new TraverseEvent (event).toString (); break; >++ case SWT.HardKeyDown: >++ case SWT.HardKeyUp: >++ case SWT.DragDetect: >++ case SWT.MenuDetect: >++ case SWT.SetData: >++ default: toString += event.toString (); >++ } >++ log (toString); >++ >++ /* Return values for event fields. */ >++ int mask = EVENT_INFO[i].setFields; >++ if (!ignore && mask != 0) { >++ Event setFieldsEvent = EVENT_INFO[i].event; >++ if ((mask & DOIT) != 0) event.doit = setFieldsEvent.doit; >++ if ((mask & DETAIL) != 0) event.detail = setFieldsEvent.detail; >++ if ((mask & TEXT) != 0) event.text = setFieldsEvent.text; >++ if ((mask & X) != 0) event.x = setFieldsEvent.x; >++ if ((mask & Y) != 0) event.y = setFieldsEvent.y; >++ if ((mask & WIDTH) != 0) event.width = setFieldsEvent.width; >++ if ((mask & HEIGHT) != 0) event.height = setFieldsEvent.height; >++ eventConsole.append (ControlExample.getResourceString("Returning")); >++ ignore = true; >++ log (event); >++ ignore = false; >++ } >++ } >++ >++ /** >++ * Logs a string to the event console. >++ */ >++ void log (String string) { >++ if (!eventConsole.isDisposed()) { >++ eventConsole.append (string); >++ eventConsole.append ("\n"); >++ } >++ } >++ >++ /** >++ * Logs a typed event to the event console. >++ */ >++ void log (String eventName, TypedEvent event) { >++ log (eventName + ": " + event.toString ()); >++ } >++ >++ /** >++ * Recreates the "Example" widgets. >++ */ >++ void recreateExampleWidgets () { >++ disposeExampleWidgets (); >++ createExampleWidgets (); >++ hookExampleWidgetListeners (); >++ setExampleWidgetState (); >++ } >++ >++ /** >++ * Sets the foreground color, background color, and font >++ * of the "Example" widgets to their default settings. >++ * Subclasses may extend in order to reset other colors >++ * and fonts to default settings as well. >++ */ >++ void resetColorsAndFonts () { >++ Color oldColor = foregroundColor; >++ foregroundColor = null; >++ setExampleWidgetForeground (); >++ if (oldColor != null) oldColor.dispose(); >++ oldColor = backgroundColor; >++ backgroundColor = null; >++ setExampleWidgetBackground (); >++ if (oldColor != null) oldColor.dispose(); >++ Font oldFont = font; >++ font = null; >++ setExampleWidgetFont (); >++ setExampleWidgetSize (); >++ if (oldFont != null) oldFont.dispose(); >++ } >++ >++ boolean rtlSupport() { >++ return RTL_SUPPORT_ENABLE; >++ } >++ >++ /** >++ * Sets the background color of the "Example" widgets' parent. >++ */ >++ void setExampleGroupBackgroundColor () { >++ if (backgroundModeGroup == null) return; >++ exampleGroup.setBackground (backgroundModeColorButton.getSelection () ? display.getSystemColor(SWT.COLOR_BLUE) : null); >++ } >++ /** >++ * Sets the background image of the "Example" widgets' parent. >++ */ >++ void setExampleGroupBackgroundImage () { >++ if (backgroundModeGroup == null) return; >++ exampleGroup.setBackgroundImage (backgroundModeImageButton.getSelection () ? instance.images[ControlExample.ciParentBackground] : null); >++ } >++ >++ /** >++ * Sets the background mode of the "Example" widgets' parent. >++ */ >++ void setExampleGroupBackgroundMode () { >++ if (backgroundModeGroup == null) return; >++ String modeString = backgroundModeCombo.getText (); >++ int mode = SWT.INHERIT_NONE; >++ if (modeString.equals("SWT.INHERIT_DEFAULT")) mode = SWT.INHERIT_DEFAULT; >++ if (modeString.equals("SWT.INHERIT_FORCE")) mode = SWT.INHERIT_FORCE; >++ exampleGroup.setBackgroundMode (mode); >++ } >++ >++ /** >++ * Sets the background color of the "Example" widgets. >++ */ >++ void setExampleWidgetBackground () { >++ if (colorAndFontTable == null) return; // user cannot change color/font on this tab >++ Control [] controls = getExampleControls (); >++ if (!instance.startup) { >++ for (int i = 0; i < controls.length; i++) { >++ controls[i].setBackground (backgroundColor); >++ } >++ } >++ // Set the background color item's image to match the background color of the example widget(s). >++ Color color = backgroundColor; >++ if (controls.length == 0) return; >++ if (color == null) color = controls [0].getBackground (); >++ TableItem item = colorAndFontTable.getItem(BACKGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage (color)); >++ } >++ >++ /** >++ * Sets the enabled state of the "Example" widgets. >++ */ >++ void setExampleWidgetEnabled () { >++ Control [] controls = getExampleControls (); >++ for (int i=0; i<controls.length; i++) { >++ controls [i].setEnabled (enabledButton.getSelection ()); >++ } >++ } >++ >++ /** >++ * Sets the font of the "Example" widgets. >++ */ >++ void setExampleWidgetFont () { >++ if (colorAndFontTable == null) return; // user cannot change color/font on this tab >++ Control [] controls = getExampleControls (); >++ if (!instance.startup) { >++ for (int i = 0; i < controls.length; i++) { >++ controls[i].setFont(font); >++ } >++ } >++ /* Set the font item's image and font to match the font of the example widget(s). */ >++ Font ft = font; >++ if (controls.length == 0) return; >++ if (ft == null) ft = controls [0].getFont (); >++ TableItem item = colorAndFontTable.getItem(FONT); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (fontImage (ft)); >++ item.setFont(ft); >++ colorAndFontTable.layout (); >++ } >++ >++ /** >++ * Sets the foreground color of the "Example" widgets. >++ */ >++ void setExampleWidgetForeground () { >++ if (colorAndFontTable == null) return; // user cannot change color/font on this tab >++ Control [] controls = getExampleControls (); >++ if (!instance.startup) { >++ for (int i = 0; i < controls.length; i++) { >++ controls[i].setForeground (foregroundColor); >++ } >++ } >++ /* Set the foreground color item's image to match the foreground color of the example widget(s). */ >++ Color color = foregroundColor; >++ if (controls.length == 0) return; >++ if (color == null) color = controls [0].getForeground (); >++ TableItem item = colorAndFontTable.getItem(FOREGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * 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 = getExampleControls (); >++ for (int i=0; i<controls.length; i++) { >++ GridData gridData = new GridData(size, size); >++ gridData.grabExcessHorizontalSpace = fillHButton.getSelection(); >++ gridData.grabExcessVerticalSpace = fillVButton.getSelection(); >++ gridData.horizontalAlignment = fillHButton.getSelection() ? SWT.FILL : SWT.LEFT; >++ gridData.verticalAlignment = fillVButton.getSelection() ? SWT.FILL : SWT.TOP; >++ controls [i].setLayoutData (gridData); >++ } >++ tabFolderPage.layout (controls); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. Subclasses >++ * may extend this method to set "Example" widget state >++ * that is specific to the widget. >++ */ >++ void setExampleWidgetState () { >++ setExampleWidgetBackground (); >++ setExampleWidgetForeground (); >++ setExampleWidgetFont (); >++ if (!instance.startup) { >++ setExampleWidgetEnabled (); >++ setExampleWidgetVisibility (); >++ setExampleGroupBackgroundMode (); >++ setExampleGroupBackgroundColor (); >++ setExampleGroupBackgroundImage (); >++ setExampleWidgetBackgroundImage (); >++ setExampleWidgetPopupMenu (); >++ setExampleWidgetSize (); >++ } >++ //TEMPORARY CODE >++// Control [] controls = getExampleControls (); >++// for (int i=0; i<controls.length; i++) { >++// log ("Control=" + controls [i] + ", border width=" + controls [i].getBorderWidth ()); >++// } >++ } >++ >++ /** >++ * Sets the visibility of the "Example" widgets. >++ */ >++ void setExampleWidgetVisibility () { >++ Control [] controls = getExampleControls (); >++ for (int i=0; i<controls.length; i++) { >++ controls [i].setVisible (visibleButton.getSelection ()); >++ } >++ } >++ >++ /** >++ * Sets the background image of the "Example" widgets. >++ */ >++ void setExampleWidgetBackgroundImage () { >++ if (backgroundImageButton != null && backgroundImageButton.isDisposed()) return; >++ Control [] controls = getExampleControls (); >++ for (int i=0; i<controls.length; i++) { >++ controls [i].setBackgroundImage (backgroundImageButton.getSelection () ? instance.images[ControlExample.ciBackground] : null); >++ } >++ } >++ >++ /** >++ * Splits the given string around matches of the given character. >++ * >++ * This subset of java.lang.String.split(String regex) >++ * uses only code that can be run on CLDC platforms. >++ */ >++ String [] split (String string, char ch) { >++ String [] result = new String[0]; >++ int start = 0; >++ int length = string.length(); >++ while (start < length) { >++ int end = string.indexOf(ch, start); >++ if (end == -1) end = length; >++ String substr = string.substring(start, end); >++ String [] newResult = new String[result.length + 1]; >++ System.arraycopy(result, 0, newResult, 0, result.length); >++ newResult [result.length] = substr; >++ result = newResult; >++ start = end + 1; >++ } >++ return result; >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/TabFolderTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/TabFolderTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/TabFolderTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/TabFolderTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,166 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++ >++class TabFolderTab extends Tab { >++ /* Example widgets and groups that contain them */ >++ TabFolder tabFolder1; >++ Group tabFolderGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button topButton, bottomButton; >++ >++ static String [] TabItems1 = {ControlExample.getResourceString("TabItem1_0"), >++ ControlExample.getResourceString("TabItem1_1"), >++ ControlExample.getResourceString("TabItem1_2")}; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ TabFolderTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the TabFolder */ >++ tabFolderGroup = new Group (exampleGroup, SWT.NONE); >++ tabFolderGroup.setLayout (new GridLayout ()); >++ tabFolderGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ tabFolderGroup.setText ("TabFolder"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (topButton.getSelection ()) style |= SWT.TOP; >++ if (bottomButton.getSelection ()) style |= SWT.BOTTOM; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ >++ /* Create the example widgets */ >++ tabFolder1 = new TabFolder (tabFolderGroup, style); >++ for (int i = 0; i < TabItems1.length; i++) { >++ TabItem item = new TabItem(tabFolder1, SWT.NONE); >++ item.setText(TabItems1[i]); >++ item.setToolTipText(ControlExample.getResourceString("Tooltip", new String [] {TabItems1[i]})); >++ Text content = new Text(tabFolder1, SWT.WRAP | SWT.MULTI); >++ content.setText(ControlExample.getResourceString("TabItem_content") + ": " + i); >++ item.setControl(content); >++ } >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ topButton = new Button (styleGroup, SWT.RADIO); >++ topButton.setText ("SWT.TOP"); >++ topButton.setSelection(true); >++ bottomButton = new Button (styleGroup, SWT.RADIO); >++ bottomButton.setText ("SWT.BOTTOM"); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ } >++ >++ /** >++ * Gets the "Example" widget children's items, if any. >++ * >++ * @return an array containing the example widget children's items >++ */ >++ Item [] getExampleWidgetItems () { >++ return tabFolder1.getItems(); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {tabFolder1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Selection", "SelectionIndex", "ToolTipText"}; >++ } >++ >++ String setMethodName(String methodRoot) { >++ /* Override to handle special case of int getSelectionIndex()/setSelection(int) */ >++ return (methodRoot.equals("SelectionIndex")) ? "setSelection" : "set" + methodRoot; >++ } >++ >++ Object[] parameterForType(String typeName, String value, Widget widget) { >++ if (value.equals("")) return new Object[] {new TabItem[0]}; >++ if (typeName.equals("org.eclipse.swt.widgets.TabItem")) { >++ TabItem item = findItem(value, ((TabFolder) widget).getItems()); >++ if (item != null) return new Object[] {item}; >++ } >++ if (typeName.equals("[Lorg.eclipse.swt.widgets.TabItem;")) { >++ String[] values = split(value, ','); >++ TabItem[] items = new TabItem[values.length]; >++ for (int i = 0; i < values.length; i++) { >++ items[i] = findItem(values[i], ((TabFolder) widget).getItems()); >++ } >++ return new Object[] {items}; >++ } >++ return super.parameterForType(typeName, value, widget); >++ } >++ >++ TabItem findItem(String value, TabItem[] items) { >++ for (int i = 0; i < items.length; i++) { >++ TabItem item = items[i]; >++ if (item.getText().equals(value)) return item; >++ } >++ return null; >++ } >++ >++ /** >++ * Gets the short text for the tab folder item. >++ */ >++ String getShortTabText() { >++ return "TF"; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "TabFolder"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ topButton.setSelection ((tabFolder1.getStyle () & SWT.TOP) != 0); >++ bottomButton.setSelection ((tabFolder1.getStyle () & SWT.BOTTOM) != 0); >++ borderButton.setSelection ((tabFolder1.getStyle () & SWT.BORDER) != 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/TableTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/TableTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/TableTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/TableTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,685 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++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; >++ >++ /* Size widgets added to the "Size" group */ >++ Button packColumnsButton; >++ >++ /* Style widgets added to the "Style" group */ >++ Button noScrollButton, checkButton, fullSelectionButton, hideSelectionButton; >++ >++ /* Other widgets added to the "Other" group */ >++ Button multipleColumns, moveableColumns, resizableColumns, headerVisibleButton, sortIndicatorButton, headerImagesButton, linesVisibleButton, subImagesButton; >++ >++ /* Controls and resources added to the "Colors and Fonts" group */ >++ static final int ITEM_FOREGROUND_COLOR = 3; >++ static final int ITEM_BACKGROUND_COLOR = 4; >++ static final int ITEM_FONT = 5; >++ static final int CELL_FOREGROUND_COLOR = 6; >++ static final int CELL_BACKGROUND_COLOR = 7; >++ static final int CELL_FONT = 8; >++ Color itemForegroundColor, itemBackgroundColor, cellForegroundColor, cellBackgroundColor; >++ Font itemFont, cellFont; >++ >++ static String [] columnTitles = {ControlExample.getResourceString("TableTitle_0"), >++ ControlExample.getResourceString("TableTitle_1"), >++ ControlExample.getResourceString("TableTitle_2"), >++ ControlExample.getResourceString("TableTitle_3")}; >++ >++ static String[][] tableData = { >++ { ControlExample.getResourceString("TableLine0_0"), >++ ControlExample.getResourceString("TableLine0_1"), >++ ControlExample.getResourceString("TableLine0_2"), >++ ControlExample.getResourceString("TableLine0_3") }, >++ { ControlExample.getResourceString("TableLine1_0"), >++ ControlExample.getResourceString("TableLine1_1"), >++ ControlExample.getResourceString("TableLine1_2"), >++ ControlExample.getResourceString("TableLine1_3") }, >++ { ControlExample.getResourceString("TableLine2_0"), >++ ControlExample.getResourceString("TableLine2_1"), >++ ControlExample.getResourceString("TableLine2_2"), >++ ControlExample.getResourceString("TableLine2_3") } }; >++ >++ Point menuMouseCoords; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ TableTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Colors and Fonts" group. >++ */ >++ void createColorAndFontGroup () { >++ super.createColorAndFontGroup(); >++ >++ TableItem item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Item_Foreground_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Item_Background_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Item_Font")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Cell_Foreground_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Cell_Background_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Cell_Font")); >++ >++ shell.addDisposeListener(new DisposeListener() { >++ public void widgetDisposed(DisposeEvent event) { >++ if (itemBackgroundColor != null) itemBackgroundColor.dispose(); >++ if (itemForegroundColor != null) itemForegroundColor.dispose(); >++ if (itemFont != null) itemFont.dispose(); >++ if (cellBackgroundColor != null) cellBackgroundColor.dispose(); >++ if (cellForegroundColor != null) cellForegroundColor.dispose(); >++ if (cellFont != null) cellFont.dispose(); >++ itemBackgroundColor = null; >++ itemForegroundColor = null; >++ itemFont = null; >++ cellBackgroundColor = null; >++ cellForegroundColor = null; >++ cellFont = null; >++ } >++ }); >++ } >++ >++ void changeFontOrColor(int index) { >++ switch (index) { >++ case ITEM_FOREGROUND_COLOR: { >++ Color oldColor = itemForegroundColor; >++ if (oldColor == null) oldColor = table1.getItem (0).getForeground (); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = itemForegroundColor; >++ itemForegroundColor = new Color (display, rgb); >++ setItemForeground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case ITEM_BACKGROUND_COLOR: { >++ Color oldColor = itemBackgroundColor; >++ if (oldColor == null) oldColor = table1.getItem (0).getBackground (); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = itemBackgroundColor; >++ itemBackgroundColor = new Color (display, rgb); >++ setItemBackground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case ITEM_FONT: { >++ Font oldFont = itemFont; >++ if (oldFont == null) oldFont = table1.getItem (0).getFont (); >++ fontDialog.setFontList(oldFont.getFontData()); >++ FontData fontData = fontDialog.open (); >++ if (fontData == null) return; >++ oldFont = itemFont; >++ itemFont = new Font (display, fontData); >++ setItemFont (); >++ setExampleWidgetSize (); >++ if (oldFont != null) oldFont.dispose (); >++ } >++ break; >++ case CELL_FOREGROUND_COLOR: { >++ Color oldColor = cellForegroundColor; >++ if (oldColor == null) oldColor = table1.getItem (0).getForeground (1); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = cellForegroundColor; >++ cellForegroundColor = new Color (display, rgb); >++ setCellForeground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case CELL_BACKGROUND_COLOR: { >++ Color oldColor = cellBackgroundColor; >++ if (oldColor == null) oldColor = table1.getItem (0).getBackground (1); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = cellBackgroundColor; >++ cellBackgroundColor = new Color (display, rgb); >++ setCellBackground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case CELL_FONT: { >++ Font oldFont = cellFont; >++ if (oldFont == null) oldFont = table1.getItem (0).getFont (1); >++ fontDialog.setFontList(oldFont.getFontData()); >++ FontData fontData = fontDialog.open (); >++ if (fontData == null) return; >++ oldFont = cellFont; >++ cellFont = new Font (display, fontData); >++ setCellFont (); >++ setExampleWidgetSize (); >++ if (oldFont != null) oldFont.dispose (); >++ } >++ break; >++ default: >++ super.changeFontOrColor(index); >++ } >++ } >++ >++ /** >++ * Creates the "Other" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ >++ /* Create display controls specific to this example */ >++ linesVisibleButton = new Button (otherGroup, SWT.CHECK); >++ linesVisibleButton.setText (ControlExample.getResourceString("Lines_Visible")); >++ multipleColumns = new Button (otherGroup, SWT.CHECK); >++ multipleColumns.setText (ControlExample.getResourceString("Multiple_Columns")); >++ multipleColumns.setSelection(true); >++ headerVisibleButton = new Button (otherGroup, SWT.CHECK); >++ headerVisibleButton.setText (ControlExample.getResourceString("Header_Visible")); >++ sortIndicatorButton = new Button (otherGroup, SWT.CHECK); >++ sortIndicatorButton.setText (ControlExample.getResourceString("Sort_Indicator")); >++ moveableColumns = new Button (otherGroup, SWT.CHECK); >++ moveableColumns.setText (ControlExample.getResourceString("Moveable_Columns")); >++ resizableColumns = new Button (otherGroup, SWT.CHECK); >++ resizableColumns.setText (ControlExample.getResourceString("Resizable_Columns")); >++ headerImagesButton = new Button (otherGroup, SWT.CHECK); >++ headerImagesButton.setText (ControlExample.getResourceString("Header_Images")); >++ subImagesButton = new Button (otherGroup, SWT.CHECK); >++ subImagesButton.setText (ControlExample.getResourceString("Sub_Images")); >++ >++ /* Add the listeners */ >++ linesVisibleButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetLinesVisible (); >++ } >++ }); >++ multipleColumns.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ recreateExampleWidgets (); >++ } >++ }); >++ headerVisibleButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetHeaderVisible (); >++ } >++ }); >++ sortIndicatorButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetSortIndicator (); >++ } >++ }); >++ moveableColumns.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setColumnsMoveable (); >++ } >++ }); >++ resizableColumns.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setColumnsResizable (); >++ } >++ }); >++ headerImagesButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ recreateExampleWidgets (); >++ } >++ }); >++ subImagesButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ recreateExampleWidgets (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the table */ >++ tableGroup = new Group (exampleGroup, SWT.NONE); >++ tableGroup.setLayout (new GridLayout ()); >++ tableGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ tableGroup.setText ("Table"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (singleButton.getSelection ()) style |= SWT.SINGLE; >++ if (multiButton.getSelection ()) style |= SWT.MULTI; >++ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL; >++ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL; >++ if (noScrollButton.getSelection ()) style |= SWT.NO_SCROLL; >++ if (checkButton.getSelection ()) style |= SWT.CHECK; >++ if (fullSelectionButton.getSelection ()) style |= SWT.FULL_SELECTION; >++ if (hideSelectionButton.getSelection ()) style |= SWT.HIDE_SELECTION; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ >++ /* Create the table widget */ >++ table1 = new Table (tableGroup, style); >++ >++ /* Fill the table with data */ >++ boolean multiColumn = multipleColumns.getSelection(); >++ if (multiColumn) { >++ for (int i = 0; i < columnTitles.length; i++) { >++ TableColumn tableColumn = new TableColumn(table1, SWT.NONE); >++ tableColumn.setText(columnTitles[i]); >++ tableColumn.setToolTipText(ControlExample.getResourceString("Tooltip", new String [] {columnTitles[i]})); >++ if (headerImagesButton.getSelection()) tableColumn.setImage(instance.images [i % 3]); >++ } >++ table1.setSortColumn(table1.getColumn(0)); >++ } >++ for (int i=0; i<16; i++) { >++ TableItem item = new TableItem (table1, SWT.NONE); >++ if (multiColumn && subImagesButton.getSelection()) { >++ for (int j = 0; j < columnTitles.length; j++) { >++ item.setImage(j, instance.images [i % 3]); >++ } >++ } else { >++ item.setImage(instance.images [i % 3]); >++ } >++ setItemText (item, i, ControlExample.getResourceString("Index") + i); >++ } >++ packColumns(); >++ } >++ >++ void setItemText(TableItem item, int i, String node) { >++ int index = i % 3; >++ if (multipleColumns.getSelection()) { >++ tableData [index][0] = node; >++ item.setText (tableData [index]); >++ } else { >++ item.setText (node); >++ } >++ } >++ >++ /** >++ * Creates the "Size" group. The "Size" group contains >++ * controls that allow the user to change the size of >++ * the example widgets. >++ */ >++ void createSizeGroup () { >++ super.createSizeGroup(); >++ >++ packColumnsButton = new Button (sizeGroup, SWT.PUSH); >++ packColumnsButton.setText (ControlExample.getResourceString("Pack_Columns")); >++ packColumnsButton.addSelectionListener(new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ packColumns (); >++ setExampleWidgetSize (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup () { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ noScrollButton = new Button (styleGroup, SWT.CHECK); >++ noScrollButton.setText ("SWT.NO_SCROLL"); >++ noScrollButton.moveAbove(borderButton); >++ checkButton = new Button (styleGroup, SWT.CHECK); >++ checkButton.setText ("SWT.CHECK"); >++ fullSelectionButton = new Button (styleGroup, SWT.CHECK); >++ fullSelectionButton.setText ("SWT.FULL_SELECTION"); >++ hideSelectionButton = new Button (styleGroup, SWT.CHECK); >++ hideSelectionButton.setText ("SWT.HIDE_SELECTION"); >++ } >++ >++ /** >++ * Gets the "Example" widget children's items, if any. >++ * >++ * @return an array containing the example widget children's items >++ */ >++ Item [] getExampleWidgetItems () { >++ Item [] columns = table1.getColumns(); >++ Item [] items = table1.getItems(); >++ Item [] allItems = new Item [columns.length + items.length]; >++ System.arraycopy(columns, 0, allItems, 0, columns.length); >++ System.arraycopy(items, 0, allItems, columns.length, items.length); >++ return allItems; >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {table1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"ColumnOrder", "ItemCount", "Selection", "SelectionIndex", "ToolTipText", "TopIndex"}; >++ } >++ >++ String setMethodName(String methodRoot) { >++ /* Override to handle special case of int getSelectionIndex()/setSelection(int) */ >++ return (methodRoot.equals("SelectionIndex")) ? "setSelection" : "set" + methodRoot; >++ } >++ >++ void packColumns () { >++ int columnCount = table1.getColumnCount(); >++ for (int i = 0; i < columnCount; i++) { >++ TableColumn tableColumn = table1.getColumn(i); >++ tableColumn.pack(); >++ } >++ } >++ >++ Object[] parameterForType(String typeName, String value, Widget widget) { >++ if (value.equals("")) return new Object[] {new TableItem[0]}; // bug in Table? >++ if (typeName.equals("org.eclipse.swt.widgets.TableItem")) { >++ TableItem item = findItem(value, ((Table) widget).getItems()); >++ if (item != null) return new Object[] {item}; >++ } >++ if (typeName.equals("[Lorg.eclipse.swt.widgets.TableItem;")) { >++ String[] values = split(value, ','); >++ TableItem[] items = new TableItem[values.length]; >++ for (int i = 0; i < values.length; i++) { >++ items[i] = findItem(values[i], ((Table) widget).getItems()); >++ } >++ return new Object[] {items}; >++ } >++ return super.parameterForType(typeName, value, widget); >++ } >++ >++ TableItem findItem(String value, TableItem[] items) { >++ for (int i = 0; i < items.length; i++) { >++ TableItem item = items[i]; >++ if (item.getText().equals(value)) return item; >++ } >++ return null; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Table"; >++ } >++ >++ /** >++ * Sets the foreground color, background color, and font >++ * of the "Example" widgets to their default settings. >++ * Also sets foreground and background color of TableItem [0] >++ * to default settings. >++ */ >++ void resetColorsAndFonts () { >++ super.resetColorsAndFonts (); >++ Color oldColor = itemForegroundColor; >++ itemForegroundColor = null; >++ setItemForeground (); >++ if (oldColor != null) oldColor.dispose(); >++ oldColor = itemBackgroundColor; >++ itemBackgroundColor = null; >++ setItemBackground (); >++ if (oldColor != null) oldColor.dispose(); >++ Font oldFont = font; >++ itemFont = null; >++ setItemFont (); >++ if (oldFont != null) oldFont.dispose(); >++ oldColor = cellForegroundColor; >++ cellForegroundColor = null; >++ setCellForeground (); >++ if (oldColor != null) oldColor.dispose(); >++ oldColor = cellBackgroundColor; >++ cellBackgroundColor = null; >++ setCellBackground (); >++ if (oldColor != null) oldColor.dispose(); >++ oldFont = font; >++ cellFont = null; >++ setCellFont (); >++ if (oldFont != null) oldFont.dispose(); >++ } >++ >++ /** >++ * Sets the background color of the Row 0 TableItem in column 1. >++ */ >++ void setCellBackground () { >++ if (!instance.startup) { >++ table1.getItem (0).setBackground (1, cellBackgroundColor); >++ } >++ /* Set the background color item's image to match the background color of the cell. */ >++ Color color = cellBackgroundColor; >++ if (color == null) color = table1.getItem (0).getBackground (1); >++ TableItem item = colorAndFontTable.getItem(CELL_BACKGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the foreground color of the Row 0 TableItem in column 1. >++ */ >++ void setCellForeground () { >++ if (!instance.startup) { >++ table1.getItem (0).setForeground (1, cellForegroundColor); >++ } >++ /* Set the foreground color item's image to match the foreground color of the cell. */ >++ Color color = cellForegroundColor; >++ if (color == null) color = table1.getItem (0).getForeground (1); >++ TableItem item = colorAndFontTable.getItem(CELL_FOREGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the font of the Row 0 TableItem in column 1. >++ */ >++ void setCellFont () { >++ if (!instance.startup) { >++ table1.getItem (0).setFont (1, cellFont); >++ } >++ /* Set the font item's image to match the font of the item. */ >++ Font ft = cellFont; >++ if (ft == null) ft = table1.getItem (0).getFont (1); >++ TableItem item = colorAndFontTable.getItem(CELL_FONT); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (fontImage(ft)); >++ item.setFont(ft); >++ colorAndFontTable.layout (); >++ } >++ >++ /** >++ * Sets the background color of TableItem [0]. >++ */ >++ void setItemBackground () { >++ if (!instance.startup) { >++ table1.getItem (0).setBackground (itemBackgroundColor); >++ } >++ /* Set the background color item's image to match the background color of the item. */ >++ Color color = itemBackgroundColor; >++ if (color == null) color = table1.getItem (0).getBackground (); >++ TableItem item = colorAndFontTable.getItem(ITEM_BACKGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the foreground color of TableItem [0]. >++ */ >++ void setItemForeground () { >++ if (!instance.startup) { >++ table1.getItem (0).setForeground (itemForegroundColor); >++ } >++ /* Set the foreground color item's image to match the foreground color of the item. */ >++ Color color = itemForegroundColor; >++ if (color == null) color = table1.getItem (0).getForeground (); >++ TableItem item = colorAndFontTable.getItem(ITEM_FOREGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the font of TableItem 0. >++ */ >++ void setItemFont () { >++ if (!instance.startup) { >++ table1.getItem (0).setFont (itemFont); >++ } >++ /* Set the font item's image to match the font of the item. */ >++ Font ft = itemFont; >++ if (ft == null) ft = table1.getItem (0).getFont (); >++ TableItem item = colorAndFontTable.getItem(ITEM_FONT); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (fontImage(ft)); >++ item.setFont(ft); >++ colorAndFontTable.layout (); >++ } >++ >++ /** >++ * Sets the moveable columns state of the "Example" widgets. >++ */ >++ void setColumnsMoveable () { >++ boolean selection = moveableColumns.getSelection(); >++ TableColumn[] columns = table1.getColumns(); >++ for (int i = 0; i < columns.length; i++) { >++ columns[i].setMoveable(selection); >++ } >++ } >++ >++ /** >++ * Sets the resizable columns state of the "Example" widgets. >++ */ >++ void setColumnsResizable () { >++ boolean selection = resizableColumns.getSelection(); >++ TableColumn[] columns = table1.getColumns(); >++ for (int i = 0; i < columns.length; i++) { >++ columns[i].setResizable(selection); >++ } >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ setItemBackground (); >++ setItemForeground (); >++ setItemFont (); >++ setCellBackground (); >++ setCellForeground (); >++ setCellFont (); >++ if (!instance.startup) { >++ setColumnsMoveable (); >++ setColumnsResizable (); >++ setWidgetHeaderVisible (); >++ setWidgetSortIndicator (); >++ setWidgetLinesVisible (); >++ } >++ super.setExampleWidgetState (); >++ noScrollButton.setSelection ((table1.getStyle () & SWT.NO_SCROLL) != 0); >++ checkButton.setSelection ((table1.getStyle () & SWT.CHECK) != 0); >++ fullSelectionButton.setSelection ((table1.getStyle () & SWT.FULL_SELECTION) != 0); >++ hideSelectionButton.setSelection ((table1.getStyle () & SWT.HIDE_SELECTION) != 0); >++ try { >++ TableColumn column = table1.getColumn(0); >++ moveableColumns.setSelection (column.getMoveable()); >++ resizableColumns.setSelection (column.getResizable()); >++ } catch (IllegalArgumentException ex) {} >++ headerVisibleButton.setSelection (table1.getHeaderVisible()); >++ linesVisibleButton.setSelection (table1.getLinesVisible()); >++ } >++ >++ /** >++ * Sets the header visible state of the "Example" widgets. >++ */ >++ void setWidgetHeaderVisible () { >++ table1.setHeaderVisible (headerVisibleButton.getSelection ()); >++ } >++ >++ /** >++ * Sets the sort indicator state of the "Example" widgets. >++ */ >++ void setWidgetSortIndicator () { >++ TableColumn [] columns = table1.getColumns(); >++ if (sortIndicatorButton.getSelection ()) { >++ /* Reset to known state: 'down' on column 0. */ >++ table1.setSortDirection (SWT.DOWN); >++ for (int i = 0; i < columns.length; i++) { >++ TableColumn column = columns[i]; >++ if (i == 0) table1.setSortColumn(column); >++ SelectionListener listener = new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ int sortDirection = SWT.DOWN; >++ if (e.widget == table1.getSortColumn()) { >++ /* If the sort column hasn't changed, cycle down -> up -> none. */ >++ switch (table1.getSortDirection ()) { >++ case SWT.DOWN: sortDirection = SWT.UP; break; >++ case SWT.UP: sortDirection = SWT.NONE; break; >++ } >++ } else { >++ table1.setSortColumn((TableColumn)e.widget); >++ } >++ table1.setSortDirection (sortDirection); >++ } >++ }; >++ column.addSelectionListener(listener); >++ column.setData("SortListener", listener); //$NON-NLS-1$ >++ } >++ } else { >++ table1.setSortDirection (SWT.NONE); >++ for (int j = 0; j < columns.length; j++) { >++ SelectionListener listener = (SelectionListener)columns[j].getData("SortListener"); //$NON-NLS-1$ >++ if (listener != null) columns[j].removeSelectionListener(listener); >++ } >++ } >++ } >++ >++ /** >++ * Sets the lines visible state of the "Example" widgets. >++ */ >++ void setWidgetLinesVisible () { >++ table1.setLinesVisible (linesVisibleButton.getSelection ()); >++ } >++ >++ protected void specialPopupMenuItems(Menu menu, Event event) { >++ MenuItem item = new MenuItem(menu, SWT.PUSH); >++ item.setText("getItem(Point) on mouse coordinates"); >++ menuMouseCoords = table1.toControl(new Point(event.x, event.y)); >++ item.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + table1.getItem(menuMouseCoords)); >++ eventConsole.append ("\n"); >++ } >++ }); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/TextTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/TextTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/TextTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/TextTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,190 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.events.*; >++import org.eclipse.swt.layout.*; >++ >++class TextTab extends ScrollableTab { >++ /* Example widgets and groups that contain them */ >++ Text text; >++ Group textGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button wrapButton, readOnlyButton, passwordButton, searchButton, iconCancelButton, iconSearchButton; >++ Button leftButton, centerButton, rightButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ TextTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the text widget */ >++ textGroup = new Group (exampleGroup, SWT.NONE); >++ textGroup.setLayout (new GridLayout ()); >++ textGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ textGroup.setText ("Text"); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ 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 (wrapButton.getSelection ()) style |= SWT.WRAP; >++ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >++ if (passwordButton.getSelection ()) style |= SWT.PASSWORD; >++ if (searchButton.getSelection ()) style |= SWT.SEARCH; >++ if (iconCancelButton.getSelection ()) style |= SWT.ICON_CANCEL; >++ if (iconSearchButton.getSelection ()) style |= SWT.ICON_SEARCH; >++ if (borderButton.getSelection ()) style |= SWT.BORDER; >++ if (leftButton.getSelection ()) style |= SWT.LEFT; >++ if (centerButton.getSelection ()) style |= SWT.CENTER; >++ if (rightButton.getSelection ()) style |= SWT.RIGHT; >++ >++ /* Create the example widgets */ >++ text = new Text (textGroup, style); >++ text.setText (ControlExample.getResourceString("Example_string") + Text.DELIMITER + ControlExample.getResourceString("One_Two_Three")); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup(); >++ >++ /* Create the extra widgets */ >++ wrapButton = new Button (styleGroup, SWT.CHECK); >++ wrapButton.setText ("SWT.WRAP"); >++ readOnlyButton = new Button (styleGroup, SWT.CHECK); >++ readOnlyButton.setText ("SWT.READ_ONLY"); >++ passwordButton = new Button (styleGroup, SWT.CHECK); >++ passwordButton.setText ("SWT.PASSWORD"); >++ searchButton = new Button (styleGroup, SWT.CHECK); >++ searchButton.setText ("SWT.SEARCH"); >++ iconCancelButton = new Button (styleGroup, SWT.CHECK); >++ iconCancelButton.setText ("SWT.ICON_CANCEL"); >++ iconSearchButton = new Button (styleGroup, SWT.CHECK); >++ iconSearchButton.setText ("SWT.ICON_SEARCH"); >++ >++ Composite alignmentGroup = new Composite (styleGroup, SWT.NONE); >++ GridLayout layout = new GridLayout (); >++ layout.marginWidth = layout.marginHeight = 0; >++ alignmentGroup.setLayout (layout); >++ alignmentGroup.setLayoutData (new GridData (GridData.FILL_BOTH)); >++ leftButton = new Button (alignmentGroup, SWT.RADIO); >++ leftButton.setText ("SWT.LEFT"); >++ centerButton = new Button (alignmentGroup, SWT.RADIO); >++ centerButton.setText ("SWT.CENTER"); >++ rightButton = new Button (alignmentGroup, SWT.RADIO); >++ rightButton.setText ("SWT.RIGHT"); >++ } >++ >++ /** >++ * Creates the tab folder page. >++ * >++ * @param tabFolder org.eclipse.swt.widgets.TabFolder >++ * @return the new page for the tab folder >++ */ >++ Composite createTabFolderPage (TabFolder tabFolder) { >++ super.createTabFolderPage (tabFolder); >++ >++ /* >++ * Add a resize listener to the tabFolderPage so that >++ * if the user types into the example widget to change >++ * its preferred size, and then resizes the shell, we >++ * recalculate the preferred size correctly. >++ */ >++ tabFolderPage.addControlListener(new ControlAdapter() { >++ public void controlResized(ControlEvent e) { >++ setExampleWidgetSize (); >++ } >++ }); >++ >++ return tabFolderPage; >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {text}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"DoubleClickEnabled", "EchoChar", "Editable", "Message", "Orientation", "Selection", "Tabs", "Text", "TextLimit", "ToolTipText", "TopIndex"}; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Text"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ wrapButton.setSelection ((text.getStyle () & SWT.WRAP) != 0); >++ readOnlyButton.setSelection ((text.getStyle () & SWT.READ_ONLY) != 0); >++ passwordButton.setSelection ((text.getStyle () & SWT.PASSWORD) != 0); >++ searchButton.setSelection ((text.getStyle () & SWT.SEARCH) != 0); >++ leftButton.setSelection ((text.getStyle () & SWT.LEFT) != 0); >++ centerButton.setSelection ((text.getStyle () & SWT.CENTER) != 0); >++ rightButton.setSelection ((text.getStyle () & SWT.RIGHT) != 0); >++ >++ /* Special case: ICON_CANCEL and H_SCROLL have the same value, >++ * and ICON_SEARCH and V_SCROLL have the same value, >++ * so to avoid confusion, only set CANCEL if SEARCH is set. */ >++ if ((text.getStyle () & SWT.SEARCH) != 0) { >++ iconCancelButton.setSelection ((text.getStyle () & SWT.ICON_CANCEL) != 0); >++ iconSearchButton.setSelection ((text.getStyle () & SWT.ICON_SEARCH) != 0); >++ horizontalButton.setSelection (false); >++ verticalButton.setSelection (false); >++ } else { >++ iconCancelButton.setSelection (false); >++ iconSearchButton.setSelection (false); >++ horizontalButton.setSelection ((text.getStyle () & SWT.H_SCROLL) != 0); >++ verticalButton.setSelection ((text.getStyle () & SWT.V_SCROLL) != 0); >++ } >++ >++ passwordButton.setEnabled ((text.getStyle () & SWT.SINGLE) != 0); >++ searchButton.setEnabled ((text.getStyle () & SWT.SINGLE) != 0); >++ iconCancelButton.setEnabled ((text.getStyle () & SWT.SEARCH) != 0); >++ iconSearchButton.setEnabled ((text.getStyle () & SWT.SEARCH) != 0); >++ wrapButton.setEnabled ((text.getStyle () & SWT.MULTI) != 0); >++ horizontalButton.setEnabled ((text.getStyle () & SWT.MULTI) != 0); >++ verticalButton.setEnabled ((text.getStyle () & SWT.MULTI) != 0); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ToolBarTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ToolBarTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ToolBarTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ToolBarTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,364 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++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, imageTextToolBar; >++ Group imageToolBarGroup, textToolBarGroup, imageTextToolBarGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button horizontalButton, verticalButton, flatButton, shadowOutButton, wrapButton, rightButton; >++ >++ /* Other widgets added to the "Other" group */ >++ Button comboChildButton; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ToolBarTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the image tool bar */ >++ imageToolBarGroup = new Group (exampleGroup, SWT.NONE); >++ imageToolBarGroup.setLayout (new GridLayout ()); >++ imageToolBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ imageToolBarGroup.setText (ControlExample.getResourceString("Image_ToolBar")); >++ >++ /* Create a group for the text tool bar */ >++ textToolBarGroup = new Group (exampleGroup, SWT.NONE); >++ textToolBarGroup.setLayout (new GridLayout ()); >++ textToolBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ textToolBarGroup.setText (ControlExample.getResourceString("Text_ToolBar")); >++ >++ /* Create a group for the image and text tool bar */ >++ imageTextToolBarGroup = new Group (exampleGroup, SWT.NONE); >++ imageTextToolBarGroup.setLayout (new GridLayout ()); >++ imageTextToolBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ imageTextToolBarGroup.setText (ControlExample.getResourceString("ImageText_ToolBar")); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (horizontalButton.getSelection()) style |= SWT.HORIZONTAL; >++ if (verticalButton.getSelection()) style |= SWT.VERTICAL; >++ if (flatButton.getSelection()) style |= SWT.FLAT; >++ if (wrapButton.getSelection()) style |= SWT.WRAP; >++ if (borderButton.getSelection()) style |= SWT.BORDER; >++ if (shadowOutButton.getSelection()) style |= SWT.SHADOW_OUT; >++ if (rightButton.getSelection()) style |= SWT.RIGHT; >++ >++ /* >++ * 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 (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText("SWT.PUSH"); >++ item = new ToolItem (imageToolBar, SWT.PUSH); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.PUSH"); >++ item = new ToolItem (imageToolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ item = new ToolItem (imageToolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciOpenFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ item = new ToolItem (imageToolBar, SWT.CHECK); >++ item.setImage (instance.images[ControlExample.ciTarget]); >++ item.setToolTipText ("SWT.CHECK"); >++ item = new ToolItem (imageToolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ item = new ToolItem (imageToolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setToolTipText ("SWT.RADIO"); >++ item = new ToolItem (imageToolBar, SWT.SEPARATOR); >++ item.setToolTipText("SWT.SEPARATOR"); >++ if (comboChildButton.getSelection ()) { >++ Combo combo = new Combo (imageToolBar, SWT.NONE); >++ combo.setItems (new String [] {"250", "500", "750"}); >++ combo.setText (combo.getItem (0)); >++ combo.pack (); >++ item.setWidth (combo.getSize ().x); >++ item.setControl (combo); >++ } >++ item = new ToolItem (imageToolBar, SWT.DROP_DOWN); >++ item.setImage (instance.images[ControlExample.ciTarget]); >++ item.setToolTipText ("SWT.DROP_DOWN"); >++ item.addSelectionListener(new DropDownSelectionListener()); >++ >++ /* Create the text tool bar */ >++ textToolBar = new ToolBar (textToolBarGroup, style); >++ item = new ToolItem (textToolBar, SWT.PUSH); >++ item.setText (ControlExample.getResourceString("Push")); >++ item.setToolTipText("SWT.PUSH"); >++ item = new ToolItem (textToolBar, SWT.PUSH); >++ item.setText (ControlExample.getResourceString("Push")); >++ item.setToolTipText("SWT.PUSH"); >++ item = new ToolItem (textToolBar, SWT.RADIO); >++ item.setText (ControlExample.getResourceString("Radio")); >++ item.setToolTipText("SWT.RADIO"); >++ item = new ToolItem (textToolBar, SWT.RADIO); >++ item.setText (ControlExample.getResourceString("Radio")); >++ item.setToolTipText("SWT.RADIO"); >++ item = new ToolItem (textToolBar, SWT.CHECK); >++ item.setText (ControlExample.getResourceString("Check")); >++ item.setToolTipText("SWT.CHECK"); >++ item = new ToolItem (textToolBar, SWT.RADIO); >++ item.setText (ControlExample.getResourceString("Radio")); >++ item.setToolTipText("SWT.RADIO"); >++ item = new ToolItem (textToolBar, SWT.RADIO); >++ item.setText (ControlExample.getResourceString("Radio")); >++ item.setToolTipText("SWT.RADIO"); >++ item = new ToolItem (textToolBar, SWT.SEPARATOR); >++ item.setToolTipText("SWT.SEPARATOR"); >++ if (comboChildButton.getSelection ()) { >++ Combo combo = new Combo (textToolBar, SWT.NONE); >++ combo.setItems (new String [] {"250", "500", "750"}); >++ combo.setText (combo.getItem (0)); >++ combo.pack (); >++ item.setWidth (combo.getSize ().x); >++ item.setControl (combo); >++ } >++ item = new ToolItem (textToolBar, SWT.DROP_DOWN); >++ item.setText (ControlExample.getResourceString("Drop_Down")); >++ item.setToolTipText("SWT.DROP_DOWN"); >++ item.addSelectionListener(new DropDownSelectionListener()); >++ >++ /* Create the image and text tool bar */ >++ imageTextToolBar = new ToolBar (imageTextToolBarGroup, style); >++ item = new ToolItem (imageTextToolBar, SWT.PUSH); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setText (ControlExample.getResourceString("Push")); >++ item.setToolTipText("SWT.PUSH"); >++ item = new ToolItem (imageTextToolBar, SWT.PUSH); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setText (ControlExample.getResourceString("Push")); >++ item.setToolTipText("SWT.PUSH"); >++ item = new ToolItem (imageTextToolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciOpenFolder]); >++ item.setText (ControlExample.getResourceString("Radio")); >++ item.setToolTipText("SWT.RADIO"); >++ item = new ToolItem (imageTextToolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciOpenFolder]); >++ item.setText (ControlExample.getResourceString("Radio")); >++ item.setToolTipText("SWT.RADIO"); >++ item = new ToolItem (imageTextToolBar, SWT.CHECK); >++ item.setImage (instance.images[ControlExample.ciTarget]); >++ item.setText (ControlExample.getResourceString("Check")); >++ item.setToolTipText("SWT.CHECK"); >++ item = new ToolItem (imageTextToolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setText (ControlExample.getResourceString("Radio")); >++ item.setToolTipText("SWT.RADIO"); >++ item = new ToolItem (imageTextToolBar, SWT.RADIO); >++ item.setImage (instance.images[ControlExample.ciClosedFolder]); >++ item.setText (ControlExample.getResourceString("Radio")); >++ item.setToolTipText("SWT.RADIO"); >++ item = new ToolItem (imageTextToolBar, SWT.SEPARATOR); >++ item.setToolTipText("SWT.SEPARATOR"); >++ if (comboChildButton.getSelection ()) { >++ Combo combo = new Combo (imageTextToolBar, SWT.NONE); >++ combo.setItems (new String [] {"250", "500", "750"}); >++ combo.setText (combo.getItem (0)); >++ combo.pack (); >++ item.setWidth (combo.getSize ().x); >++ item.setControl (combo); >++ } >++ item = new ToolItem (imageTextToolBar, SWT.DROP_DOWN); >++ item.setImage (instance.images[ControlExample.ciTarget]); >++ item.setText (ControlExample.getResourceString("Drop_Down")); >++ item.setToolTipText("SWT.DROP_DOWN"); >++ item.addSelectionListener(new DropDownSelectionListener()); >++ >++ /* >++ * 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 "Other" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ >++ /* Create display controls specific to this example */ >++ comboChildButton = new Button (otherGroup, SWT.CHECK); >++ comboChildButton.setText (ControlExample.getResourceString("Combo_child")); >++ >++ /* Add the listeners */ >++ comboChildButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ recreateExampleWidgets (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup(); >++ >++ /* Create the extra widgets */ >++ horizontalButton = new Button (styleGroup, SWT.RADIO); >++ horizontalButton.setText ("SWT.HORIZONTAL"); >++ verticalButton = new Button (styleGroup, SWT.RADIO); >++ verticalButton.setText ("SWT.VERTICAL"); >++ flatButton = new Button (styleGroup, SWT.CHECK); >++ flatButton.setText ("SWT.FLAT"); >++ shadowOutButton = new Button (styleGroup, SWT.CHECK); >++ shadowOutButton.setText ("SWT.SHADOW_OUT"); >++ wrapButton = new Button (styleGroup, SWT.CHECK); >++ wrapButton.setText ("SWT.WRAP"); >++ rightButton = new Button (styleGroup, SWT.CHECK); >++ rightButton.setText ("SWT.RIGHT"); >++ borderButton = new Button (styleGroup, SWT.CHECK); >++ borderButton.setText ("SWT.BORDER"); >++ } >++ >++ void disposeExampleWidgets () { >++ super.disposeExampleWidgets (); >++ } >++ >++ /** >++ * Gets the "Example" widget children's items, if any. >++ * >++ * @return an array containing the example widget children's items >++ */ >++ Item [] getExampleWidgetItems () { >++ Item [] imageToolBarItems = imageToolBar.getItems(); >++ Item [] textToolBarItems = textToolBar.getItems(); >++ Item [] imageTextToolBarItems = imageTextToolBar.getItems(); >++ Item [] allItems = new Item [imageToolBarItems.length + textToolBarItems.length + imageTextToolBarItems.length]; >++ System.arraycopy(imageToolBarItems, 0, allItems, 0, imageToolBarItems.length); >++ System.arraycopy(textToolBarItems, 0, allItems, imageToolBarItems.length, textToolBarItems.length); >++ System.arraycopy(imageTextToolBarItems, 0, allItems, imageToolBarItems.length + textToolBarItems.length, imageTextToolBarItems.length); >++ return allItems; >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {imageToolBar, textToolBar, imageTextToolBar}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"ToolTipText"}; >++ } >++ >++ /** >++ * Gets the short text for the tab folder item. >++ */ >++ String getShortTabText() { >++ return "TB"; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "ToolBar"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ super.setExampleWidgetState (); >++ horizontalButton.setSelection ((imageToolBar.getStyle () & SWT.HORIZONTAL) != 0); >++ verticalButton.setSelection ((imageToolBar.getStyle () & SWT.VERTICAL) != 0); >++ flatButton.setSelection ((imageToolBar.getStyle () & SWT.FLAT) != 0); >++ wrapButton.setSelection ((imageToolBar.getStyle () & SWT.WRAP) != 0); >++ shadowOutButton.setSelection ((imageToolBar.getStyle () & SWT.SHADOW_OUT) != 0); >++ borderButton.setSelection ((imageToolBar.getStyle () & SWT.BORDER) != 0); >++ rightButton.setSelection ((imageToolBar.getStyle () & SWT.RIGHT) != 0); >++ } >++ >++ /** >++ * Listens to widgetSelected() events on SWT.DROP_DOWN type ToolItems >++ * and opens/closes a menu when appropriate. >++ */ >++ class DropDownSelectionListener extends SelectionAdapter { >++ private Menu menu = null; >++ >++ public void widgetSelected(SelectionEvent event) { >++ // Create the menu if it has not already been created >++ if (menu == null) { >++ // Lazy create the menu. >++ ToolBar toolbar = ((ToolItem) event.widget).getParent(); >++ int style = toolbar.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT); >++ menu = new Menu(shell, style | SWT.POP_UP); >++ for (int i = 0; i < 9; ++i) { >++ final String text = ControlExample.getResourceString("DropDownData_" + i); >++ if (text.length() != 0) { >++ MenuItem menuItem = new MenuItem(menu, SWT.NONE); >++ menuItem.setText(text); >++ } else { >++ new MenuItem(menu, SWT.SEPARATOR); >++ } >++ } >++ } >++ >++ /** >++ * 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 menu below and vertically aligned with the the drop down tool button. >++ final ToolItem toolItem = (ToolItem) event.widget; >++ final ToolBar toolBar = toolItem.getParent(); >++ >++ Point point = toolBar.toDisplay(new Point(event.x, event.y)); >++ menu.setLocation(point.x, point.y); >++ menu.setVisible(true); >++ } >++ } >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/ToolTipTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/ToolTipTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/ToolTipTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/ToolTipTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,260 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.events.*; >++import org.eclipse.swt.layout.*; >++ >++class ToolTipTab extends Tab { >++ >++ /* Example widgets and groups that contain them */ >++ ToolTip toolTip1; >++ Group toolTipGroup; >++ >++ /* Style widgets added to the "Style" group */ >++ Button balloonButton, iconErrorButton, iconInformationButton, iconWarningButton, noIconButton; >++ >++ /* Other widgets added to the "Other" group */ >++ Button autoHideButton, showInTrayButton; >++ >++ Tray tray; >++ TrayItem trayItem; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ ToolTipTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the tooltip visibility check box */ >++ toolTipGroup = new Group (exampleGroup, SWT.NONE); >++ toolTipGroup.setLayout (new GridLayout ()); >++ toolTipGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ toolTipGroup.setText ("ToolTip"); >++ visibleButton = new Button(toolTipGroup, SWT.CHECK); >++ visibleButton.setText(ControlExample.getResourceString("Visible")); >++ visibleButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleWidgetVisibility (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ if (balloonButton.getSelection ()) style |= SWT.BALLOON; >++ if (iconErrorButton.getSelection ()) style |= SWT.ICON_ERROR; >++ if (iconInformationButton.getSelection ()) style |= SWT.ICON_INFORMATION; >++ if (iconWarningButton.getSelection ()) style |= SWT.ICON_WARNING; >++ >++ /* Create the example widgets */ >++ toolTip1 = new ToolTip (shell, style); >++ toolTip1.setText(ControlExample.getResourceString("ToolTip_Title")); >++ toolTip1.setMessage(ControlExample.getResourceString("Example_string")); >++ } >++ >++ /** >++ * Creates the tab folder page. >++ * >++ * @param tabFolder org.eclipse.swt.widgets.TabFolder >++ * @return the new page for the tab folder >++ */ >++ Composite createTabFolderPage (TabFolder tabFolder) { >++ super.createTabFolderPage (tabFolder); >++ >++ /* >++ * Add a resize listener to the tabFolderPage so that >++ * if the user types into the example widget to change >++ * its preferred size, and then resizes the shell, we >++ * recalculate the preferred size correctly. >++ */ >++ tabFolderPage.addControlListener(new ControlAdapter() { >++ public void controlResized(ControlEvent e) { >++ setExampleWidgetSize (); >++ } >++ }); >++ >++ return tabFolderPage; >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup () { >++ super.createStyleGroup (); >++ >++ /* Create the extra widgets */ >++ balloonButton = new Button (styleGroup, SWT.CHECK); >++ balloonButton.setText ("SWT.BALLOON"); >++ iconErrorButton = new Button (styleGroup, SWT.RADIO); >++ iconErrorButton.setText("SWT.ICON_ERROR"); >++ iconInformationButton = new Button (styleGroup, SWT.RADIO); >++ iconInformationButton.setText("SWT.ICON_INFORMATION"); >++ iconWarningButton = new Button (styleGroup, SWT.RADIO); >++ iconWarningButton.setText("SWT.ICON_WARNING"); >++ noIconButton = new Button (styleGroup, SWT.RADIO); >++ noIconButton.setText(ControlExample.getResourceString("No_Icon")); >++ } >++ >++ void createColorAndFontGroup () { >++ // ToolTip does not need a color and font group. >++ } >++ >++ void createOtherGroup () { >++ /* Create the group */ >++ otherGroup = new Group (controlGroup, SWT.NONE); >++ otherGroup.setLayout (new GridLayout ()); >++ otherGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >++ otherGroup.setText (ControlExample.getResourceString("Other")); >++ >++ /* Create the controls */ >++ autoHideButton = new Button(otherGroup, SWT.CHECK); >++ autoHideButton.setText(ControlExample.getResourceString("AutoHide")); >++ showInTrayButton = new Button(otherGroup, SWT.CHECK); >++ showInTrayButton.setText(ControlExample.getResourceString("Show_In_Tray")); >++ tray = display.getSystemTray(); >++ showInTrayButton.setEnabled(tray != null); >++ >++ /* Add the listeners */ >++ autoHideButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setExampleWidgetAutoHide (); >++ } >++ }); >++ showInTrayButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ showExampleWidgetInTray (); >++ } >++ }); >++ shell.addDisposeListener(new DisposeListener() { >++ public void widgetDisposed(DisposeEvent event) { >++ disposeTrayItem(); >++ } >++ }); >++ >++ /* Set the default state */ >++ autoHideButton.setSelection(true); >++ } >++ >++ void createSizeGroup () { >++ // ToolTip does not need a size group. >++ } >++ >++ void createBackgroundModeGroup () { >++ // ToolTip does not need a background mode group. >++ } >++ >++ /** >++ * Disposes the "Example" widgets. >++ */ >++ void disposeExampleWidgets () { >++ disposeTrayItem(); >++ super.disposeExampleWidgets(); >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ // Tab uses this for many things - widgets would only get set/get, listeners, and dispose. >++ Widget[] getExampleWidgets () { >++ return new Widget [] {toolTip1}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"Message", "Text"}; >++ } >++ >++ /** >++ * Gets the short text for the tab folder item. >++ */ >++ String getShortTabText() { >++ return "TT"; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "ToolTip"; >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ showExampleWidgetInTray (); >++ setExampleWidgetAutoHide (); >++ super.setExampleWidgetState (); >++ balloonButton.setSelection ((toolTip1.getStyle () & SWT.BALLOON) != 0); >++ iconErrorButton.setSelection ((toolTip1.getStyle () & SWT.ICON_ERROR) != 0); >++ iconInformationButton.setSelection ((toolTip1.getStyle () & SWT.ICON_INFORMATION) != 0); >++ iconWarningButton.setSelection ((toolTip1.getStyle () & SWT.ICON_WARNING) != 0); >++ noIconButton.setSelection ((toolTip1.getStyle () & (SWT.ICON_ERROR | SWT.ICON_INFORMATION | SWT.ICON_WARNING)) == 0); >++ autoHideButton.setSelection(toolTip1.getAutoHide()); >++ } >++ >++ /** >++ * Sets the visibility of the "Example" widgets. >++ */ >++ void setExampleWidgetVisibility () { >++ toolTip1.setVisible (visibleButton.getSelection ()); >++ } >++ >++ /** >++ * Sets the autoHide state of the "Example" widgets. >++ */ >++ void setExampleWidgetAutoHide () { >++ toolTip1.setAutoHide(autoHideButton.getSelection ()); >++ } >++ >++ void showExampleWidgetInTray () { >++ if (showInTrayButton.getSelection ()) { >++ createTrayItem(); >++ trayItem.setToolTip(toolTip1); >++ } else { >++ disposeTrayItem(); >++ } >++ } >++ >++ void createTrayItem() { >++ if (trayItem == null) { >++ trayItem = new TrayItem(tray, SWT.NONE); >++ trayItem.setImage(instance.images[ControlExample.ciTarget]); >++ } >++ } >++ >++ void disposeTrayItem() { >++ if (trayItem != null) { >++ trayItem.setToolTip(null); >++ trayItem.dispose(); >++ trayItem = null; >++ } >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/TreeTab.java >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/TreeTab.java >+diff -N src/org/eclipse/swt/examples/mirroringTest/TreeTab.java >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/TreeTab.java 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,783 @@ >++/******************************************************************************* >++ * Copyright (c) 2000, 2007 IBM Corporation and others. >++ * All rights reserved. This program and the accompanying materials >++ * are made available under the terms of the Eclipse Public License v1.0 >++ * which accompanies this distribution, and is available at >++ * http://www.eclipse.org/legal/epl-v10.html >++ * >++ * Contributors: >++ * IBM Corporation - initial API and implementation >++ *******************************************************************************/ >++package org.eclipse.swt.examples.mirroringTest; >++ >++ >++import org.eclipse.swt.*; >++import org.eclipse.swt.layout.*; >++import org.eclipse.swt.widgets.*; >++import org.eclipse.swt.graphics.*; >++import org.eclipse.swt.events.*; >++ >++class TreeTab extends ScrollableTab { >++ /* Example widgets and groups that contain them */ >++ Tree tree1, tree2; >++ TreeItem textNode1, imageNode1; >++ Group treeGroup, imageTreeGroup, itemGroup; >++ >++ /* Size widgets added to the "Size" group */ >++ Button packColumnsButton; >++ >++ /* Style widgets added to the "Style" group */ >++ Button noScrollButton, checkButton, fullSelectionButton; >++ >++ /* Other widgets added to the "Other" group */ >++ Button multipleColumns, moveableColumns, resizableColumns, headerVisibleButton, sortIndicatorButton, headerImagesButton, subImagesButton, linesVisibleButton; >++ >++ /* Controls and resources added to the "Colors and Fonts" group */ >++ static final int ITEM_FOREGROUND_COLOR = 3; >++ static final int ITEM_BACKGROUND_COLOR = 4; >++ static final int ITEM_FONT = 5; >++ static final int CELL_FOREGROUND_COLOR = 6; >++ static final int CELL_BACKGROUND_COLOR = 7; >++ static final int CELL_FONT = 8; >++ Color itemForegroundColor, itemBackgroundColor, cellForegroundColor, cellBackgroundColor; >++ Font itemFont, cellFont; >++ >++ static String [] columnTitles = {ControlExample.getResourceString("TableTitle_0"), >++ ControlExample.getResourceString("TableTitle_1"), >++ ControlExample.getResourceString("TableTitle_2"), >++ ControlExample.getResourceString("TableTitle_3")}; >++ >++ static String[][] tableData = { >++ { ControlExample.getResourceString("TableLine0_0"), >++ ControlExample.getResourceString("TableLine0_1"), >++ ControlExample.getResourceString("TableLine0_2"), >++ ControlExample.getResourceString("TableLine0_3") }, >++ { ControlExample.getResourceString("TableLine1_0"), >++ ControlExample.getResourceString("TableLine1_1"), >++ ControlExample.getResourceString("TableLine1_2"), >++ ControlExample.getResourceString("TableLine1_3") }, >++ { ControlExample.getResourceString("TableLine2_0"), >++ ControlExample.getResourceString("TableLine2_1"), >++ ControlExample.getResourceString("TableLine2_2"), >++ ControlExample.getResourceString("TableLine2_3") } }; >++ >++ Point menuMouseCoords; >++ >++ /** >++ * Creates the Tab within a given instance of ControlExample. >++ */ >++ TreeTab(ControlExample instance) { >++ super(instance); >++ } >++ >++ /** >++ * Creates the "Colors and Fonts" group. >++ */ >++ void createColorAndFontGroup () { >++ super.createColorAndFontGroup(); >++ >++ TableItem item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Item_Foreground_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Item_Background_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Item_Font")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Cell_Foreground_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Cell_Background_Color")); >++ item = new TableItem(colorAndFontTable, SWT.None); >++ item.setText(ControlExample.getResourceString ("Cell_Font")); >++ >++ shell.addDisposeListener(new DisposeListener() { >++ public void widgetDisposed(DisposeEvent event) { >++ if (itemBackgroundColor != null) itemBackgroundColor.dispose(); >++ if (itemForegroundColor != null) itemForegroundColor.dispose(); >++ if (itemFont != null) itemFont.dispose(); >++ if (cellBackgroundColor != null) cellBackgroundColor.dispose(); >++ if (cellForegroundColor != null) cellForegroundColor.dispose(); >++ if (cellFont != null) cellFont.dispose(); >++ itemBackgroundColor = null; >++ itemForegroundColor = null; >++ itemFont = null; >++ cellBackgroundColor = null; >++ cellForegroundColor = null; >++ cellFont = null; >++ } >++ }); >++ } >++ >++ void changeFontOrColor(int index) { >++ switch (index) { >++ case ITEM_FOREGROUND_COLOR: { >++ Color oldColor = itemForegroundColor; >++ if (oldColor == null) oldColor = textNode1.getForeground (); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = itemForegroundColor; >++ itemForegroundColor = new Color (display, rgb); >++ setItemForeground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case ITEM_BACKGROUND_COLOR: { >++ Color oldColor = itemBackgroundColor; >++ if (oldColor == null) oldColor = textNode1.getBackground (); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = itemBackgroundColor; >++ itemBackgroundColor = new Color (display, rgb); >++ setItemBackground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case ITEM_FONT: { >++ Font oldFont = itemFont; >++ if (oldFont == null) oldFont = textNode1.getFont (); >++ fontDialog.setFontList(oldFont.getFontData()); >++ FontData fontData = fontDialog.open (); >++ if (fontData == null) return; >++ oldFont = itemFont; >++ itemFont = new Font (display, fontData); >++ setItemFont (); >++ setExampleWidgetSize (); >++ if (oldFont != null) oldFont.dispose (); >++ } >++ break; >++ case CELL_FOREGROUND_COLOR: { >++ Color oldColor = cellForegroundColor; >++ if (oldColor == null) oldColor = textNode1.getForeground (1); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = cellForegroundColor; >++ cellForegroundColor = new Color (display, rgb); >++ setCellForeground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case CELL_BACKGROUND_COLOR: { >++ Color oldColor = cellBackgroundColor; >++ if (oldColor == null) oldColor = textNode1.getBackground (1); >++ colorDialog.setRGB(oldColor.getRGB()); >++ RGB rgb = colorDialog.open(); >++ if (rgb == null) return; >++ oldColor = cellBackgroundColor; >++ cellBackgroundColor = new Color (display, rgb); >++ setCellBackground (); >++ if (oldColor != null) oldColor.dispose (); >++ } >++ break; >++ case CELL_FONT: { >++ Font oldFont = cellFont; >++ if (oldFont == null) oldFont = textNode1.getFont (1); >++ fontDialog.setFontList(oldFont.getFontData()); >++ FontData fontData = fontDialog.open (); >++ if (fontData == null) return; >++ oldFont = cellFont; >++ cellFont = new Font (display, fontData); >++ setCellFont (); >++ setExampleWidgetSize (); >++ if (oldFont != null) oldFont.dispose (); >++ } >++ break; >++ default: >++ super.changeFontOrColor(index); >++ } >++ } >++ >++ /** >++ * Creates the "Other" group. >++ */ >++ void createOtherGroup () { >++ super.createOtherGroup (); >++ >++ /* Create display controls specific to this example */ >++ linesVisibleButton = new Button (otherGroup, SWT.CHECK); >++ linesVisibleButton.setText (ControlExample.getResourceString("Lines_Visible")); >++ multipleColumns = new Button (otherGroup, SWT.CHECK); >++ multipleColumns.setText (ControlExample.getResourceString("Multiple_Columns")); >++ headerVisibleButton = new Button (otherGroup, SWT.CHECK); >++ headerVisibleButton.setText (ControlExample.getResourceString("Header_Visible")); >++ sortIndicatorButton = new Button (otherGroup, SWT.CHECK); >++ sortIndicatorButton.setText (ControlExample.getResourceString("Sort_Indicator")); >++ moveableColumns = new Button (otherGroup, SWT.CHECK); >++ moveableColumns.setText (ControlExample.getResourceString("Moveable_Columns")); >++ resizableColumns = new Button (otherGroup, SWT.CHECK); >++ resizableColumns.setText (ControlExample.getResourceString("Resizable_Columns")); >++ headerImagesButton = new Button (otherGroup, SWT.CHECK); >++ headerImagesButton.setText (ControlExample.getResourceString("Header_Images")); >++ subImagesButton = new Button (otherGroup, SWT.CHECK); >++ subImagesButton.setText (ControlExample.getResourceString("Sub_Images")); >++ >++ /* Add the listeners */ >++ linesVisibleButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetLinesVisible (); >++ } >++ }); >++ multipleColumns.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ recreateExampleWidgets (); >++ } >++ }); >++ headerVisibleButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetHeaderVisible (); >++ } >++ }); >++ sortIndicatorButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setWidgetSortIndicator (); >++ } >++ }); >++ moveableColumns.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setColumnsMoveable (); >++ } >++ }); >++ resizableColumns.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ setColumnsResizable (); >++ } >++ }); >++ headerImagesButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ recreateExampleWidgets (); >++ } >++ }); >++ subImagesButton.addSelectionListener (new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ recreateExampleWidgets (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Example" group. >++ */ >++ void createExampleGroup () { >++ super.createExampleGroup (); >++ >++ /* Create a group for the text tree */ >++ treeGroup = new Group (exampleGroup, SWT.NONE); >++ treeGroup.setLayout (new GridLayout ()); >++ treeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ treeGroup.setText ("Tree"); >++ >++ /* Create a group for the image tree */ >++ imageTreeGroup = new Group (exampleGroup, SWT.NONE); >++ imageTreeGroup.setLayout (new GridLayout ()); >++ imageTreeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >++ imageTreeGroup.setText (ControlExample.getResourceString("Tree_With_Images")); >++ } >++ >++ /** >++ * Creates the "Example" widgets. >++ */ >++ void createExampleWidgets () { >++ /* Compute the widget style */ >++ int style = getDefaultStyle(); >++ 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 (noScrollButton.getSelection()) style |= SWT.NO_SCROLL; >++ if (checkButton.getSelection()) style |= SWT.CHECK; >++ if (fullSelectionButton.getSelection ()) style |= SWT.FULL_SELECTION; >++ if (borderButton.getSelection()) style |= SWT.BORDER; >++ >++ /* Create the text tree */ >++ tree1 = new Tree (treeGroup, style); >++ boolean multiColumn = multipleColumns.getSelection(); >++ if (multiColumn) { >++ for (int i = 0; i < columnTitles.length; i++) { >++ TreeColumn treeColumn = new TreeColumn(tree1, SWT.NONE); >++ treeColumn.setText(columnTitles[i]); >++ treeColumn.setToolTipText(ControlExample.getResourceString("Tooltip", new String [] {columnTitles[i]})); >++ } >++ tree1.setSortColumn(tree1.getColumn(0)); >++ } >++ for (int i = 0; i < 4; i++) { >++ TreeItem item = new TreeItem (tree1, SWT.NONE); >++ setItemText(item, i, ControlExample.getResourceString("Node_" + (i + 1))); >++ if (i < 3) { >++ TreeItem subitem = new TreeItem (item, SWT.NONE); >++ setItemText(subitem, i, ControlExample.getResourceString("Node_" + (i + 1) + "_1")); >++ } >++ } >++ TreeItem treeRoots[] = tree1.getItems (); >++ TreeItem item = new TreeItem (treeRoots[1], SWT.NONE); >++ setItemText(item, 1, ControlExample.getResourceString("Node_2_2")); >++ item = new TreeItem (item, SWT.NONE); >++ setItemText(item, 1, ControlExample.getResourceString("Node_2_2_1")); >++ textNode1 = treeRoots[0]; >++ packColumns(tree1); >++ try { >++ TreeColumn column = tree1.getColumn(0); >++ resizableColumns.setSelection (column.getResizable()); >++ } catch (IllegalArgumentException ex) {} >++ >++ /* Create the image tree */ >++ tree2 = new Tree (imageTreeGroup, style); >++ Image image = instance.images[ControlExample.ciClosedFolder]; >++ if (multiColumn) { >++ for (int i = 0; i < columnTitles.length; i++) { >++ TreeColumn treeColumn = new TreeColumn(tree2, SWT.NONE); >++ treeColumn.setText(columnTitles[i]); >++ treeColumn.setToolTipText(ControlExample.getResourceString("Tooltip", new String [] {columnTitles[i]})); >++ if (headerImagesButton.getSelection()) treeColumn.setImage(instance.images [i % 3]); >++ } >++ } >++ for (int i = 0; i < 4; i++) { >++ item = new TreeItem (tree2, SWT.NONE); >++ setItemText(item, i, ControlExample.getResourceString("Node_" + (i + 1))); >++ if (multiColumn && subImagesButton.getSelection()) { >++ for (int j = 0; j < columnTitles.length; j++) { >++ item.setImage(j, image); >++ } >++ } else { >++ item.setImage(image); >++ } >++ if (i < 3) { >++ TreeItem subitem = new TreeItem (item, SWT.NONE); >++ setItemText(subitem, i, ControlExample.getResourceString("Node_" + (i + 1) + "_1")); >++ if (multiColumn && subImagesButton.getSelection()) { >++ for (int j = 0; j < columnTitles.length; j++) { >++ subitem.setImage(j, image); >++ } >++ } else { >++ subitem.setImage(image); >++ } >++ } >++ } >++ treeRoots = tree2.getItems (); >++ item = new TreeItem (treeRoots[1], SWT.NONE); >++ setItemText(item, 1, ControlExample.getResourceString("Node_2_2")); >++ if (multiColumn && subImagesButton.getSelection()) { >++ for (int j = 0; j < columnTitles.length; j++) { >++ item.setImage(j, image); >++ } >++ } else { >++ item.setImage(image); >++ } >++ item = new TreeItem (item, SWT.NONE); >++ setItemText(item, 1, ControlExample.getResourceString("Node_2_2_1")); >++ if (multiColumn && subImagesButton.getSelection()) { >++ for (int j = 0; j < columnTitles.length; j++) { >++ item.setImage(j, image); >++ } >++ } else { >++ item.setImage(image); >++ } >++ imageNode1 = treeRoots[0]; >++ packColumns(tree2); >++ } >++ >++ void setItemText(TreeItem item, int i, String node) { >++ int index = i % 3; >++ if (multipleColumns.getSelection()) { >++ tableData [index][0] = node; >++ item.setText (tableData [index]); >++ } else { >++ item.setText (node); >++ } >++ } >++ >++ /** >++ * Creates the "Size" group. The "Size" group contains >++ * controls that allow the user to change the size of >++ * the example widgets. >++ */ >++ void createSizeGroup () { >++ super.createSizeGroup(); >++ >++ packColumnsButton = new Button (sizeGroup, SWT.PUSH); >++ packColumnsButton.setText (ControlExample.getResourceString("Pack_Columns")); >++ packColumnsButton.addSelectionListener(new SelectionAdapter () { >++ public void widgetSelected (SelectionEvent event) { >++ packColumns (tree1); >++ packColumns (tree2); >++ setExampleWidgetSize (); >++ } >++ }); >++ } >++ >++ /** >++ * Creates the "Style" group. >++ */ >++ void createStyleGroup() { >++ super.createStyleGroup(); >++ >++ /* Create the extra widgets */ >++ noScrollButton = new Button (styleGroup, SWT.CHECK); >++ noScrollButton.setText ("SWT.NO_SCROLL"); >++ noScrollButton.moveAbove(borderButton); >++ checkButton = new Button (styleGroup, SWT.CHECK); >++ checkButton.setText ("SWT.CHECK"); >++ fullSelectionButton = new Button (styleGroup, SWT.CHECK); >++ fullSelectionButton.setText ("SWT.FULL_SELECTION"); >++ } >++ >++ /** >++ * Gets the "Example" widget children's items, if any. >++ * >++ * @return an array containing the example widget children's items >++ */ >++ Item [] getExampleWidgetItems () { >++ /* Note: We do not bother collecting the tree items >++ * because tree items don't have any events. If events >++ * are ever added to TreeItem, then this needs to change. >++ */ >++ Item [] columns1 = tree1.getColumns(); >++ Item [] columns2 = tree2.getColumns(); >++ Item [] allItems = new Item [columns1.length + columns2.length]; >++ System.arraycopy(columns1, 0, allItems, 0, columns1.length); >++ System.arraycopy(columns2, 0, allItems, columns1.length, columns2.length); >++ return allItems; >++ } >++ >++ /** >++ * Gets the "Example" widget children. >++ */ >++ Widget [] getExampleWidgets () { >++ return new Widget [] {tree1, tree2}; >++ } >++ >++ /** >++ * Returns a list of set/get API method names (without the set/get prefix) >++ * that can be used to set/get values in the example control(s). >++ */ >++ String[] getMethodNames() { >++ return new String[] {"ColumnOrder", "Selection", "ToolTipText", "TopItem"}; >++ } >++ >++ Object[] parameterForType(String typeName, String value, Widget widget) { >++ if (typeName.equals("org.eclipse.swt.widgets.TreeItem")) { >++ TreeItem item = findItem(value, ((Tree) widget).getItems()); >++ if (item != null) return new Object[] {item}; >++ } >++ if (typeName.equals("[Lorg.eclipse.swt.widgets.TreeItem;")) { >++ String[] values = split(value, ','); >++ TreeItem[] items = new TreeItem[values.length]; >++ for (int i = 0; i < values.length; i++) { >++ TreeItem item = findItem(values[i], ((Tree) widget).getItems()); >++ if (item == null) break; >++ items[i] = item; >++ } >++ return new Object[] {items}; >++ } >++ return super.parameterForType(typeName, value, widget); >++ } >++ >++ TreeItem findItem(String value, TreeItem[] items) { >++ for (int i = 0; i < items.length; i++) { >++ TreeItem item = items[i]; >++ if (item.getText().equals(value)) return item; >++ item = findItem(value, item.getItems()); >++ if (item != null) return item; >++ } >++ return null; >++ } >++ >++ /** >++ * Gets the text for the tab folder item. >++ */ >++ String getTabText () { >++ return "Tree"; >++ } >++ >++ void packColumns (Tree tree) { >++ if (multipleColumns.getSelection()) { >++ int columnCount = tree.getColumnCount(); >++ for (int i = 0; i < columnCount; i++) { >++ TreeColumn treeColumn = tree.getColumn(i); >++ treeColumn.pack(); >++ } >++ } >++ } >++ >++ /** >++ * Sets the moveable columns state of the "Example" widgets. >++ */ >++ void setColumnsMoveable () { >++ boolean selection = moveableColumns.getSelection(); >++ TreeColumn[] columns1 = tree1.getColumns(); >++ for (int i = 0; i < columns1.length; i++) { >++ columns1[i].setMoveable(selection); >++ } >++ TreeColumn[] columns2 = tree2.getColumns(); >++ for (int i = 0; i < columns2.length; i++) { >++ columns2[i].setMoveable(selection); >++ } >++ } >++ >++ /** >++ * Sets the resizable columns state of the "Example" widgets. >++ */ >++ void setColumnsResizable () { >++ boolean selection = resizableColumns.getSelection(); >++ TreeColumn[] columns1 = tree1.getColumns(); >++ for (int i = 0; i < columns1.length; i++) { >++ columns1[i].setResizable(selection); >++ } >++ TreeColumn[] columns2 = tree2.getColumns(); >++ for (int i = 0; i < columns2.length; i++) { >++ columns2[i].setResizable(selection); >++ } >++ } >++ >++ /** >++ * Sets the foreground color, background color, and font >++ * of the "Example" widgets to their default settings. >++ * Also sets foreground and background color of the Node 1 >++ * TreeItems to default settings. >++ */ >++ void resetColorsAndFonts () { >++ super.resetColorsAndFonts (); >++ Color oldColor = itemForegroundColor; >++ itemForegroundColor = null; >++ setItemForeground (); >++ if (oldColor != null) oldColor.dispose(); >++ oldColor = itemBackgroundColor; >++ itemBackgroundColor = null; >++ setItemBackground (); >++ if (oldColor != null) oldColor.dispose(); >++ Font oldFont = font; >++ itemFont = null; >++ setItemFont (); >++ if (oldFont != null) oldFont.dispose(); >++ oldColor = cellForegroundColor; >++ cellForegroundColor = null; >++ setCellForeground (); >++ if (oldColor != null) oldColor.dispose(); >++ oldColor = cellBackgroundColor; >++ cellBackgroundColor = null; >++ setCellBackground (); >++ if (oldColor != null) oldColor.dispose(); >++ oldFont = font; >++ cellFont = null; >++ setCellFont (); >++ if (oldFont != null) oldFont.dispose(); >++ } >++ >++ /** >++ * Sets the state of the "Example" widgets. >++ */ >++ void setExampleWidgetState () { >++ setItemBackground (); >++ setItemForeground (); >++ setItemFont (); >++ setCellBackground (); >++ setCellForeground (); >++ setCellFont (); >++ if (!instance.startup) { >++ setColumnsMoveable (); >++ setColumnsResizable (); >++ setWidgetHeaderVisible (); >++ setWidgetSortIndicator (); >++ setWidgetLinesVisible (); >++ } >++ super.setExampleWidgetState (); >++ noScrollButton.setSelection ((tree1.getStyle () & SWT.NO_SCROLL) != 0); >++ checkButton.setSelection ((tree1.getStyle () & SWT.CHECK) != 0); >++ fullSelectionButton.setSelection ((tree1.getStyle () & SWT.FULL_SELECTION) != 0); >++ try { >++ TreeColumn column = tree1.getColumn(0); >++ moveableColumns.setSelection (column.getMoveable()); >++ resizableColumns.setSelection (column.getResizable()); >++ } catch (IllegalArgumentException ex) {} >++ headerVisibleButton.setSelection (tree1.getHeaderVisible()); >++ linesVisibleButton.setSelection (tree1.getLinesVisible()); >++ } >++ >++ /** >++ * Sets the background color of the Node 1 TreeItems in column 1. >++ */ >++ void setCellBackground () { >++ if (!instance.startup) { >++ textNode1.setBackground (1, cellBackgroundColor); >++ imageNode1.setBackground (1, cellBackgroundColor); >++ } >++ /* Set the background color item's image to match the background color of the cell. */ >++ Color color = cellBackgroundColor; >++ if (color == null) color = textNode1.getBackground (1); >++ TableItem item = colorAndFontTable.getItem(CELL_BACKGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the foreground color of the Node 1 TreeItems in column 1. >++ */ >++ void setCellForeground () { >++ if (!instance.startup) { >++ textNode1.setForeground (1, cellForegroundColor); >++ imageNode1.setForeground (1, cellForegroundColor); >++ } >++ /* Set the foreground color item's image to match the foreground color of the cell. */ >++ Color color = cellForegroundColor; >++ if (color == null) color = textNode1.getForeground (1); >++ TableItem item = colorAndFontTable.getItem(CELL_FOREGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the font of the Node 1 TreeItems in column 1. >++ */ >++ void setCellFont () { >++ if (!instance.startup) { >++ textNode1.setFont (1, cellFont); >++ imageNode1.setFont (1, cellFont); >++ } >++ /* Set the font item's image to match the font of the item. */ >++ Font ft = cellFont; >++ if (ft == null) ft = textNode1.getFont (1); >++ TableItem item = colorAndFontTable.getItem(CELL_FONT); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (fontImage(ft)); >++ item.setFont(ft); >++ colorAndFontTable.layout (); >++ } >++ >++ /** >++ * Sets the background color of the Node 1 TreeItems. >++ */ >++ void setItemBackground () { >++ if (!instance.startup) { >++ textNode1.setBackground (itemBackgroundColor); >++ imageNode1.setBackground (itemBackgroundColor); >++ } >++ /* Set the background button's color to match the background color of the item. */ >++ Color color = itemBackgroundColor; >++ if (color == null) color = textNode1.getBackground (); >++ TableItem item = colorAndFontTable.getItem(ITEM_BACKGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the foreground color of the Node 1 TreeItems. >++ */ >++ void setItemForeground () { >++ if (!instance.startup) { >++ textNode1.setForeground (itemForegroundColor); >++ imageNode1.setForeground (itemForegroundColor); >++ } >++ /* Set the foreground button's color to match the foreground color of the item. */ >++ Color color = itemForegroundColor; >++ if (color == null) color = textNode1.getForeground (); >++ TableItem item = colorAndFontTable.getItem(ITEM_FOREGROUND_COLOR); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (colorImage(color)); >++ } >++ >++ /** >++ * Sets the font of the Node 1 TreeItems. >++ */ >++ void setItemFont () { >++ if (!instance.startup) { >++ textNode1.setFont (itemFont); >++ imageNode1.setFont (itemFont); >++ } >++ /* Set the font item's image to match the font of the item. */ >++ Font ft = itemFont; >++ if (ft == null) ft = textNode1.getFont (); >++ TableItem item = colorAndFontTable.getItem(ITEM_FONT); >++ Image oldImage = item.getImage(); >++ if (oldImage != null) oldImage.dispose(); >++ item.setImage (fontImage(ft)); >++ item.setFont(ft); >++ colorAndFontTable.layout (); >++ } >++ >++ /** >++ * Sets the header visible state of the "Example" widgets. >++ */ >++ void setWidgetHeaderVisible () { >++ tree1.setHeaderVisible (headerVisibleButton.getSelection ()); >++ tree2.setHeaderVisible (headerVisibleButton.getSelection ()); >++ } >++ >++ /** >++ * Sets the sort indicator state of the "Example" widgets. >++ */ >++ void setWidgetSortIndicator () { >++ if (sortIndicatorButton.getSelection ()) { >++ initializeSortState (tree1); >++ initializeSortState (tree2); >++ } else { >++ resetSortState (tree1); >++ resetSortState (tree2); >++ } >++ } >++ >++ /** >++ * Sets the initial sort indicator state and adds a listener >++ * to cycle through sort states and columns. >++ */ >++ void initializeSortState (final Tree tree) { >++ /* Reset to known state: 'down' on column 0. */ >++ tree.setSortDirection (SWT.DOWN); >++ TreeColumn [] columns = tree.getColumns(); >++ for (int i = 0; i < columns.length; i++) { >++ TreeColumn column = columns[i]; >++ if (i == 0) tree.setSortColumn(column); >++ SelectionListener listener = new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ int sortDirection = SWT.DOWN; >++ if (e.widget == tree.getSortColumn()) { >++ /* If the sort column hasn't changed, cycle down -> up -> none. */ >++ switch (tree.getSortDirection ()) { >++ case SWT.DOWN: sortDirection = SWT.UP; break; >++ case SWT.UP: sortDirection = SWT.NONE; break; >++ } >++ } else { >++ tree.setSortColumn((TreeColumn)e.widget); >++ } >++ tree.setSortDirection (sortDirection); >++ } >++ }; >++ column.addSelectionListener(listener); >++ column.setData("SortListener", listener); //$NON-NLS-1$ >++ } >++ } >++ >++ void resetSortState (final Tree tree) { >++ tree.setSortDirection (SWT.NONE); >++ TreeColumn [] columns = tree.getColumns(); >++ for (int i = 0; i < columns.length; i++) { >++ SelectionListener listener = (SelectionListener)columns[i].getData("SortListener"); //$NON-NLS-1$ >++ if (listener != null) columns[i].removeSelectionListener(listener); >++ } >++ } >++ >++ /** >++ * Sets the lines visible state of the "Example" widgets. >++ */ >++ void setWidgetLinesVisible () { >++ tree1.setLinesVisible (linesVisibleButton.getSelection ()); >++ tree2.setLinesVisible (linesVisibleButton.getSelection ()); >++ } >++ >++ protected void specialPopupMenuItems(Menu menu, Event event) { >++ MenuItem item = new MenuItem(menu, SWT.PUSH); >++ item.setText("getItem(Point) on mouse coordinates"); >++ final Tree t = (Tree) event.widget; >++ menuMouseCoords = t.toControl(new Point(event.x, event.y)); >++ item.addSelectionListener(new SelectionAdapter() { >++ public void widgetSelected(SelectionEvent e) { >++ eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + t.getItem(menuMouseCoords)); >++ eventConsole.append ("\n"); >++ } >++ }); >++ } >++} >+Index: src/org/eclipse/swt/examples/mirroringTest/browser-content.html >+=================================================================== >+RCS file: src/org/eclipse/swt/examples/mirroringTest/browser-content.html >+diff -N src/org/eclipse/swt/examples/mirroringTest/browser-content.html >+--- /dev/null 1 Jan 1970 00:00:00 -0000 >++++ src/org/eclipse/swt/examples/mirroringTest/browser-content.html 1 Jan 1970 00:00:00 -0000 >+@@ -0,0 +1,35 @@ >++<html> >++<head> >++<title>SWT Browser</title> >++</head> >++ >++<h3>About SWT Browser</h3> >++<p>You are looking at HTML content in a <b>Browser</b> widget. >++<ul> >++<li>For a definition of the Browser widget, see: >++<a href="http://www.eclipse.org/swt/faq.php#whatisbrowser">http://www.eclipse.org/swt/faq.php#whatisbrowser</a></li> >++<li>For a list of the platforms that Browser supports, see: >++<a href="http://www.eclipse.org/swt/faq.php#browserplatforms">http://www.eclipse.org/swt/faq.php#browserplatforms</a></li> >++<li>For more information on the SWT.WEBKIT Browser style, see: >++<a href="http://www.eclipse.org/swt/faq.php#howusewebkit">http://www.eclipse.org/swt/faq.php#howusewebkit</a></li> >++<li>For more information on the SWT.MOZILLA Browser style, see: >++<a href="http://www.eclipse.org/swt/faq.php#howusemozilla">http://www.eclipse.org/swt/faq.php#howusemozilla</a></li> >++<li>For more examples that use a Browser widget, see BrowserExample, BrowserDemo, and WebBrowser: >++<a href="http://www.eclipse.org/swt/examples.php">http://www.eclipse.org/swt/examples.php</a></li> >++</ul></p> >++ >++<h3>About SWT</h3> >++<p>For more information on SWT, including the Widget Gallery, Snippets, Examples, FAQ, Tools, Documentation >++and more, check out <a href="http://www.eclipse.org/swt/">http://www.eclipse.org/swt</a>.</p> >++ >++<h3>Eclipse Downloads Page</h3> >++<p>To download the latest Integration Build of eclipse, go to: >++<a href="http://download.eclipse.org/eclipse/downloads/">http://download.eclipse.org/eclipse/downloads</a>.</p> >++ >++<h3>Bug Reports and Feature Requests</h3> >++<p>To report an SWT bug or request an SWT feature, go to: >++<a href="https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform">https://bugs.eclipse.org/bugs</a> >++and select <b>Component: SWT</b>.</p> >++ >++</body> >++</html> >Index: src/org/eclipse/swt/examples/mirroringTest/AlignableTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/AlignableTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/AlignableTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/AlignableTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,89 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+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 { >+ >+ /* Alignment Controls */ >+ Button leftButton, rightButton, centerButton; >+ >+ /* Alignment Group */ >+ Group alignmentGroup; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ AlignableTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Other" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ >+ /* Create the group */ >+ alignmentGroup = new Group (otherGroup, SWT.NONE); >+ alignmentGroup.setLayout (new GridLayout ()); >+ alignmentGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | >+ GridData.VERTICAL_ALIGN_FILL)); >+ alignmentGroup.setText (ControlExample.getResourceString("Alignment")); >+ >+ /* Create the controls */ >+ leftButton = new Button (alignmentGroup, SWT.RADIO); >+ leftButton.setText (ControlExample.getResourceString("Left")); >+ centerButton = new Button (alignmentGroup, SWT.RADIO); >+ centerButton.setText(ControlExample.getResourceString("Center")); >+ rightButton = new Button (alignmentGroup, SWT.RADIO); >+ rightButton.setText (ControlExample.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 (); >+ Widget [] widgets = getExampleWidgets (); >+ if (widgets.length != 0) { >+ leftButton.setSelection ((widgets [0].getStyle () & SWT.LEFT) != 0); >+ centerButton.setSelection ((widgets [0].getStyle () & SWT.CENTER) != 0); >+ rightButton.setSelection ((widgets [0].getStyle () & SWT.RIGHT) != 0); >+ } >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/BrowserTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/BrowserTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/BrowserTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/BrowserTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,347 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.browser.*; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+ >+class BrowserTab extends Tab { >+ >+ /* Example widgets and groups that contain them */ >+ Browser browser; >+ Group browserGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button mozillaButton, webKitButton; >+ >+ String errorMessage, lastText, lastUrl; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ BrowserTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ void createBackgroundModeGroup () { >+ // Browser does not need a background mode group. >+ } >+ >+ void createColorAndFontGroup () { >+ // Browser does not need a color and font group. >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the browser */ >+ browserGroup = new Group (exampleGroup, SWT.NONE); >+ browserGroup.setLayout (new GridLayout ()); >+ browserGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ browserGroup.setText ("Browser"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (mozillaButton.getSelection ()) style |= SWT.MOZILLA; >+ if (webKitButton.getSelection ()) style |= SWT.WEBKIT; >+ >+ /* Create the example widgets */ >+ try { >+ browser = new Browser (browserGroup, style); >+ } catch (SWTError e) { // Probably missing browser >+ try { >+ browser = new Browser (browserGroup, style & ~(SWT.MOZILLA | SWT.WEBKIT)); >+ } catch (SWTError e2) { // Unsupported platform >+ errorMessage = e.getMessage(); >+ return; >+ } >+ MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); >+ String resourceString = (style & SWT.MOZILLA) != 0 ? "MozillaNotFound" : "WebKitNotFound"; >+ dialog.setMessage(ControlExample.getResourceString(resourceString, new String [] {e.getMessage()})); >+ dialog.open(); >+ } >+ >+ if (lastUrl != null) { >+ browser.setUrl(lastUrl); >+ } else if (lastText != null) { >+ browser.setText(lastText); >+ } else { >+ InputStream htmlStream= ControlExample.class.getResourceAsStream("browser-content.html"); >+ BufferedReader br= new BufferedReader(new InputStreamReader(htmlStream)); >+ StringBuffer sb= new StringBuffer(300); >+ try { >+ int read= 0; >+ while ((read= br.read()) != -1) >+ sb.append((char) read); >+ } catch (IOException e) { >+ log(e.getMessage()); >+ } finally { >+ try { >+ br.close(); >+ } catch (IOException e) { >+ log(e.getMessage()); >+ } >+ } >+ String text= sb.toString(); >+ browser.setText(text); >+ } >+ lastText = lastUrl = null; >+ } >+ >+ /** >+ * Creates the "Other" group. This is typically >+ * a child of the "Control" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ backgroundImageButton.dispose (); >+ } >+ >+ /** >+ * Creates the "Size" group. The "Size" group contains >+ * controls that allow the user to change the size of >+ * the example widgets. >+ */ >+ void createSizeGroup () { >+ super.createSizeGroup (); >+ >+ /* Set the default state for Browser to fill horizontally & vertically. */ >+ fillHButton.setSelection (true); >+ fillVButton.setSelection (true); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup () { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ mozillaButton = new Button (styleGroup, SWT.CHECK); >+ mozillaButton.setText ("SWT.MOZILLA"); >+ mozillaButton.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) { >+ webKitButton.setSelection(false); >+ } >+ }); >+ webKitButton = new Button (styleGroup, SWT.CHECK); >+ webKitButton.setText ("SWT.WEBKIT"); >+ webKitButton.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) { >+ mozillaButton.setSelection(false); >+ } >+ }); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ } >+ >+ /** >+ * Creates the tab folder page. >+ * >+ * @param tabFolder org.eclipse.swt.widgets.TabFolder >+ * @return the new page for the tab folder >+ */ >+ Composite createTabFolderPage (final TabFolder tabFolder) { >+ super.createTabFolderPage (tabFolder); >+ >+ /* >+ * Add a resize listener to the tabFolderPage so that >+ * if the user types into the example widget to change >+ * its preferred size, and then resizes the shell, we >+ * recalculate the preferred size correctly. >+ */ >+ tabFolderPage.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) { >+ setExampleWidgetSize (); >+ } >+ }); >+ >+ /* >+ * Add a selection listener to the tabFolder to bring up a >+ * dialog if this platform does not support the Browser. >+ */ >+ tabFolder.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ if (errorMessage != null && tabFolder.getSelection()[0].getText().equals(getTabText())) { >+ MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); >+ dialog.setMessage(ControlExample.getResourceString("BrowserNotFound", new String [] {errorMessage})); >+ dialog.open(); >+ } >+ } >+ }); >+ >+ return tabFolderPage; >+ } >+ >+ /** >+ * Disposes the "Example" widgets. >+ */ >+ void disposeExampleWidgets () { >+ /* store the state of the Browser if applicable */ >+ if (browser != null) { >+ String url = browser.getUrl(); >+ if (url.length() > 0 && !url.equals("about:blank")) { //$NON-NLS-1$ >+ lastUrl = url; >+ } else { >+ String text = browser.getText(); >+ if (text.length() > 0) { >+ lastText = text; >+ } >+ } >+ } >+ super.disposeExampleWidgets(); >+ } >+ >+ public static String getContents(InputStream in) throws IOException { >+ BufferedReader br= new BufferedReader(new InputStreamReader(in)); >+ >+ StringBuffer sb= new StringBuffer(300); >+ try { >+ int read= 0; >+ while ((read= br.read()) != -1) >+ sb.append((char) read); >+ } finally { >+ br.close(); >+ } >+ return sb.toString(); >+ } >+ >+ /** >+ * Gets the list of custom event names. >+ * >+ * @return an array containing custom event names >+ */ >+ String [] getCustomEventNames () { >+ return new String [] {"CloseWindowListener", "LocationListener", "OpenWindowListener", >+ "ProgressListener", "StatusTextListener", "TitleListener", "VisibilityWindowListener"}; >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ if (browser != null) return new Widget [] {browser}; >+ return super.getExampleWidgets(); >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Text", "Url", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Browser"; >+ } >+ >+ /** >+ * Hooks the custom listener specified by eventName. >+ */ >+ void hookCustomListener (final String eventName) { >+ if (browser == null) return; >+ if (eventName == "CloseWindowListener") { >+ browser.addCloseWindowListener (new CloseWindowListener () { >+ public void close(WindowEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "LocationListener") { >+ browser.addLocationListener (new LocationListener () { >+ public void changed(LocationEvent event) { >+ log (eventName + ".changed", event); >+ } >+ public void changing(LocationEvent event) { >+ log (eventName + ".changing", event); >+ } >+ }); >+ } >+ if (eventName == "OpenWindowListener") { >+ browser.addOpenWindowListener (new OpenWindowListener () { >+ public void open(WindowEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "ProgressListener") { >+ browser.addProgressListener (new ProgressListener () { >+ public void changed(ProgressEvent event) { >+ log (eventName + ".changed", event); >+ } >+ public void completed(ProgressEvent event) { >+ log (eventName + ".completed", event); >+ } >+ }); >+ } >+ if (eventName == "StatusTextListener") { >+ browser.addStatusTextListener (new StatusTextListener () { >+ public void changed(StatusTextEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "TitleListener") { >+ browser.addTitleListener (new TitleListener () { >+ public void changed(TitleEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "VisibilityWindowListener") { >+ browser.addVisibilityWindowListener (new VisibilityWindowListener () { >+ public void hide(WindowEvent event) { >+ log (eventName + ".hide", event); >+ } >+ public void show(WindowEvent event) { >+ log (eventName + ".show", event); >+ } >+ }); >+ } >+ } >+ >+ boolean rtlSupport() { >+ return false; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ mozillaButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.MOZILLA) != 0); >+ webKitButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.WEBKIT) != 0); >+ borderButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.BORDER) != 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ButtonTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ButtonTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ButtonTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ButtonTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,245 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+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, button7, button8, button9; >+ Group textButtonGroup, imageButtonGroup, imagetextButtonGroup; >+ >+ /* Alignment widgets added to the "Control" group */ >+ Button upButton, downButton; >+ >+ /* Style widgets added to the "Style" group */ >+ Button pushButton, checkButton, radioButton, toggleButton, arrowButton, flatButton, wrapButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ButtonTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Control" group. >+ */ >+ void createControlGroup () { >+ super.createControlGroup (); >+ >+ /* Create the controls */ >+ upButton = new Button (alignmentGroup, SWT.RADIO); >+ upButton.setText (ControlExample.getResourceString("Up")); >+ downButton = new Button (alignmentGroup, SWT.RADIO); >+ downButton.setText (ControlExample.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 (SWT.FILL, SWT.FILL, true, true)); >+ textButtonGroup.setText (ControlExample.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 (SWT.FILL, SWT.FILL, true, true)); >+ imageButtonGroup.setText (ControlExample.getResourceString("Image_Buttons")); >+ >+ /* Create a group for the image and text buttons */ >+ imagetextButtonGroup = new Group(exampleGroup, SWT.NONE); >+ gridLayout = new GridLayout(); >+ imagetextButtonGroup.setLayout(gridLayout); >+ gridLayout.numColumns = 3; >+ imagetextButtonGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ imagetextButtonGroup.setText (ControlExample.getResourceString("Image_Text_Buttons")); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ 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 (flatButton.getSelection()) style |= SWT.FLAT; >+ if (wrapButton.getSelection()) style |= SWT.WRAP; >+ if (borderButton.getSelection()) style |= SWT.BORDER; >+ if (leftButton.getSelection()) style |= SWT.LEFT; >+ if (rightButton.getSelection()) style |= SWT.RIGHT; >+ if (arrowButton.getSelection()) { >+ style |= SWT.ARROW; >+ if (upButton.getSelection()) style |= SWT.UP; >+ if (downButton.getSelection()) style |= SWT.DOWN; >+ } else { >+ if (centerButton.getSelection()) style |= SWT.CENTER; >+ } >+ >+ /* Create the example widgets */ >+ button1 = new Button(textButtonGroup, style); >+ button1.setText(ControlExample.getResourceString("One...")); >+ button2 = new Button(textButtonGroup, style); >+ button2.setText(ControlExample.getResourceString("Two...")); >+ button3 = new Button(textButtonGroup, style); >+ if (wrapButton.getSelection ()) { >+ button3.setText (ControlExample.getResourceString("Wrap_Text...")); >+ } else { >+ button3.setText (ControlExample.getResourceString("Three...")); >+ } >+ button4 = new Button(imageButtonGroup, style); >+ button4.setImage(instance.images[ControlExample.ciClosedFolder]); >+ button5 = new Button(imageButtonGroup, style); >+ button5.setImage(instance.images[ControlExample.ciOpenFolder]); >+ button6 = new Button(imageButtonGroup, style); >+ button6.setImage(instance.images[ControlExample.ciTarget]); >+ button7 = new Button(imagetextButtonGroup, style); >+ button7.setText(ControlExample.getResourceString("One...")); >+ button7.setImage(instance.images[ControlExample.ciClosedFolder]); >+ button8 = new Button(imagetextButtonGroup, style); >+ button8.setText(ControlExample.getResourceString("Two...")); >+ button8.setImage(instance.images[ControlExample.ciOpenFolder]); >+ button9 = new Button(imagetextButtonGroup, style); >+ if (wrapButton.getSelection ()) { >+ button9.setText (ControlExample.getResourceString("Wrap_Text...")); >+ } else { >+ button9.setText (ControlExample.getResourceString("Three...")); >+ } >+ button9.setImage(instance.images[ControlExample.ciTarget]); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ pushButton = new Button (styleGroup, SWT.RADIO); >+ pushButton.setText("SWT.PUSH"); >+ checkButton = new Button (styleGroup, SWT.RADIO); >+ checkButton.setText ("SWT.CHECK"); >+ radioButton = new Button (styleGroup, SWT.RADIO); >+ radioButton.setText ("SWT.RADIO"); >+ toggleButton = new Button (styleGroup, SWT.RADIO); >+ toggleButton.setText ("SWT.TOGGLE"); >+ arrowButton = new Button (styleGroup, SWT.RADIO); >+ arrowButton.setText ("SWT.ARROW"); >+ flatButton = new Button (styleGroup, SWT.CHECK); >+ flatButton.setText ("SWT.FLAT"); >+ wrapButton = new Button (styleGroup, SWT.CHECK); >+ wrapButton.setText ("SWT.WRAP"); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {button1, button2, button3, button4, button5, button6, button7, button8, button9}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Grayed", "Selection", "Text", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Button"; >+ } >+ >+ /** >+ * Sets the alignment of the "Example" widgets. >+ */ >+ void setExampleWidgetAlignment () { >+ int alignment = 0; >+ if (leftButton.getSelection ()) alignment = SWT.LEFT; >+ if (centerButton.getSelection ()) alignment = SWT.CENTER; >+ if (rightButton.getSelection ()) alignment = SWT.RIGHT; >+ if (upButton.getSelection ()) alignment = SWT.UP; >+ if (downButton.getSelection ()) alignment = SWT.DOWN; >+ button1.setAlignment (alignment); >+ button2.setAlignment (alignment); >+ button3.setAlignment (alignment); >+ button4.setAlignment (alignment); >+ button5.setAlignment (alignment); >+ button6.setAlignment (alignment); >+ button7.setAlignment (alignment); >+ button8.setAlignment (alignment); >+ button9.setAlignment (alignment); >+ } >+ >+ /** >+ * 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); >+ flatButton.setSelection ((button1.getStyle () & SWT.FLAT) != 0); >+ wrapButton.setSelection ((button1.getStyle () & SWT.WRAP) != 0); >+ borderButton.setSelection ((button1.getStyle () & SWT.BORDER) != 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/CComboTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CComboTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CComboTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CComboTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,123 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.custom.*; >+import org.eclipse.swt.layout.*; >+ >+class CComboTab extends Tab { >+ >+ /* Example widgets and groups that contain them */ >+ CCombo combo1; >+ Group comboGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button flatButton, readOnlyButton; >+ >+ static String [] ListData = {ControlExample.getResourceString("ListData1_0"), >+ ControlExample.getResourceString("ListData1_1"), >+ ControlExample.getResourceString("ListData1_2"), >+ ControlExample.getResourceString("ListData1_3"), >+ ControlExample.getResourceString("ListData1_4"), >+ ControlExample.getResourceString("ListData1_5"), >+ ControlExample.getResourceString("ListData1_6"), >+ ControlExample.getResourceString("ListData1_7"), >+ ControlExample.getResourceString("ListData1_8")}; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ CComboTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the combo box */ >+ comboGroup = new Group (exampleGroup, SWT.NONE); >+ comboGroup.setLayout (new GridLayout ()); >+ comboGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ comboGroup.setText (ControlExample.getResourceString("Custom_Combo")); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (flatButton.getSelection ()) style |= SWT.FLAT; >+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ >+ /* Create the example widgets */ >+ combo1 = new CCombo (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 */ >+ readOnlyButton = new Button (styleGroup, SWT.CHECK); >+ readOnlyButton.setText ("SWT.READ_ONLY"); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ flatButton = new Button (styleGroup, SWT.CHECK); >+ flatButton.setText ("SWT.FLAT"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {combo1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Editable", "Items", "Selection", "Text", "TextLimit", "ToolTipText", "VisibleItemCount"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "CCombo"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ flatButton.setSelection ((combo1.getStyle () & SWT.FLAT) != 0); >+ readOnlyButton.setSelection ((combo1.getStyle () & SWT.READ_ONLY) != 0); >+ borderButton.setSelection ((combo1.getStyle () & SWT.BORDER) != 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/CLabelTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CLabelTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CLabelTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CLabelTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,135 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.custom.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+ >+class CLabelTab extends AlignableTab { >+ /* Example widgets and groups that contain them */ >+ CLabel label1, label2, label3; >+ Group textLabelGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button shadowInButton, shadowOutButton, shadowNoneButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ CLabelTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the text labels */ >+ textLabelGroup = new Group(exampleGroup, SWT.NONE); >+ GridLayout gridLayout = new GridLayout (); >+ textLabelGroup.setLayout (gridLayout); >+ gridLayout.numColumns = 3; >+ textLabelGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ textLabelGroup.setText (ControlExample.getResourceString("Custom_Labels")); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (shadowInButton.getSelection ()) style |= SWT.SHADOW_IN; >+ if (shadowNoneButton.getSelection ()) style |= SWT.SHADOW_NONE; >+ if (shadowOutButton.getSelection ()) style |= SWT.SHADOW_OUT; >+ if (leftButton.getSelection ()) style |= SWT.LEFT; >+ if (centerButton.getSelection ()) style |= SWT.CENTER; >+ if (rightButton.getSelection ()) style |= SWT.RIGHT; >+ >+ /* Create the example widgets */ >+ label1 = new CLabel (textLabelGroup, style); >+ label1.setText(ControlExample.getResourceString("One")); >+ label1.setImage (instance.images[ControlExample.ciClosedFolder]); >+ label2 = new CLabel (textLabelGroup, style); >+ label2.setImage (instance.images[ControlExample.ciTarget]); >+ label3 = new CLabel (textLabelGroup, style); >+ label3.setText(ControlExample.getResourceString("Example_string") + "\n" + ControlExample.getResourceString("One_Two_Three")); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ shadowNoneButton = new Button (styleGroup, SWT.RADIO); >+ shadowNoneButton.setText ("SWT.SHADOW_NONE"); >+ shadowInButton = new Button (styleGroup, SWT.RADIO); >+ shadowInButton.setText ("SWT.SHADOW_IN"); >+ shadowOutButton = new Button (styleGroup, SWT.RADIO); >+ shadowOutButton.setText ("SWT.SHADOW_OUT"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {label1, label2, label3}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"BottomMargin", "LeftMargin", "RightMargin", "Text", "ToolTipText", "TopMargin"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "CLabel"; >+ } >+ >+ /** >+ * Sets the alignment of the "Example" widgets. >+ */ >+ void setExampleWidgetAlignment () { >+ int alignment = 0; >+ if (leftButton.getSelection ()) alignment = SWT.LEFT; >+ if (centerButton.getSelection ()) alignment = SWT.CENTER; >+ if (rightButton.getSelection ()) alignment = SWT.RIGHT; >+ label1.setAlignment (alignment); >+ label2.setAlignment (alignment); >+ label3.setAlignment (alignment); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ leftButton.setSelection ((label1.getStyle () & SWT.LEFT) != 0); >+ centerButton.setSelection ((label1.getStyle () & SWT.CENTER) != 0); >+ rightButton.setSelection ((label1.getStyle () & SWT.RIGHT) != 0); >+ shadowInButton.setSelection ((label1.getStyle () & SWT.SHADOW_IN) != 0); >+ shadowOutButton.setSelection ((label1.getStyle () & SWT.SHADOW_OUT) != 0); >+ shadowNoneButton.setSelection ((label1.getStyle () & (SWT.SHADOW_IN | SWT.SHADOW_OUT)) == 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/CTabFolderTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CTabFolderTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CTabFolderTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CTabFolderTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,446 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.custom.*; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.widgets.*; >+ >+class CTabFolderTab extends Tab { >+ int lastSelectedTab = 0; >+ >+ /* Example widgets and groups that contain them */ >+ CTabFolder tabFolder1; >+ Group tabFolderGroup, itemGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button topButton, bottomButton, flatButton, closeButton; >+ >+ static String [] CTabItems1 = {ControlExample.getResourceString("CTabItem1_0"), >+ ControlExample.getResourceString("CTabItem1_1"), >+ ControlExample.getResourceString("CTabItem1_2")}; >+ >+ /* Controls and resources added to the "Fonts" group */ >+ static final int SELECTION_FOREGROUND_COLOR = 3; >+ static final int SELECTION_BACKGROUND_COLOR = 4; >+ static final int ITEM_FONT = 5; >+ Color selectionForegroundColor, selectionBackgroundColor; >+ Font itemFont; >+ >+ /* Other widgets added to the "Other" group */ >+ Button simpleTabButton, singleTabButton, imageButton, showMinButton, showMaxButton, unselectedCloseButton, unselectedImageButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ CTabFolderTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Colors and Fonts" group. >+ */ >+ void createColorAndFontGroup () { >+ super.createColorAndFontGroup(); >+ >+ TableItem item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Selection_Foreground_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Selection_Background_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Item_Font")); >+ >+ shell.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent event) { >+ if (selectionBackgroundColor != null) selectionBackgroundColor.dispose(); >+ if (selectionForegroundColor != null) selectionForegroundColor.dispose(); >+ if (itemFont != null) itemFont.dispose(); >+ selectionBackgroundColor = null; >+ selectionForegroundColor = null; >+ itemFont = null; >+ } >+ }); >+ } >+ >+ void changeFontOrColor(int index) { >+ switch (index) { >+ case SELECTION_FOREGROUND_COLOR: { >+ Color oldColor = selectionForegroundColor; >+ if (oldColor == null) oldColor = tabFolder1.getSelectionForeground(); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = selectionForegroundColor; >+ selectionForegroundColor = new Color (display, rgb); >+ setSelectionForeground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case SELECTION_BACKGROUND_COLOR: { >+ Color oldColor = selectionBackgroundColor; >+ if (oldColor == null) oldColor = tabFolder1.getSelectionBackground(); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = selectionBackgroundColor; >+ selectionBackgroundColor = new Color (display, rgb); >+ setSelectionBackground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case ITEM_FONT: { >+ Font oldFont = itemFont; >+ if (oldFont == null) oldFont = tabFolder1.getItem (0).getFont (); >+ fontDialog.setFontList(oldFont.getFontData()); >+ FontData fontData = fontDialog.open (); >+ if (fontData == null) return; >+ oldFont = itemFont; >+ itemFont = new Font (display, fontData); >+ setItemFont (); >+ setExampleWidgetSize (); >+ if (oldFont != null) oldFont.dispose (); >+ } >+ break; >+ default: >+ super.changeFontOrColor(index); >+ } >+ } >+ >+ /** >+ * Creates the "Other" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ >+ /* Create display controls specific to this example */ >+ simpleTabButton = new Button (otherGroup, SWT.CHECK); >+ simpleTabButton.setText (ControlExample.getResourceString("Set_Simple_Tabs")); >+ simpleTabButton.setSelection(true); >+ simpleTabButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setSimpleTabs(); >+ } >+ }); >+ >+ singleTabButton = new Button (otherGroup, SWT.CHECK); >+ singleTabButton.setText (ControlExample.getResourceString("Set_Single_Tabs")); >+ singleTabButton.setSelection(false); >+ singleTabButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setSingleTabs(); >+ } >+ }); >+ >+ showMinButton = new Button (otherGroup, SWT.CHECK); >+ showMinButton.setText (ControlExample.getResourceString("Set_Min_Visible")); >+ showMinButton.setSelection(false); >+ showMinButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setMinimizeVisible(); >+ } >+ }); >+ >+ showMaxButton = new Button (otherGroup, SWT.CHECK); >+ showMaxButton.setText (ControlExample.getResourceString("Set_Max_Visible")); >+ showMaxButton.setSelection(false); >+ showMaxButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setMaximizeVisible(); >+ } >+ }); >+ >+ imageButton = new Button (otherGroup, SWT.CHECK); >+ imageButton.setText (ControlExample.getResourceString("Set_Image")); >+ imageButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setImages(); >+ } >+ }); >+ >+ unselectedImageButton = new Button (otherGroup, SWT.CHECK); >+ unselectedImageButton.setText (ControlExample.getResourceString("Set_Unselected_Image_Visible")); >+ unselectedImageButton.setSelection(true); >+ unselectedImageButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setUnselectedImageVisible(); >+ } >+ }); >+ unselectedCloseButton = new Button (otherGroup, SWT.CHECK); >+ unselectedCloseButton.setText (ControlExample.getResourceString("Set_Unselected_Close_Visible")); >+ unselectedCloseButton.setSelection(true); >+ unselectedCloseButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setUnselectedCloseVisible(); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the CTabFolder */ >+ tabFolderGroup = new Group (exampleGroup, SWT.NONE); >+ tabFolderGroup.setLayout (new GridLayout ()); >+ tabFolderGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ tabFolderGroup.setText ("CTabFolder"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (topButton.getSelection ()) style |= SWT.TOP; >+ if (bottomButton.getSelection ()) style |= SWT.BOTTOM; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (flatButton.getSelection ()) style |= SWT.FLAT; >+ if (closeButton.getSelection ()) style |= SWT.CLOSE; >+ >+ /* Create the example widgets */ >+ tabFolder1 = new CTabFolder (tabFolderGroup, style); >+ for (int i = 0; i < CTabItems1.length; i++) { >+ CTabItem item = new CTabItem(tabFolder1, SWT.NONE); >+ item.setText(CTabItems1[i]); >+ Text text = new Text(tabFolder1, SWT.WRAP | SWT.MULTI); >+ text.setText(ControlExample.getResourceString("CTabItem_content") + ": " + i); >+ item.setControl(text); >+ } >+ tabFolder1.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) { >+ lastSelectedTab = tabFolder1.getSelectionIndex(); >+ } >+ }); >+ tabFolder1.setSelection(lastSelectedTab); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ topButton = new Button (styleGroup, SWT.RADIO); >+ topButton.setText ("SWT.TOP"); >+ topButton.setSelection(true); >+ bottomButton = new Button (styleGroup, SWT.RADIO); >+ bottomButton.setText ("SWT.BOTTOM"); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ flatButton = new Button (styleGroup, SWT.CHECK); >+ flatButton.setText ("SWT.FLAT"); >+ closeButton = new Button (styleGroup, SWT.CHECK); >+ closeButton.setText ("SWT.CLOSE"); >+ } >+ >+ /** >+ * Gets the list of custom event names. >+ * >+ * @return an array containing custom event names >+ */ >+ String [] getCustomEventNames () { >+ return new String [] {"CTabFolderEvent"}; >+ } >+ >+ /** >+ * Gets the "Example" widget children's items, if any. >+ * >+ * @return an array containing the example widget children's items >+ */ >+ Item [] getExampleWidgetItems () { >+ return tabFolder1.getItems(); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {tabFolder1}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "CTabFolder"; >+ } >+ >+ /** >+ * Hooks the custom listener specified by eventName. >+ */ >+ void hookCustomListener (final String eventName) { >+ if (eventName == "CTabFolderEvent") { >+ tabFolder1.addCTabFolder2Listener (new CTabFolder2Adapter () { >+ public void close (CTabFolderEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ } >+ >+ /** >+ * Sets the foreground color, background color, and font >+ * of the "Example" widgets to their default settings. >+ * Also sets foreground and background color of the Node 1 >+ * TreeItems to default settings. >+ */ >+ void resetColorsAndFonts () { >+ super.resetColorsAndFonts (); >+ Color oldColor = selectionForegroundColor; >+ selectionForegroundColor = null; >+ setSelectionForeground (); >+ if (oldColor != null) oldColor.dispose(); >+ oldColor = selectionBackgroundColor; >+ selectionBackgroundColor = null; >+ setSelectionBackground (); >+ if (oldColor != null) oldColor.dispose(); >+ Font oldFont = itemFont; >+ itemFont = null; >+ setItemFont (); >+ if (oldFont != null) oldFont.dispose(); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState(); >+ setSimpleTabs(); >+ setSingleTabs(); >+ setImages(); >+ setMinimizeVisible(); >+ setMaximizeVisible(); >+ setUnselectedCloseVisible(); >+ setUnselectedImageVisible(); >+ setSelectionBackground (); >+ setSelectionForeground (); >+ setItemFont (); >+ setExampleWidgetSize(); >+ } >+ >+ /** >+ * Sets the shape that the CTabFolder will use to render itself. >+ */ >+ void setSimpleTabs () { >+ tabFolder1.setSimple (simpleTabButton.getSelection ()); >+ setExampleWidgetSize(); >+ } >+ >+ /** >+ * Sets the number of tabs that the CTabFolder should display. >+ */ >+ void setSingleTabs () { >+ tabFolder1.setSingle (singleTabButton.getSelection ()); >+ setExampleWidgetSize(); >+ } >+ /** >+ * Sets an image into each item of the "Example" widgets. >+ */ >+ void setImages () { >+ boolean setImage = imageButton.getSelection (); >+ CTabItem items[] = tabFolder1.getItems (); >+ for (int i = 0; i < items.length; i++) { >+ if (setImage) { >+ items[i].setImage (instance.images[ControlExample.ciClosedFolder]); >+ } else { >+ items[i].setImage (null); >+ } >+ } >+ setExampleWidgetSize (); >+ } >+ /** >+ * Sets the visibility of the minimize button >+ */ >+ void setMinimizeVisible () { >+ tabFolder1.setMinimizeVisible(showMinButton.getSelection ()); >+ setExampleWidgetSize(); >+ } >+ /** >+ * Sets the visibility of the maximize button >+ */ >+ void setMaximizeVisible () { >+ tabFolder1.setMaximizeVisible(showMaxButton.getSelection ()); >+ setExampleWidgetSize(); >+ } >+ /** >+ * Sets the visibility of the close button on unselected tabs >+ */ >+ void setUnselectedCloseVisible () { >+ tabFolder1.setUnselectedCloseVisible(unselectedCloseButton.getSelection ()); >+ setExampleWidgetSize(); >+ } >+ /** >+ * Sets the visibility of the image on unselected tabs >+ */ >+ void setUnselectedImageVisible () { >+ tabFolder1.setUnselectedImageVisible(unselectedImageButton.getSelection ()); >+ setExampleWidgetSize(); >+ } >+ /** >+ * Sets the background color of CTabItem 0. >+ */ >+ void setSelectionBackground () { >+ if (!instance.startup) { >+ tabFolder1.setSelectionBackground(selectionBackgroundColor); >+ } >+ // Set the selection background item's image to match the background color of the selection. >+ Color color = selectionBackgroundColor; >+ if (color == null) color = tabFolder1.getSelectionBackground (); >+ TableItem item = colorAndFontTable.getItem(SELECTION_BACKGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the foreground color of CTabItem 0. >+ */ >+ void setSelectionForeground () { >+ if (!instance.startup) { >+ tabFolder1.setSelectionForeground(selectionForegroundColor); >+ } >+ // Set the selection foreground item's image to match the foreground color of the selection. >+ Color color = selectionForegroundColor; >+ if (color == null) color = tabFolder1.getSelectionForeground (); >+ TableItem item = colorAndFontTable.getItem(SELECTION_FOREGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the font of CTabItem 0. >+ */ >+ void setItemFont () { >+ if (!instance.startup) { >+ tabFolder1.getItem (0).setFont (itemFont); >+ setExampleWidgetSize(); >+ } >+ /* Set the font item's image to match the font of the item. */ >+ Font ft = itemFont; >+ if (ft == null) ft = tabFolder1.getItem (0).getFont (); >+ TableItem item = colorAndFontTable.getItem(ITEM_FONT); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (fontImage(ft)); >+ item.setFont(ft); >+ colorAndFontTable.layout (); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/CanvasTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CanvasTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CanvasTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CanvasTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,312 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.*; >+ >+class CanvasTab extends Tab { >+ static final int colors [] = { >+ SWT.COLOR_RED, >+ SWT.COLOR_GREEN, >+ SWT.COLOR_BLUE, >+ SWT.COLOR_MAGENTA, >+ SWT.COLOR_YELLOW, >+ SWT.COLOR_CYAN, >+ SWT.COLOR_DARK_RED, >+ SWT.COLOR_DARK_GREEN, >+ SWT.COLOR_DARK_BLUE, >+ SWT.COLOR_DARK_MAGENTA, >+ SWT.COLOR_DARK_YELLOW, >+ SWT.COLOR_DARK_CYAN >+ }; >+ static final String canvasString = "Canvas"; //$NON-NLS-1$ >+ >+ /* Example widgets and groups that contain them */ >+ Canvas canvas; >+ Group canvasGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button horizontalButton, verticalButton, noBackgroundButton, noFocusButton, >+ noMergePaintsButton, noRedrawResizeButton, doubleBufferedButton; >+ >+ /* Other widgets added to the "Other" group */ >+ Button caretButton, fillDamageButton; >+ >+ int paintCount; >+ int cx, cy; >+ int maxX, maxY; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ CanvasTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Other" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ >+ /* Create display controls specific to this example */ >+ caretButton = new Button (otherGroup, SWT.CHECK); >+ caretButton.setText (ControlExample.getResourceString("Caret")); >+ fillDamageButton = new Button (otherGroup, SWT.CHECK); >+ fillDamageButton.setText (ControlExample.getResourceString("FillDamage")); >+ >+ /* Add the listeners */ >+ caretButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setCaret (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the canvas widget */ >+ canvasGroup = new Group (exampleGroup, SWT.NONE); >+ canvasGroup.setLayout (new GridLayout ()); >+ canvasGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ canvasGroup.setText ("Canvas"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL; >+ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (noBackgroundButton.getSelection ()) style |= SWT.NO_BACKGROUND; >+ if (noFocusButton.getSelection ()) style |= SWT.NO_FOCUS; >+ if (noMergePaintsButton.getSelection ()) style |= SWT.NO_MERGE_PAINTS; >+ if (noRedrawResizeButton.getSelection ()) style |= SWT.NO_REDRAW_RESIZE; >+ if (doubleBufferedButton.getSelection ()) style |= SWT.DOUBLE_BUFFERED; >+ >+ /* Create the example widgets */ >+ paintCount = 0; cx = 0; cy = 0; >+ canvas = new Canvas (canvasGroup, style); >+ canvas.addPaintListener(new PaintListener () { >+ public void paintControl(PaintEvent e) { >+ paintCount++; >+ GC gc = e.gc; >+ if (fillDamageButton.getSelection ()) { >+ Color color = e.display.getSystemColor (colors [paintCount % colors.length]); >+ gc.setBackground(color); >+ gc.fillRectangle(e.x, e.y, e.width, e.height); >+ } >+ Point size = canvas.getSize (); >+ gc.drawArc(cx + 1, cy + 1, size.x - 2, size.y - 2, 0, 360); >+ gc.drawRectangle(cx + (size.x - 10) / 2, cy + (size.y - 10) / 2, 10, 10); >+ Point extent = gc.textExtent(canvasString); >+ gc.drawString(canvasString, cx + (size.x - extent.x) / 2, cy - extent.y + (size.y - 10) / 2, true); >+ } >+ }); >+ canvas.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent event) { >+ Point size = canvas.getSize (); >+ maxX = size.x * 3 / 2; maxY = size.y * 3 / 2; >+ resizeScrollBars (); >+ } >+ }); >+ ScrollBar bar = canvas.getHorizontalBar(); >+ if (bar != null) { >+ hookListeners (bar); >+ bar.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ scrollHorizontal ((ScrollBar)event.widget); >+ } >+ }); >+ } >+ bar = canvas.getVerticalBar(); >+ if (bar != null) { >+ hookListeners (bar); >+ bar.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ scrollVertical ((ScrollBar)event.widget); >+ } >+ }); >+ } >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup(); >+ >+ /* Create the extra widgets */ >+ horizontalButton = new Button (styleGroup, SWT.CHECK); >+ horizontalButton.setText ("SWT.H_SCROLL"); >+ horizontalButton.setSelection(true); >+ verticalButton = new Button (styleGroup, SWT.CHECK); >+ verticalButton.setText ("SWT.V_SCROLL"); >+ verticalButton.setSelection(true); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ noBackgroundButton = new Button (styleGroup, SWT.CHECK); >+ noBackgroundButton.setText ("SWT.NO_BACKGROUND"); >+ noFocusButton = new Button (styleGroup, SWT.CHECK); >+ noFocusButton.setText ("SWT.NO_FOCUS"); >+ noMergePaintsButton = new Button (styleGroup, SWT.CHECK); >+ noMergePaintsButton.setText ("SWT.NO_MERGE_PAINTS"); >+ noRedrawResizeButton = new Button (styleGroup, SWT.CHECK); >+ noRedrawResizeButton.setText ("SWT.NO_REDRAW_RESIZE"); >+ doubleBufferedButton = new Button (styleGroup, SWT.CHECK); >+ doubleBufferedButton.setText ("SWT.DOUBLE_BUFFERED"); >+ } >+ >+ /** >+ * Creates the tab folder page. >+ * >+ * @param tabFolder org.eclipse.swt.widgets.TabFolder >+ * @return the new page for the tab folder >+ */ >+ Composite createTabFolderPage (TabFolder tabFolder) { >+ super.createTabFolderPage (tabFolder); >+ >+ /* >+ * Add a resize listener to the tabFolderPage so that >+ * if the user types into the example widget to change >+ * its preferred size, and then resizes the shell, we >+ * recalculate the preferred size correctly. >+ */ >+ tabFolderPage.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) { >+ setExampleWidgetSize (); >+ } >+ }); >+ >+ return tabFolderPage; >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {canvas}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Canvas"; >+ } >+ >+ /** >+ * Resizes the maximum and thumb of both scrollbars. >+ */ >+ void resizeScrollBars () { >+ Rectangle clientArea = canvas.getClientArea(); >+ ScrollBar bar = canvas.getHorizontalBar(); >+ if (bar != null) { >+ bar.setMaximum(maxX); >+ bar.setThumb(clientArea.width); >+ bar.setPageIncrement(clientArea.width); >+ } >+ bar = canvas.getVerticalBar(); >+ if (bar != null) { >+ bar.setMaximum(maxY); >+ bar.setThumb(clientArea.height); >+ bar.setPageIncrement(clientArea.height); >+ } >+ } >+ >+ /** >+ * Scrolls the canvas horizontally. >+ * >+ * @param scrollBar >+ */ >+ void scrollHorizontal (ScrollBar scrollBar) { >+ Rectangle bounds = canvas.getClientArea(); >+ int x = -scrollBar.getSelection(); >+ if (x + maxX < bounds.width) { >+ x = bounds.width - maxX; >+ } >+ canvas.scroll(x, cy, cx, cy, maxX, maxY, false); >+ cx = x; >+ } >+ >+ /** >+ * Scrolls the canvas vertically. >+ * >+ * @param scrollBar >+ */ >+ void scrollVertical (ScrollBar scrollBar) { >+ Rectangle bounds = canvas.getClientArea(); >+ int y = -scrollBar.getSelection(); >+ if (y + maxY < bounds.height) { >+ y = bounds.height - maxY; >+ } >+ canvas.scroll(cx, y, cx, cy, maxX, maxY, false); >+ cy = y; >+ } >+ >+ /** >+ * Sets or clears the caret in the "Example" widget. >+ */ >+ void setCaret () { >+ Caret oldCaret = canvas.getCaret (); >+ if (caretButton.getSelection ()) { >+ Caret newCaret = new Caret(canvas, SWT.NONE); >+ Font font = canvas.getFont(); >+ newCaret.setFont(font); >+ GC gc = new GC(canvas); >+ gc.setFont(font); >+ newCaret.setBounds(1, 1, 1, gc.getFontMetrics().getHeight()); >+ gc.dispose(); >+ canvas.setCaret (newCaret); >+ canvas.setFocus(); >+ } else { >+ canvas.setCaret (null); >+ } >+ if (oldCaret != null) oldCaret.dispose (); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ horizontalButton.setSelection ((canvas.getStyle () & SWT.H_SCROLL) != 0); >+ verticalButton.setSelection ((canvas.getStyle () & SWT.V_SCROLL) != 0); >+ borderButton.setSelection ((canvas.getStyle () & SWT.BORDER) != 0); >+ noBackgroundButton.setSelection ((canvas.getStyle () & SWT.NO_BACKGROUND) != 0); >+ noFocusButton.setSelection ((canvas.getStyle () & SWT.NO_FOCUS) != 0); >+ noMergePaintsButton.setSelection ((canvas.getStyle () & SWT.NO_MERGE_PAINTS) != 0); >+ noRedrawResizeButton.setSelection ((canvas.getStyle () & SWT.NO_REDRAW_RESIZE) != 0); >+ doubleBufferedButton.setSelection ((canvas.getStyle () & SWT.DOUBLE_BUFFERED) != 0); >+ if (!instance.startup) setCaret (); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/CombineComposition.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CombineComposition.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CombineComposition.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CombineComposition.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,896 @@ >+package org.eclipse.swt.examples.mirroringTest; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.CoolBar; >+import org.eclipse.swt.widgets.CoolItem; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.List; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; >+import org.eclipse.swt.widgets.ProgressBar; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Slider; >+import org.eclipse.swt.widgets.TabFolder; >+import org.eclipse.swt.widgets.TabItem; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.swt.widgets.TableItem; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.swt.widgets.TreeColumn; >+import org.eclipse.swt.widgets.TreeItem; >+ >+public class CombineComposition extends Composite{ >+ >+ private Button buttonRTLCompositeGroups; >+ private Button buttonLTRCompositeGroups; >+ >+ private Button buttonListRTLCompositeGroups; >+ private Button buttonListLTRCompositeGroups; >+ >+ private Composite compositeGroups; >+ private Slider sliderGtoupC; >+ private Combo comboSimpleGroupA; >+ private Combo comboDropDownGroupA; >+ private Button buttonTextPicGroupA; >+ private Button buttonPic; >+ private Button buttonTextGroupA; >+ private Button buttonRTLGroupA; >+ private Button buttonLTRGroupA; >+ private Label labelPicture; >+ private Label labelTextGroupA; >+ private Button buttonLTRGroupC; >+ private Button buttonRTLGroupC; >+ private ProgressBar progressBarGroupC; >+ private ToolBar toolBar1; >+ CoolItem pushItem, dropDownItem, radioItem, checkItem, textItem; >+ private CoolBar coolBarGroupC; >+ private Tree treeGroupC; >+ TreeItem textNode1, imageNode1; >+ private Group groupC; >+ private Button buttonRTLGroupD; >+ private Button buttonLTRGroupD; >+ private Text textAriaGroupD; >+ private Text textSingleGroupD; >+ private Table tableGroupD; >+ private Composite compositeInTabGtoupD; >+ private TabItem cTabItem1; >+ private TabFolder tabFolderInGroupD; >+ private Group groupD; >+ private Group groupA; >+ private Label labelMultiText; >+ private Label labelSimpleText; >+ private List list; >+ >+ Control[] controls; >+ >+ CombinedBasic combinedBasic; >+ CombinedOrientationExample instance; >+ >+ static String [] ListData = {"\u05d0\u05e0\u05d9\u0020\u05e2\u05d5\u05d1\u05d3\u05ea\u0020\u05d1 - IBM \u05d9\u05e9\u05e8\u05d0\u05dc...", >+ "I work at \u05d9\u05d1\u05de in Israel...", >+ "My name is \u05d0\u05dc\u05d9\u05e1...", >+ "\u05e7\u05d5\u05e8\u05d0\u05d9\u05dd\u0020\u05dc\u05d9 Alice...", >+ "1234..."}; >+ static String [] columnTitles = {CombinedOrientationExample.getResourceString("TableTitle_0"), >+ CombinedOrientationExample.getResourceString("TableTitle_1"), >+ CombinedOrientationExample.getResourceString("TableTitle_2"), >+ CombinedOrientationExample.getResourceString("TableTitle_3")}; >+ >+ static String[][] tableData = { >+ { CombinedOrientationExample.getResourceString("TableLine0_0"), >+ CombinedOrientationExample.getResourceString("TableLine0_1"), >+ CombinedOrientationExample.getResourceString("TableLine0_2"), >+ CombinedOrientationExample.getResourceString("TableLine0_3") }, >+ { CombinedOrientationExample.getResourceString("TableLine1_0"), >+ CombinedOrientationExample.getResourceString("TableLine1_1"), >+ CombinedOrientationExample.getResourceString("TableLine1_2"), >+ CombinedOrientationExample.getResourceString("TableLine1_3") }, >+ { CombinedOrientationExample.getResourceString("TableLine2_0"), >+ CombinedOrientationExample.getResourceString("TableLine2_1"), >+ CombinedOrientationExample.getResourceString("TableLine2_2"), >+ CombinedOrientationExample.getResourceString("TableLine2_3") } }; >+ >+ >+ static String [] widgetsListData = { >+ "\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 - group D...", >+ "Tab folder...", >+// "Tab Item...", >+ "Composite in tab Item...", >+ "Table...", >+ "Simple Text Label...", >+ "Simple Text...", >+ "Multi Text Label...", >+ "Multi Text...", >+ "\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 LTR...", >+ "\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 RTL...", >+ "---", >+ "Complex Group", >+ "Text Label - Complex group...", >+ "Picture Label - Complex group", >+ "Text Button - Complex group", >+ "Picture Button - Complex group", >+ "Text & Picture Button - Complex group", >+ "Drop down combo - Complex group", >+ "Simple combo - Complex group", >+ "LTR button - Complex group", >+ "RTL button - Complex group", >+ "---", >+ "Small Group", >+ "Tree - Small group", >+ "CoolBar - Small group", >+ "Progress Bar - Small group", >+ "Slider - Small group", >+// "pushItem", >+// "dropDownItem", >+// "radioItem", >+// "checkItem", >+// "textItem", >+ "LTR button - Small group", >+ "RTL button - Small group", >+ "---", >+ "List - Me..." >+ }; >+ >+ >+ >+ public CombineComposition(Composite parent, int style, CombinedOrientationExample instance) { >+ super(parent, style); >+ this.instance = instance; >+ initGUI(style); >+ } >+ /** >+ * Initializes the GUI. >+ */ >+ private void initGUI(int style) { >+ try { >+ SelectionListener bidiListener = new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ >+ if(event.widget == buttonRTLCompositeGroups || event.widget == buttonLTRCompositeGroups){ >+ compositeGroups.setOrientation(event.widget == buttonLTRCompositeGroups ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >+ compositeGroups.setToolTipText("I'm " + (event.widget == buttonLTRCompositeGroups ? "LTR" : "RTL")); >+ } >+ if(event.widget == buttonRTLGroupA || event.widget == buttonLTRGroupA){ >+ groupA.setOrientation(event.widget == buttonLTRGroupA ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >+ } >+ if(event.widget == buttonLTRGroupC || event.widget == buttonRTLGroupC){ >+ groupC.setOrientation(event.widget == buttonLTRGroupC ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >+ } >+ if(event.widget == buttonLTRGroupD || event.widget == buttonRTLGroupD){ >+ groupD.setOrientation(event.widget == buttonLTRGroupD ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >+ } >+ if(event.widget == buttonListRTLCompositeGroups || event.widget == buttonListLTRCompositeGroups){ >+ setOrientationItemFromList(list.getSelectionIndices(), event.widget == buttonListLTRCompositeGroups ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); >+ } >+ } >+ }; >+ >+ //this.setBackground(new Color(Display.getDefault(),192, 192, 192)); >+ FormLayout thisLayout = new FormLayout(); >+ this.setLayout(thisLayout); >+ { >+ { >+ FormData listLData = new FormData(); >+ listLData.left = new FormAttachment(0, 1000, 505); >+ listLData.top = new FormAttachment(0, 1000, 26); >+ listLData.width = 99; >+ listLData.height = 509; >+ list = new List(this, style | SWT.MULTI | SWT.BORDER); >+ list.setItems (widgetsListData); >+ >+ list.setLayoutData(listLData); >+ } >+ { >+ buttonListRTLCompositeGroups = new Button(this, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonRTLCompositeGroupsLData = new FormData(); >+ buttonRTLCompositeGroupsLData.left = new FormAttachment(0, 1000, 505); >+ buttonRTLCompositeGroupsLData.top = new FormAttachment(904, 1000, 0); >+ buttonRTLCompositeGroupsLData.width = 50; >+ buttonRTLCompositeGroupsLData.height = 23; >+ buttonListRTLCompositeGroups.setLayoutData(buttonRTLCompositeGroupsLData); >+ buttonListRTLCompositeGroups.setText("Item RTL"); >+ } >+ { >+ buttonListLTRCompositeGroups = new Button(this, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonLTRCompositeGroupsLData = new FormData(); >+ buttonLTRCompositeGroupsLData.width = 50; >+ buttonLTRCompositeGroupsLData.height = 23; >+ buttonLTRCompositeGroupsLData.left = new FormAttachment(0, 1000, 559); >+ buttonLTRCompositeGroupsLData.top = new FormAttachment(904, 1000, 0); >+ buttonListLTRCompositeGroups.setLayoutData(buttonLTRCompositeGroupsLData); >+ buttonListLTRCompositeGroups.setText("Item LTR"); >+ } >+ { >+ buttonRTLCompositeGroups = new Button(this, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonRTLCompositeGroupsLData = new FormData(); >+ buttonRTLCompositeGroupsLData.left = new FormAttachment(860, 1000, 0); >+ buttonRTLCompositeGroupsLData.top = new FormAttachment(950, 1000, 0); >+ buttonRTLCompositeGroupsLData.width = 30; >+ buttonRTLCompositeGroupsLData.height = 23; >+ buttonRTLCompositeGroups.setLayoutData(buttonRTLCompositeGroupsLData); >+ buttonRTLCompositeGroups.setText("RTL"); >+ } >+ { >+ buttonLTRCompositeGroups = new Button(this, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonLTRCompositeGroupsLData = new FormData(); >+ buttonLTRCompositeGroupsLData.width = 30; >+ buttonLTRCompositeGroupsLData.height = 23; >+ buttonLTRCompositeGroupsLData.left = new FormAttachment(916, 1000, 0); >+ buttonLTRCompositeGroupsLData.top = new FormAttachment(950, 1000, 0); >+ buttonLTRCompositeGroups.setLayoutData(buttonLTRCompositeGroupsLData); >+ buttonLTRCompositeGroups.setText("LTR"); >+ } >+ { >+ groupA = new Group(this, SWT.NONE | style); >+ FormLayout groupALayout = new FormLayout(); >+ groupA.setLayout(groupALayout); >+ FormData groupALData = new FormData(); >+ groupALData.width = 385; >+ groupALData.height = 421; >+ groupALData.left = new FormAttachment(11, 1000, 0); >+ groupALData.right = new FormAttachment(817, 1000, 0); >+ groupALData.top = new FormAttachment(9, 1000, 0); >+ groupALData.bottom = new FormAttachment(731, 1000, 0); >+ groupA.setLayoutData(groupALData); >+ groupA.setText("Very complex group..."); >+ groupA.setBackground(new Color(Display.getDefault(),192,192,192)); >+ { >+ comboSimpleGroupA = new Combo(groupA, SWT.NONE | style | SWT.SIMPLE); >+ FormData comboSimpleGroupALData = new FormData(); >+ comboSimpleGroupALData.left = new FormAttachment(0, 1000, 315); >+ comboSimpleGroupALData.top = new FormAttachment(0, 1000, 188); >+ comboSimpleGroupALData.width = 135; >+// comboSimpleGroupALData.height = 21; >+ comboSimpleGroupA.setLayoutData(comboSimpleGroupALData); >+ comboSimpleGroupA.setText("combo"); >+ comboSimpleGroupA.setItems (ListData); >+ if (ListData.length >= 3) { >+ comboSimpleGroupA.setText(ListData [2]); >+ } >+ } >+ { >+ comboDropDownGroupA = new Combo(groupA, SWT.NONE | style | SWT.DROP_DOWN); >+ FormData comboDropDownGroupALData = new FormData(); >+ comboDropDownGroupALData.left = new FormAttachment(0, 1000, 315); >+ comboDropDownGroupALData.top = new FormAttachment(0, 1000, 150); >+// comboDropDownGroupALData.width = 31; >+// comboDropDownGroupALData.height = 21; >+ comboDropDownGroupA.setLayoutData(comboDropDownGroupALData); >+ comboDropDownGroupA.setText("simple combo"); >+ comboDropDownGroupA.setItems (ListData); >+ if (ListData.length >= 3) { >+ comboDropDownGroupA.setText(ListData [2]); >+ } >+ } >+ { >+ buttonTextPicGroupA = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonTextPicGroupALData = new FormData(); >+ buttonTextPicGroupALData.left = new FormAttachment(0, 1000, 316); >+ buttonTextPicGroupALData.top = new FormAttachment(0, 1000, 103); >+ buttonTextPicGroupALData.width = 91; >+ buttonTextPicGroupALData.height = 23; >+ buttonTextPicGroupA.setLayoutData(buttonTextPicGroupALData); >+ buttonTextPicGroupA.setText("Text..."); >+ buttonTextPicGroupA.setImage(instance.images[CombinedOrientationExample.ciOpenFolder]); >+ >+ } >+ { >+ buttonPic = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonPicLData = new FormData(); >+ buttonPicLData.left = new FormAttachment(0, 1000, 374); >+ buttonPicLData.top = new FormAttachment(0, 1000, 74); >+ buttonPic.setLayoutData(buttonPicLData); >+ buttonPic.setImage(instance.images[CombinedOrientationExample.ciOpenFolder]); >+ >+ } >+ { >+ buttonTextGroupA = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonTextGroupALData = new FormData(); >+ buttonTextGroupALData.left = new FormAttachment(0, 1000, 316); >+ buttonTextGroupALData.top = new FormAttachment(0, 1000, 74); >+ buttonTextGroupALData.width = 46; >+ buttonTextGroupALData.height = 23; >+ buttonTextGroupA.setLayoutData(buttonTextGroupALData); >+ buttonTextGroupA.setText("Text..."); >+ } >+ { >+ buttonRTLGroupA = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonRTLGroupALData = new FormData(); >+ buttonRTLGroupALData.left = new FormAttachment(0, 1000, 353); >+ buttonRTLGroupALData.top = new FormAttachment(0, 1000, 384); >+ buttonRTLGroupALData.width = 30; >+ buttonRTLGroupALData.height = 23; >+ buttonRTLGroupA.setLayoutData(buttonRTLGroupALData); >+ buttonRTLGroupA.setText("RTL"); >+ } >+ { >+ buttonLTRGroupA = new Button(groupA, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonLTRGroupALData = new FormData(); >+ buttonLTRGroupALData.left = new FormAttachment(0, 1000, 317); >+ buttonLTRGroupALData.top = new FormAttachment(0, 1000, 384); >+ buttonLTRGroupALData.width = 30; >+ buttonLTRGroupALData.height = 23; >+ buttonLTRGroupA.setLayoutData(buttonLTRGroupALData); >+ buttonLTRGroupA.setText("LTR"); >+ } >+ { >+ labelPicture = new Label(groupA, SWT.NONE | style); >+ FormData labelPictureLData = new FormData(); >+ labelPictureLData.left = new FormAttachment(0, 1000, 316); >+ labelPictureLData.top = new FormAttachment(0, 1000, 38); >+ labelPicture.setLayoutData(labelPictureLData); >+ labelPicture.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >+ } >+ { >+ groupD = new Group(groupA, SWT.NONE | style); >+ FormLayout groupDLayout = new FormLayout(); >+ groupD.setLayout(groupDLayout); >+ FormData groupDLData = new FormData(); >+ groupDLData.width = 267; >+ groupDLData.height = 384; >+ groupDLData.left = new FormAttachment(14, 1000, 0); >+ groupDLData.right = new FormAttachment(638, 1000, 0); >+ groupDLData.top = new FormAttachment(13, 1000, 0); >+ groupDLData.bottom = new FormAttachment(963, 1000, 0); >+ groupD.setLayoutData(groupDLData); >+ groupD.setText("\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4..."); >+ groupD.setBackground(new Color(Display.getDefault(),192, 192, 192)); >+ { >+ labelMultiText = new Label(groupD, SWT.NONE); >+ FormData labelMultiTextLData = new FormData(); >+ labelMultiTextLData.left = new FormAttachment(0, 1000, 0); >+ labelMultiTextLData.top = new FormAttachment(0, 1000, 306); >+ //labelMultiTextLData.width = 56; >+ labelMultiTextLData.height = 13; >+ labelMultiText.setLayoutData(labelMultiTextLData); >+ labelMultiText.setText("SWT.MULTI..."); >+ } >+ { >+ labelSimpleText = new Label(groupD, SWT.NONE); >+ FormData labelSimpleTextLData = new FormData(); >+ labelSimpleTextLData.left = new FormAttachment(0, 1000, 0); >+ labelSimpleTextLData.top = new FormAttachment(0, 1000, 280); >+ //labelSimpleTextLData.width = 53; >+ labelSimpleTextLData.height = 13; >+ labelSimpleText.setLayoutData(labelSimpleTextLData); >+ labelSimpleText.setText("SWT.SINGLE..."); >+ } >+ { >+ buttonRTLGroupD = new Button(groupD, SWT.PUSH | SWT.CENTER); >+ FormData buttonRTLGroupDLData = new FormData(); >+ buttonRTLGroupDLData.width = 108; >+ buttonRTLGroupDLData.height = 23; >+ buttonRTLGroupDLData.left = new FormAttachment(20, 1000, 0); >+ buttonRTLGroupDLData.right = new FormAttachment(425, 1000, 0); >+ buttonRTLGroupDLData.top = new FormAttachment(14, 1000, 0); >+ buttonRTLGroupDLData.bottom = new FormAttachment(74, 1000, 0); >+ buttonRTLGroupD.setLayoutData(buttonRTLGroupDLData); >+ buttonRTLGroupD.setText("\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 RTL..."); >+ } >+ { >+ buttonLTRGroupD = new Button(groupD, SWT.PUSH | SWT.CENTER); >+ FormData buttonLTRGroupDLData = new FormData(); >+ buttonLTRGroupDLData.width = 108; >+ buttonLTRGroupDLData.height = 23; >+ buttonLTRGroupDLData.left = new FormAttachment(20, 1000, 0); >+ buttonLTRGroupDLData.right = new FormAttachment(425, 1000, 0); >+ buttonLTRGroupDLData.top = new FormAttachment(87, 1000, 0); >+ buttonLTRGroupDLData.bottom = new FormAttachment(147, 1000, 0); >+ buttonLTRGroupD.setLayoutData(buttonLTRGroupDLData); >+ buttonLTRGroupD.setText("\u05e7\u05d1\u05d5\u05e6\u05d4 \u05e7\u05d8\u05e0\u05d4 LTR..."); >+ } >+ { >+ tabFolderInGroupD = new TabFolder(groupD, SWT.NONE | style); >+ { >+ cTabItem1 = new TabItem(tabFolderInGroupD, SWT.NONE | style); >+ cTabItem1.setText("Tab"); >+ { >+ compositeInTabGtoupD = new Composite(tabFolderInGroupD, SWT.NONE | style); >+ GridLayout compositeInTabGtoupDLayout = new GridLayout(); >+ compositeInTabGtoupDLayout.makeColumnsEqualWidth = true; >+ compositeInTabGtoupD.setLayout(compositeInTabGtoupDLayout); >+ cTabItem1.setControl(compositeInTabGtoupD); >+ { >+ GridData tableGroupDLData = new GridData(); >+ tableGroupDLData.widthHint = 222; >+ tableGroupDLData.heightHint = 166; >+ tableGroupD = new Table(compositeInTabGtoupD, SWT.NONE | style); >+ for (int i = 0; i < columnTitles.length; i++) { >+ TableColumn tableColumn = new TableColumn(tableGroupD, SWT.NONE); >+ tableColumn.setText(columnTitles[i]); >+ tableColumn.setImage(instance.images [i % 3]); >+ } >+ tableGroupD.setSortColumn(tableGroupD.getColumn(0)); >+ for (int i=0; i<16; i++) { >+ TableItem item = new TableItem (tableGroupD, SWT.NONE); >+ setItemText (item, i, CombinedOrientationExample.getResourceString("Index") + i); >+ } >+ packColumns(); >+ tableGroupD.setHeaderVisible(true); >+ tableGroupD.setLinesVisible (true); >+ tableGroupD.setLayoutData(tableGroupDLData); >+ } >+ } >+ } >+ FormData tabFolderInGroupDLData = new FormData(); >+ tabFolderInGroupDLData.width = 250; >+ tabFolderInGroupDLData.height = 193; >+ tabFolderInGroupDLData.left = new FormAttachment(20, 1000, 0); >+ tabFolderInGroupDLData.right = new FormAttachment(971, 1000, 0); >+ tabFolderInGroupDLData.top = new FormAttachment(160, 1000, 0); >+ tabFolderInGroupDLData.bottom = new FormAttachment(720, 1000, 0); >+ tabFolderInGroupD.setLayoutData(tabFolderInGroupDLData); >+ tabFolderInGroupD.setSelection(0); >+ tabFolderInGroupD.setBackground(new Color(Display.getDefault(),192, 192, 192)); >+ } >+ { >+ textSingleGroupD = new Text(groupD, SWT.NONE | style | SWT.BORDER); >+ FormData textSingleGroupDLData = new FormData(); >+ textSingleGroupDLData.width = 188; >+ textSingleGroupDLData.height = 20; >+ textSingleGroupDLData.left = new FormAttachment(256, 1000, 0); >+ textSingleGroupDLData.right = new FormAttachment(983, 1000, 0); >+ textSingleGroupDLData.top = new FormAttachment(730, 1000, 0); >+ textSingleGroupDLData.bottom = new FormAttachment(782, 1000, 0); >+ textSingleGroupD.setLayoutData(textSingleGroupDLData); >+ } >+ { >+ textAriaGroupD = new Text(groupD, SWT.MULTI | SWT.WRAP | style | SWT.BORDER); >+ FormData textAriaGroupDLData = new FormData(); >+ textAriaGroupDLData.width = 188; >+ textAriaGroupDLData.height = 63; >+ textAriaGroupDLData.left = new FormAttachment(256, 1000, 0); >+ textAriaGroupDLData.right = new FormAttachment(983, 1000, 0); >+ textAriaGroupDLData.top = new FormAttachment(798, 1000, 0); >+ textAriaGroupDLData.bottom = new FormAttachment(962, 1000, 0); >+ textAriaGroupD.setLayoutData(textAriaGroupDLData); >+ } >+ } >+ { >+ labelTextGroupA = new Label(groupA, SWT.NONE | style); >+ FormData labelTextGroupALData = new FormData(); >+ labelTextGroupALData.width = 121; >+ labelTextGroupALData.height = 13; >+ labelTextGroupALData.left = new FormAttachment(704, 1000, 0); >+ labelTextGroupALData.right = new FormAttachment(980, 1000, 0); >+ labelTextGroupALData.top = new FormAttachment(32, 1000, 0); >+ labelTextGroupALData.bottom = new FormAttachment(62, 1000, 0); >+ labelTextGroupA.setLayoutData(labelTextGroupALData); >+ labelTextGroupA.setText("I work at \u05d9\u05d1\u05de Israel..."); >+ } >+ } >+ { >+ groupC = new Group(this, SWT.NONE | style); >+ FormLayout groupCLayout = new FormLayout(); >+ groupC.setLayout(groupCLayout); >+ FormData groupCLData = new FormData(); >+ groupCLData.width = 439; >+ groupCLData.height = 134; >+ groupCLData.left = new FormAttachment(11, 1000, 0); >+ groupCLData.right = new FormAttachment(819, 1000, 0); >+ groupCLData.top = new FormAttachment(741, 1000, 0); >+ groupCLData.bottom = new FormAttachment(989, 1000, 0); >+ groupC.setLayoutData(groupCLData); >+ groupC.setText("Small group..."); >+ groupC.setBackground(new Color(Display.getDefault(),192,192,192)); >+ { >+ FormData sliderGtoupCLData = new FormData(); >+ sliderGtoupCLData.left = new FormAttachment(0, 1000, 201); >+ sliderGtoupCLData.top = new FormAttachment(0, 1000, 110); >+ sliderGtoupCLData.width = 155; >+ sliderGtoupCLData.height = 17; >+ sliderGtoupC = new Slider(groupC, SWT.NONE); >+ sliderGtoupC.setLayoutData(sliderGtoupCLData); >+ } >+ { >+ buttonRTLGroupC = new Button(groupC, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonRTLGroupCLData = new FormData(); >+ buttonRTLGroupCLData.left = new FormAttachment(0, 1000, 400); >+ buttonRTLGroupCLData.top = new FormAttachment(0, 1000, 110); >+ buttonRTLGroupCLData.width = 30; >+ buttonRTLGroupCLData.height = 23; >+ buttonRTLGroupC.setLayoutData(buttonRTLGroupCLData); >+ buttonRTLGroupC.setText("RTL"); >+ } >+ { >+ FormData treeGroupCLData = new FormData(); >+ treeGroupCLData.width = 150; >+ treeGroupCLData.height = 112; >+ treeGroupCLData.left = new FormAttachment(7, 1000, 0); >+// treeGroupCLData.right = new FormAttachment(413, 1000, 0); >+ treeGroupCLData.top = new FormAttachment(26, 1000, 0); >+// treeGroupCLData.bottom = new FormAttachment(988, 1000, 0); >+ treeGroupC = new Tree(groupC, SWT.NONE | style); >+ updateTree(); >+ treeGroupC.setLayoutData(treeGroupCLData); >+ } >+ { >+ FormData coolBarGroupCLData = new FormData(); >+ coolBarGroupCLData.width = 223; >+ coolBarGroupCLData.height = 22; >+ coolBarGroupCLData.left = new FormAttachment(458, 1000, 0); >+ coolBarGroupCLData.right = new FormAttachment(966, 1000, 0); >+ coolBarGroupCLData.top = new FormAttachment(26, 1000, 0); >+ coolBarGroupCLData.bottom = new FormAttachment(190, 1000, 0); >+ coolBarGroupC = new CoolBar(groupC, SWT.NONE | style); >+ updateCoolbar(); >+ coolBarGroupC.setLayoutData(coolBarGroupCLData); >+// { >+// coolItem1 = new CoolItem(coolBarGroupC, SWT.NONE | style); >+// coolItem1.setMinimumSize(new org.eclipse.swt.graphics.Point(48, 23)); >+// coolItem1.setPreferredSize(new org.eclipse.swt.graphics.Point(48, 23)); >+// coolItem1.setSize(48, 23); >+// { >+// toolBar1 = new ToolBar(coolBarGroupC, SWT.NONE | style); >+// coolItem1.setControl(toolBar1); >+// } >+// } >+ } >+ { >+ FormData progressBarGroupCLData = new FormData(); >+ progressBarGroupCLData.width = 229; >+ progressBarGroupCLData.height = 17; >+ progressBarGroupCLData.left = new FormAttachment(458, 1000, 0); >+ progressBarGroupCLData.right = new FormAttachment(980, 1000, 0); >+ progressBarGroupCLData.top = new FormAttachment(652, 1000, 0); >+ progressBarGroupCLData.bottom = new FormAttachment(779, 1000, 0); >+ progressBarGroupC = new ProgressBar(groupC, style | SWT.INDETERMINATE); >+ progressBarGroupC.setLayoutData(progressBarGroupCLData); >+ } >+ { >+ buttonLTRGroupC = new Button(groupC, SWT.PUSH | SWT.CENTER | style); >+ FormData buttonLTRGroupCLData = new FormData(); >+ buttonLTRGroupCLData.width = 32; >+ buttonLTRGroupCLData.height = 23; >+ buttonLTRGroupCLData.left = new FormAttachment(0, 1000, 362); >+ buttonLTRGroupCLData.top = new FormAttachment(0, 1000, 110); >+ buttonLTRGroupC.setLayoutData(buttonLTRGroupCLData); >+ buttonLTRGroupC.setText("LTR"); >+ } >+ } >+ } >+ buttonRTLGroupA.addSelectionListener (bidiListener); >+ buttonLTRGroupA.addSelectionListener (bidiListener); >+ buttonRTLCompositeGroups.addSelectionListener (bidiListener); >+ buttonLTRCompositeGroups.addSelectionListener (bidiListener); >+ buttonListRTLCompositeGroups.addSelectionListener (bidiListener); >+ buttonListLTRCompositeGroups.addSelectionListener (bidiListener); >+ buttonLTRGroupC.addSelectionListener (bidiListener); >+ buttonRTLGroupC.addSelectionListener (bidiListener); >+ buttonLTRGroupD.addSelectionListener (bidiListener); >+ buttonRTLGroupD.addSelectionListener (bidiListener); >+ this.layout(); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ setToolTipText("I'm " + (style == SWT.LEFT_TO_RIGHT ? "LTR" : "RTL")); >+ this.compositeGroups = this; >+ >+ controls = new Control[]{groupD, >+ tabFolderInGroupD, >+// cTabItem1, >+ compositeInTabGtoupD, >+ tableGroupD, >+ labelSimpleText, >+ textSingleGroupD, >+ labelMultiText, >+ textAriaGroupD, >+ buttonLTRGroupD, >+ buttonRTLGroupD, >+ null, >+ groupA, >+ labelTextGroupA, >+ labelPicture, >+ buttonTextGroupA, >+ buttonPic, >+ buttonTextPicGroupA, >+ comboDropDownGroupA, >+ comboSimpleGroupA, >+ buttonLTRGroupA, >+ buttonRTLGroupA, >+ null, >+ groupC, >+ treeGroupC, >+ coolBarGroupC, >+ progressBarGroupC, >+ sliderGtoupC, >+// pushItem, >+// dropDownItem, >+// radioItem, >+// checkItem, >+// textItem, >+ buttonLTRGroupC, >+ buttonRTLGroupC, >+ null, >+ list}; >+ } >+ void setItemText(TableItem item, int i, String node) { >+ int index = i % 3; >+ tableData [index][0] = node; >+ item.setText (tableData [index]); >+ } >+ void packColumns () { >+ int columnCount = tableGroupD.getColumnCount(); >+ for (int i = 0; i < columnCount; i++) { >+ TableColumn tableColumn = tableGroupD.getColumn(i); >+ tableColumn.pack(); >+ } >+ } >+ void updateTree(){ >+ /* Create the image tree */ >+ TreeItem treeRoots[]; >+ TreeItem item; >+ Image image = instance.images[CombinedOrientationExample.ciClosedFolder]; >+ for (int i = 0; i < 4; i++) { >+ item = new TreeItem (treeGroupC, SWT.NONE); >+ setItemText(item, i, CombinedOrientationExample.getResourceString("Node_" + (i + 1))); >+ item.setImage(image); >+ if (i < 3) { >+ TreeItem subitem = new TreeItem (item, SWT.NONE); >+ setItemText(subitem, i, CombinedOrientationExample.getResourceString("Node_" + (i + 1) + "_1")); >+ subitem.setImage(image); >+ } >+ } >+ treeRoots = treeGroupC.getItems (); >+ item = new TreeItem (treeRoots[1], SWT.NONE); >+ setItemText(item, 1, CombinedOrientationExample.getResourceString("Node_2_2")); >+ item.setImage(image); >+ item = new TreeItem (item, SWT.NONE); >+ setItemText(item, 1, CombinedOrientationExample.getResourceString("Node_2_2_1")); >+ item.setImage(image); >+ imageNode1 = treeRoots[0]; >+ packColumns(treeGroupC); >+ >+ } >+ void updateCoolbar(){ >+ int style = getStyle(), itemStyle = 0; >+ >+ /* Compute the widget, item, and item toolBar styles */ >+ int toolBarStyle = SWT.FLAT; >+ boolean vertical = false; >+ style |= SWT.HORIZONTAL; >+ toolBarStyle |= SWT.HORIZONTAL; >+ style |= SWT.BORDER; >+ >+ /* Create the push button toolbar cool item */ >+ ToolBar toolBar = new ToolBar (coolBarGroupC, toolBarStyle); >+ ToolItem item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[CombinedOrientationExample.ciTarget]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (toolBar, SWT.SEPARATOR); >+ item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ pushItem = new CoolItem (coolBarGroupC, itemStyle); >+ pushItem.setControl (toolBar); >+ pushItem.addSelectionListener (new CoolItemSelectionListener()); >+ >+ /* Create the dropdown toolbar cool item */ >+ toolBar = new ToolBar (coolBarGroupC, toolBarStyle); >+ item = new ToolItem (toolBar, SWT.DROP_DOWN); >+ item.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.DROP_DOWN"); >+// item.addSelectionListener (new DropDownSelectionListener()); >+ item = new ToolItem (toolBar, SWT.DROP_DOWN); >+ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.DROP_DOWN"); >+// item.addSelectionListener (new DropDownSelectionListener()); >+ dropDownItem = new CoolItem (coolBarGroupC, itemStyle); >+ dropDownItem.setControl (toolBar); >+ dropDownItem.addSelectionListener (new CoolItemSelectionListener()); >+ >+ /* Create the radio button toolbar cool item */ >+ toolBar = new ToolBar (coolBarGroupC, toolBarStyle); >+ item = new ToolItem (toolBar, SWT.RADIO); >+ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ item = new ToolItem (toolBar, SWT.RADIO); >+ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ item = new ToolItem (toolBar, SWT.RADIO); >+ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ radioItem = new CoolItem (coolBarGroupC, itemStyle); >+ radioItem.setControl (toolBar); >+ radioItem.addSelectionListener (new CoolItemSelectionListener()); >+ >+ /* Create the check button toolbar cool item */ >+ toolBar = new ToolBar (coolBarGroupC, toolBarStyle); >+ item = new ToolItem (toolBar, SWT.CHECK); >+ item.setImage (instance.images[CombinedOrientationExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.CHECK"); >+ item = new ToolItem (toolBar, SWT.CHECK); >+ item.setImage (instance.images[CombinedOrientationExample.ciTarget]); >+ item.setToolTipText ("SWT.CHECK"); >+ item = new ToolItem (toolBar, SWT.CHECK); >+ item.setImage (instance.images[CombinedOrientationExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.CHECK"); >+ item = new ToolItem (toolBar, SWT.CHECK); >+ item.setImage (instance.images[CombinedOrientationExample.ciTarget]); >+ item.setToolTipText ("SWT.CHECK"); >+ checkItem = new CoolItem (coolBarGroupC, itemStyle); >+ checkItem.setControl (toolBar); >+ checkItem.addSelectionListener (new CoolItemSelectionListener()); >+ >+ /* Create the text cool item */ >+ if (!vertical) { >+ Text text = new Text (coolBarGroupC, SWT.BORDER | SWT.SINGLE); >+ textItem = new CoolItem (coolBarGroupC, itemStyle); >+ textItem.setControl (text); >+ textItem.addSelectionListener (new CoolItemSelectionListener()); >+ Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ textSize = textItem.computeSize(textSize.x, textSize.y); >+ textItem.setMinimumSize(textSize); >+ textItem.setPreferredSize(textSize); >+ textItem.setSize(textSize); >+ } >+ >+ /* Set the sizes after adding all cool items */ >+ CoolItem[] coolItems = coolBarGroupC.getItems(); >+ for (int i = 0; i < coolItems.length; i++) { >+ CoolItem coolItem = coolItems[i]; >+ Control control = coolItem.getControl(); >+ Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ Point coolSize = coolItem.computeSize(size.x, size.y); >+ if (control instanceof ToolBar) { >+ ToolBar bar = (ToolBar)control; >+ if (bar.getItemCount() > 0) { >+ if (vertical) { >+ size.y = bar.getItem(0).getBounds().height; >+ } else { >+ size.x = bar.getItem(0).getWidth(); >+ } >+ } >+ } >+ coolItem.setMinimumSize(size); >+ coolItem.setPreferredSize(coolSize); >+ coolItem.setSize(coolSize); >+ } >+ } >+ void setItemText(TreeItem item, int i, String node) { >+ int index = i % 3; >+ tableData [index][0] = node; >+ item.setText (tableData [index]); >+ } >+ void packColumns (Tree tree) { >+ int columnCount = tree.getColumnCount(); >+ for (int i = 0; i < columnCount; i++) { >+ TreeColumn treeColumn = tree.getColumn(i); >+ treeColumn.pack(); >+ } >+ } >+ void setOrientationItemFromList(int[] indexArr, int orientation){ >+ for (int i = 0; i < indexArr.length; i++) { >+ controls[indexArr[i]].setOrientation(orientation); >+ } >+ } >+ class CoolItemSelectionListener extends SelectionAdapter { >+ private Menu menu = null; >+ >+ public void widgetSelected(SelectionEvent event) { >+ /** >+ * A selection event will be fired when the cool item >+ * is selected by its gripper or if the drop down arrow >+ * (or 'chevron') is selected. Examine the event detail >+ * to determine where the widget was selected. >+ */ >+ if (event.detail == SWT.ARROW) { >+ /* If the popup menu is already up (i.e. user pressed arrow twice), >+ * then dispose it. >+ */ >+ if (menu != null) { >+ menu.dispose(); >+ menu = null; >+ return; >+ } >+ >+ /* Get the cool item and convert its bounds to display coordinates. */ >+ CoolItem coolItem = (CoolItem) event.widget; >+ Rectangle itemBounds = coolItem.getBounds (); >+ itemBounds.width = event.x - itemBounds.x; >+ Point pt = coolBarGroupC.toDisplay(new Point (itemBounds.x, itemBounds.y)); >+ itemBounds.x = pt.x; >+ itemBounds.y = pt.y; >+ >+ /* Get the toolbar from the cool item. */ >+ ToolBar toolBar = (ToolBar) coolItem.getControl (); >+ ToolItem[] tools = toolBar.getItems (); >+ int toolCount = tools.length; >+ >+ /* Convert the bounds of each tool item to display coordinates, >+ * and determine which ones are past the bounds of the cool item. >+ */ >+ int i = 0; >+ while (i < toolCount) { >+ Rectangle toolBounds = tools[i].getBounds (); >+ pt = toolBar.toDisplay(new Point(toolBounds.x, toolBounds.y)); >+ toolBounds.x = pt.x; >+ toolBounds.y = pt.y; >+ Rectangle intersection = itemBounds.intersection (toolBounds); >+ if (!intersection.equals (toolBounds)) break; >+ i++; >+ } >+ >+ /* Create a pop-up menu with items for each of the hidden buttons. */ >+ menu = new Menu (getShell(), SWT.POP_UP | (coolBarGroupC.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT))); >+ for (int j = i; j < toolCount; j++) { >+ ToolItem tool = tools[j]; >+ Image image = tool.getImage(); >+ if (image == null) { >+ new MenuItem (menu, SWT.SEPARATOR); >+ } else { >+ if ((tool.getStyle() & SWT.DROP_DOWN) != 0) { >+ MenuItem menuItem = new MenuItem (menu, SWT.CASCADE); >+ menuItem.setImage(image); >+ String text = tool.getToolTipText(); >+ if (text != null) menuItem.setText(text); >+ Menu m = new Menu(menu); >+ menuItem.setMenu(m); >+ for (int k = 0; k < 9; ++k) { >+ text = ControlExample.getResourceString("DropDownData_" + k); >+ if (text.length() != 0) { >+ MenuItem mi = new MenuItem(m, SWT.NONE); >+ mi.setText(text); >+ /* Application code to perform the action for the submenu item would go here. */ >+ } else { >+ new MenuItem(m, SWT.SEPARATOR); >+ } >+ } >+ } else { >+ MenuItem menuItem = new MenuItem (menu, SWT.NONE); >+ menuItem.setImage(image); >+ String text = tool.getToolTipText(); >+ if (text != null) menuItem.setText(text); >+ } >+ /* Application code to perform the action for the menu item would go here. */ >+ } >+ } >+ >+ /* Display the pop-up menu at the lower left corner of the arrow button. >+ * Dispose the menu when the user is done with it. >+ */ >+ pt = coolBarGroupC.toDisplay(new Point(event.x, event.y)); >+ menu.setLocation (pt.x, pt.y); >+ menu.setVisible (true); >+ while (menu != null && !menu.isDisposed() && menu.isVisible ()) { >+ if (!getDisplay().readAndDispatch ()) getDisplay().sleep (); >+ } >+ if (menu != null) { >+ menu.dispose (); >+ menu = null; >+ } >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/swt/examples/mirroringTest/CombinedBasic.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CombinedBasic.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CombinedBasic.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CombinedBasic.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,164 @@ >+package org.eclipse.swt.examples.mirroringTest; >+import org.eclipse.swt.*; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+ >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; >+import org.eclipse.swt.widgets.Shell; >+ >+public class CombinedBasic extends org.eclipse.swt.widgets.Composite { >+ private Menu menu1; >+ private Menu fileMenu; >+ private MenuItem fileMenuItem; >+ private MenuItem aboutMenuItem; >+ private MenuItem contentsMenuItem; >+ private Menu helpMenu; >+ private MenuItem helpMenuItem; >+ private MenuItem exitMenuItem; >+ private MenuItem closeFileMenuItem; >+ private MenuItem saveFileMenuItem; >+ private MenuItem newFileMenuItem; >+ private MenuItem openFileMenuItem; >+ >+ private Button buttonLTRFocused; >+ private Button buttonRTLFocused; >+// private Button buttonRTLShell; >+// private Button buttonLTRShell; >+ >+ private CombineComposition composition1;// = new CombineComposition(this, getStyle() | SWT.LEFT_TO_RIGHT); >+ private CombineComposition composition2;// = new CombineComposition(this, getStyle() | SWT.RIGHT_TO_LEFT); >+ >+ public CombinedBasic(Composite parent, int style, CombinedOrientationExample instance) { >+ super(parent, style); >+ initGUI(instance); >+ } >+ >+ /** >+ * Initializes the GUI. >+ */ >+ private void initGUI(CombinedOrientationExample instance) { >+ /* Add the listeners */ >+ SelectionListener setOrientationListener = new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ int flag = event.widget == buttonRTLFocused ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >+ } >+ }; >+ try { >+ this.setSize(1049, 612); >+ this.setBackground(new Color(Display.getDefault(),192, 192, 192)); >+ FormLayout thisLayout = new FormLayout(); >+ this.setLayout(thisLayout); >+ { >+ composition1 = new CombineComposition(this, getStyle() | SWT.LEFT_TO_RIGHT, instance); >+ FormLayout compositeGroupsLayout = new FormLayout(); >+ FormData compositeGroupsLData = new FormData(); >+ compositeGroupsLData.left = new FormAttachment(0, 1000, 10); >+ compositeGroupsLData.top = new FormAttachment(0, 1000, 7); >+ compositeGroupsLData.width = 612; >+ compositeGroupsLData.height = 605; >+ composition1.setLayoutData(compositeGroupsLData); >+ composition1.setLayout(compositeGroupsLayout); >+ } >+ { >+ composition2 = new CombineComposition(this, SWT.RIGHT_TO_LEFT, instance); >+ FormLayout compositeGroupsLayout = new FormLayout(); >+ FormData compositeGroupsLData = new FormData(); >+ compositeGroupsLData.left = new FormAttachment(0, 1000, 632); >+ compositeGroupsLData.top = new FormAttachment(0, 1000, 7); >+ compositeGroupsLData.width = 612; >+ compositeGroupsLData.height = 605; >+ composition2.setLayoutData(compositeGroupsLData); >+ composition2.setLayout(compositeGroupsLayout); >+ } >+ { >+ menu1 = new Menu(getShell(), SWT.BAR); >+ getShell().setMenuBar(menu1); >+ { >+ fileMenuItem = new MenuItem(menu1, SWT.CASCADE); >+ fileMenuItem.setText("File"); >+ { >+ fileMenu = new Menu(fileMenuItem); >+ { >+ openFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >+ openFileMenuItem.setText("Open"); >+ } >+ { >+ newFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >+ newFileMenuItem.setText("New"); >+ } >+ { >+ saveFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >+ saveFileMenuItem.setText("Save"); >+ } >+ { >+ closeFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >+ closeFileMenuItem.setText("Close"); >+ } >+ { >+ exitMenuItem = new MenuItem(fileMenu, SWT.CASCADE); >+ exitMenuItem.setText("Exit"); >+ } >+ fileMenuItem.setMenu(fileMenu); >+ } >+ } >+ { >+ helpMenuItem = new MenuItem(menu1, SWT.CASCADE); >+ helpMenuItem.setText("Help"); >+ { >+ helpMenu = new Menu(helpMenuItem); >+ { >+ contentsMenuItem = new MenuItem(helpMenu, SWT.CASCADE); >+ contentsMenuItem.setText("Contents"); >+ } >+ { >+ aboutMenuItem = new MenuItem(helpMenu, SWT.CASCADE); >+ aboutMenuItem.setText("About"); >+ } >+ helpMenuItem.setMenu(helpMenu); >+ } >+ } >+ } >+ this.layout(); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ /** >+ * Auto-generated main method to display this >+ * org.eclipse.swt.widgets.Composite inside a new Shell. >+ >+ public static void main(String[] args) { >+ Display display = Display.getDefault(); >+ Shell shell = new Shell(display); >+ CombinedBasic inst = new CombinedBasic(shell, SWT.NULL); >+ Point size = inst.getSize(); >+ shell.setLayout(new FillLayout()); >+ shell.layout(); >+ if(size.x == 0 && size.y == 0) { >+ inst.pack(); >+ shell.pack(); >+ } else { >+ Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y); >+ shell.setSize(shellBounds.width, shellBounds.height); >+ } >+ shell.open(); >+ while (!shell.isDisposed()) { >+ if (!display.readAndDispatch()) >+ display.sleep(); >+ } >+ } >+*/ >+} >Index: src/org/eclipse/swt/examples/mirroringTest/CombinedOrientationExample.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CombinedOrientationExample.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CombinedOrientationExample.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CombinedOrientationExample.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,202 @@ >+package org.eclipse.swt.examples.mirroringTest; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.text.MessageFormat; >+import java.util.MissingResourceException; >+import java.util.ResourceBundle; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.FormAttachment; >+import org.eclipse.swt.layout.FormData; >+import org.eclipse.swt.layout.FormLayout; >+import org.eclipse.swt.layout.RowLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.TabFolder; >+import org.eclipse.swt.widgets.TabItem; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Vector; >+ >+public class CombinedOrientationExample { >+ >+ protected static ResourceBundle resourceBundle = >+ ResourceBundle.getBundle("examples_control"); //$NON-NLS-1$ >+ protected CombinedBasic combineBasic; >+ Image images[]; >+ Shell shell; >+ >+ static final int ciClosedFolder = 0, ciOpenFolder = 1, ciTarget = 2, ciBackground = 3, ciParentBackground = 4; >+ static final String[] imageLocations = { >+ "/org/eclipse/swt/examples/controlexample/closedFolder.gif", //$NON-NLS-1$ >+ "/org/eclipse/swt/examples/controlexample/openFolder.gif", //$NON-NLS-1$ >+ "/org/eclipse/swt/examples/controlexample/target.gif", //$NON-NLS-1$ >+ "/org/eclipse/swt/examples/controlexample/backgroundImage.png", //$NON-NLS-1$ >+ "/org/eclipse/swt/examples/controlexample/parentBackgroundImage.png"}; //$NON-NLS-1$ >+ static final int[] imageTypes = { >+ SWT.ICON, >+ SWT.ICON, >+ SWT.ICON, >+ SWT.BITMAP, >+ SWT.BITMAP}; >+ boolean startup = true; >+ /** >+ * Creates an instance of a ControlExample embedded inside >+ * the supplied parent Composite. >+ * >+ * @param parent the container of the example >+ */ >+ public CombinedOrientationExample(Shell parent) { >+ initResources(); >+ this.shell = parent; >+ combineBasic = new CombinedBasic(parent, SWT.LEFT_TO_RIGHT, this); >+ startup = false; >+ } >+ /** >+ * Loads the resources >+ */ >+ void initResources() { >+ final Class clazz = ControlExample.class; >+ if (resourceBundle != null) { >+ try { >+ if (images == null) { >+ images = new Image[imageLocations.length]; >+ >+ for (int i = 0; i < imageLocations.length; ++i) { >+ InputStream sourceStream = clazz.getResourceAsStream(imageLocations[i]); >+ ImageData source = new ImageData(sourceStream); >+ if (imageTypes[i] == SWT.ICON) { >+ ImageData mask = source.getTransparencyMask(); >+ images[i] = new Image(null, source, mask); >+ } else { >+ images[i] = new Image(null, source); >+ } >+ try { >+ sourceStream.close(); >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } >+ } >+ return; >+ } catch (Throwable t) { >+ } >+ } >+ String error = (resourceBundle != null) ? >+ getResourceString("error.CouldNotLoadResources") : >+ "Unable to load resources"; //$NON-NLS-1$ >+ freeResources(); >+ throw new RuntimeException(error); >+ } >+ /** >+ * Gets a string from the resource bundle. >+ * We don't want to crash because of a missing String. >+ * Returns the key if not found. >+ */ >+ static String getResourceString(String key) { >+ try { >+ return resourceBundle.getString(key)+"..."; >+ } catch (MissingResourceException e) { >+ return key; >+ } catch (NullPointerException e) { >+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ >+ /** >+ * Gets a string from the resource bundle and binds it >+ * with the given arguments. If the key is not found, >+ * return the key. >+ */ >+ static String getResourceString(String key, Object[] args) { >+ try { >+ return MessageFormat.format(getResourceString(key), args); >+ } catch (MissingResourceException e) { >+ return key; >+ } catch (NullPointerException e) { >+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ /** >+ * Disposes of all resources associated with a particular >+ * instance of the ControlExample. >+ */ >+ public void dispose() { >+ /* >+ * Destroy any shells that may have been created >+ * by the Shells tab. When a shell is disposed, >+ * all child shells are also disposed. Therefore >+ * it is necessary to check for disposed shells >+ * in the shells list to avoid disposing a shell >+ * twice. >+ */ >+// tabFolder = null; >+ freeResources(); >+ } >+ >+ /** >+ * Frees the resources >+ */ >+ void freeResources() { >+ if (images != null) { >+ for (int i = 0; i < images.length; ++i) { >+ final Image image = images[i]; >+ if (image != null) image.dispose(); >+ } >+ images = null; >+ } >+ } >+ /** >+ * @param args >+ */ >+ public static void main(String[] args) { >+ Display display = new Display(); >+ final Shell shell = new Shell(display, SWT.SHELL_TRIM); >+ shell.setLayout(new RowLayout()); >+ //CombinedBasic instance = new CombinedBasic(shell, 0, this); >+ CombinedOrientationExample instance = new CombinedOrientationExample(shell); >+ >+ final Button buttonRtl = new Button(shell, SWT.PUSH); >+ buttonRtl.setText("Shell RTL"); >+ final Button buttonLtr = new Button(shell, SWT.PUSH); >+ buttonLtr.setText("Shell LTR"); >+ >+ /* Add the listeners */ >+ SelectionListener setOrientationListener = new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ int flag = event.widget == buttonRtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >+ shell.setOrientation(flag); >+ } >+ }; >+ buttonRtl.addSelectionListener(setOrientationListener); >+ buttonLtr.addSelectionListener(setOrientationListener); >+ shell.setText(getResourceString("window.title")); >+ setShellSize(instance, shell); >+ shell.open(); >+ while (! shell.isDisposed()) { >+ if (! display.readAndDispatch()) display.sleep(); >+ } >+ instance.dispose(); >+ display.dispose(); >+ } >+ /** >+ * Sets the size of the shell to it's "packed" size, >+ * unless that makes it larger than the monitor it is being displayed on, >+ * in which case just set the shell size to be slightly smaller than the monitor. >+ */ >+ static void setShellSize(CombinedOrientationExample instance, Shell shell) { >+ Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ Rectangle monitorArea = shell.getMonitor().getClientArea(); >+ shell.setSize(Math.min(size.x, monitorArea.width), Math.min(size.y, monitorArea.height)); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ComboTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ComboTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ComboTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ComboTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,148 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.*; >+ >+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 = {ControlExample.getResourceString("ListData0_0"), >+ ControlExample.getResourceString("ListData0_1"), >+ ControlExample.getResourceString("ListData0_2"), >+ ControlExample.getResourceString("ListData0_3"), >+ ControlExample.getResourceString("ListData0_4"), >+ ControlExample.getResourceString("ListData0_5"), >+ ControlExample.getResourceString("ListData0_6"), >+ ControlExample.getResourceString("ListData0_7"), >+ ControlExample.getResourceString("ListData0_8")}; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ComboTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the combo box */ >+ comboGroup = new Group (exampleGroup, SWT.NONE); >+ comboGroup.setLayout (new GridLayout ()); >+ comboGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ comboGroup.setText ("Combo"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (dropDownButton.getSelection ()) style |= SWT.DROP_DOWN; >+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >+ if (simpleButton.getSelection ()) style |= SWT.SIMPLE; >+ >+ /* Create the example widgets */ >+ combo1 = new Combo (comboGroup, style); >+ combo1.setItems (ListData); >+ if (ListData.length >= 3) { >+ combo1.setText(ListData [2]); >+ } >+ } >+ >+ /** >+ * Creates the tab folder page. >+ * >+ * @param tabFolder org.eclipse.swt.widgets.TabFolder >+ * @return the new page for the tab folder >+ */ >+ Composite createTabFolderPage (TabFolder tabFolder) { >+ super.createTabFolderPage (tabFolder); >+ >+ /* >+ * Add a resize listener to the tabFolderPage so that >+ * if the user types into the example widget to change >+ * its preferred size, and then resizes the shell, we >+ * recalculate the preferred size correctly. >+ */ >+ tabFolderPage.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) { >+ setExampleWidgetSize (); >+ } >+ }); >+ >+ return tabFolderPage; >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup () { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ dropDownButton = new Button (styleGroup, SWT.RADIO); >+ dropDownButton.setText ("SWT.DROP_DOWN"); >+ simpleButton = new Button (styleGroup, SWT.RADIO); >+ simpleButton.setText("SWT.SIMPLE"); >+ readOnlyButton = new Button (styleGroup, SWT.CHECK); >+ readOnlyButton.setText ("SWT.READ_ONLY"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {combo1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Items", "Orientation", "Selection", "Text", "TextLimit", "ToolTipText", "VisibleItemCount"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "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); >+ readOnlyButton.setEnabled(!simpleButton.getSelection()); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ControlExample.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ControlExample.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ControlExample.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ControlExample.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,265 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.examples.controlexample.*; >+ >+import java.io.*; >+import java.text.*; >+import java.util.*; >+ >+public class ControlExample { >+ protected static ResourceBundle resourceBundle = >+ ResourceBundle.getBundle("examples_control"); //$NON-NLS-1$ >+ protected ShellTab shellTab; >+ protected TabFolder tabFolder; >+ protected Tab [] tabs; >+ Image images[]; >+ >+ static final int ciClosedFolder = 0, ciOpenFolder = 1, ciTarget = 2, ciBackground = 3, ciParentBackground = 4; >+ static final String[] imageLocations = { >+ "/org/eclipse/swt/examples/controlexample/closedFolder.gif", //$NON-NLS-1$ >+ "/org/eclipse/swt/examples/controlexample/openFolder.gif", //$NON-NLS-1$ >+ "/org/eclipse/swt/examples/controlexample/target.gif", //$NON-NLS-1$ >+ "/org/eclipse/swt/examples/controlexample/backgroundImage.png", //$NON-NLS-1$ >+ "/org/eclipse/swt/examples/controlexample/parentBackgroundImage.png"}; //$NON-NLS-1$ >+ static final int[] imageTypes = { >+ SWT.ICON, >+ SWT.ICON, >+ SWT.ICON, >+ SWT.BITMAP, >+ SWT.BITMAP}; >+ >+ boolean startup = true; >+ >+ /** >+ * Creates an instance of a ControlExample embedded inside >+ * the supplied parent Composite. >+ * >+ * @param parent the container of the example >+ */ >+ public ControlExample(Composite parent) { >+ initResources(); >+ tabFolder = new TabFolder (parent, SWT.NONE); >+ tabs = createTabs(); >+ for (int i=0; i<tabs.length; i++) { >+ TabItem item = new TabItem (tabFolder, SWT.NONE); >+ item.setText (tabs [i].getTabText ()); >+ item.setControl (tabs [i].createTabFolderPage (tabFolder)); >+ item.setData (tabs [i]); >+ } >+ >+ /* Workaround: if the tab folder is wider than the screen, >+ * Mac platforms clip instead of somehow scrolling the tab items. >+ * We try to recover some width by using shorter tab names. */ >+ Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ Rectangle monitorArea = parent.getMonitor().getClientArea(); >+ boolean isMac = SWT.getPlatform().equals("carbon") || SWT.getPlatform().equals("cocoa"); >+ if (size.x > monitorArea.width && isMac) { >+ TabItem [] tabItems = tabFolder.getItems(); >+ for (int i=0; i<tabItems.length; i++) { >+ tabItems[i].setText (tabs [i].getShortTabText ()); >+ } >+ } >+ startup = false; >+ } >+ >+ /** >+ * Answers the set of example Tabs >+ */ >+ Tab[] createTabs() { >+ return new Tab [] { >+ new ButtonTab (this), >+ new CanvasTab (this), >+ new ComboTab (this), >+ new CoolBarTab (this), >+ new DateTimeTab (this), >+ new DialogTab (this), >+ new ExpandBarTab (this), >+ new GroupTab (this), >+ new LabelTab (this), >+ new LinkTab (this), >+ new ListTab (this), >+ new MenuTab (this), >+ new ProgressBarTab (this), >+ new SashTab (this), >+ new ScaleTab (this), >+ shellTab = new ShellTab(this), >+ new SliderTab (this), >+ new SpinnerTab (this), >+ new TabFolderTab (this), >+ new TableTab (this), >+ new TextTab (this), >+ new ToolBarTab (this), >+ new ToolTipTab (this), >+ new TreeTab (this), >+ new BrowserTab (this), >+ }; >+ } >+ >+ /** >+ * Disposes of all resources associated with a particular >+ * instance of the ControlExample. >+ */ >+ public void dispose() { >+ /* >+ * Destroy any shells that may have been created >+ * by the Shells tab. When a shell is disposed, >+ * all child shells are also disposed. Therefore >+ * it is necessary to check for disposed shells >+ * in the shells list to avoid disposing a shell >+ * twice. >+ */ >+ if (shellTab != null) shellTab.closeAllShells (); >+ shellTab = null; >+ tabFolder = null; >+ freeResources(); >+ } >+ >+ /** >+ * Frees the resources >+ */ >+ void freeResources() { >+ if (images != null) { >+ for (int i = 0; i < images.length; ++i) { >+ final Image image = images[i]; >+ if (image != null) image.dispose(); >+ } >+ images = null; >+ } >+ } >+ >+ /** >+ * Gets a string from the resource bundle. >+ * We don't want to crash because of a missing String. >+ * Returns the key if not found. >+ */ >+ static String getResourceString(String key) { >+ try { >+ return resourceBundle.getString(key)+"..."; >+ } catch (MissingResourceException e) { >+ return key; >+ } catch (NullPointerException e) { >+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ >+ /** >+ * Gets a string from the resource bundle and binds it >+ * with the given arguments. If the key is not found, >+ * return the key. >+ */ >+ static String getResourceString(String key, Object[] args) { >+ try { >+ return MessageFormat.format(getResourceString(key), args); >+ } catch (MissingResourceException e) { >+ return key; >+ } catch (NullPointerException e) { >+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ >+ /** >+ * Loads the resources >+ */ >+ void initResources() { >+ final Class clazz = ControlExample.class; >+ if (resourceBundle != null) { >+ try { >+ if (images == null) { >+ images = new Image[imageLocations.length]; >+ >+ for (int i = 0; i < imageLocations.length; ++i) { >+ InputStream sourceStream = clazz.getResourceAsStream(imageLocations[i]); >+ ImageData source = new ImageData(sourceStream); >+ if (imageTypes[i] == SWT.ICON) { >+ ImageData mask = source.getTransparencyMask(); >+ images[i] = new Image(null, source, mask); >+ } else { >+ images[i] = new Image(null, source); >+ } >+ try { >+ sourceStream.close(); >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } >+ } >+ return; >+ } catch (Throwable t) { >+ } >+ } >+ String error = (resourceBundle != null) ? >+ getResourceString("error.CouldNotLoadResources") : >+ "Unable to load resources"; //$NON-NLS-1$ >+ freeResources(); >+ throw new RuntimeException(error); >+ } >+ >+ /** >+ * Invokes as a standalone program. >+ */ >+ public static void main(String[] args) { >+ Display display = new Display(); >+ final Shell shell = new Shell(display, SWT.SHELL_TRIM); >+ shell.setLayout(new RowLayout()); >+ ControlExample instance = new ControlExample(shell); >+ final Button buttonRtl = new Button(shell, SWT.PUSH); >+ buttonRtl.setText("Shell RTL"); >+ final Button buttonLtr = new Button(shell, SWT.PUSH); >+ buttonLtr.setText("Shell LTR"); >+ >+ /* Add the listeners */ >+ SelectionListener setOrientationListener = new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ int flag = event.widget == buttonRtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >+ shell.setOrientation(flag); >+ } >+ }; >+ buttonRtl.addSelectionListener(setOrientationListener); >+ buttonLtr.addSelectionListener(setOrientationListener); >+ shell.setText(getResourceString("window.title")); >+ setShellSize(instance, shell); >+ shell.open(); >+ while (! shell.isDisposed()) { >+ if (! display.readAndDispatch()) display.sleep(); >+ } >+ instance.dispose(); >+ display.dispose(); >+ } >+ >+ /** >+ * Grabs input focus. >+ */ >+ public void setFocus() { >+ tabFolder.setFocus(); >+ } >+ >+ /** >+ * Sets the size of the shell to it's "packed" size, >+ * unless that makes it larger than the monitor it is being displayed on, >+ * in which case just set the shell size to be slightly smaller than the monitor. >+ */ >+ static void setShellSize(ControlExample instance, Shell shell) { >+ Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ Rectangle monitorArea = shell.getMonitor().getClientArea(); >+ shell.setSize(Math.min(size.x, monitorArea.width), Math.min(size.y, monitorArea.height)); >+ } >+} >+ >Index: src/org/eclipse/swt/examples/mirroringTest/ControlExampleRTL.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ControlExampleRTL.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ControlExampleRTL.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ControlExampleRTL.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,79 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+ >+import java.io.*; >+import java.text.*; >+import java.util.*; >+ >+public class ControlExampleRTL extends ControlExample{ >+ >+ /** >+ * Creates an instance of a ControlExample embedded inside >+ * the supplied parent Composite. >+ * >+ * @param parent the container of the example >+ */ >+ public ControlExampleRTL(Composite parent) { >+ super(parent); >+ >+ } >+ >+ >+ >+ /** >+ * Invokes as a standalone program. >+ */ >+ public static void main(String[] args) { >+ Display display = new Display(); >+ final Shell shell = new Shell(display, SWT.SHELL_TRIM); >+ shell.setOrientation(SWT.RIGHT_TO_LEFT); >+ shell.setLayout(new RowLayout()); >+ ControlExampleRTL instance = new ControlExampleRTL(shell); >+ >+ final Button buttonRtl = new Button(shell, SWT.PUSH); >+ buttonRtl.setText("Shell RTL"); >+ final Button buttonLtr = new Button(shell, SWT.PUSH); >+ buttonLtr.setText("Shell LTR"); >+ >+ /* Add the listeners */ >+ SelectionListener setOrientationListener = new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ int flag = event.widget == buttonRtl ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >+ shell.setOrientation(flag); >+ } >+ }; >+ buttonRtl.addSelectionListener(setOrientationListener); >+ buttonLtr.addSelectionListener(setOrientationListener); >+ >+ shell.setText(getResourceString("window.title")); >+ setShellSize(instance, shell); >+ shell.open(); >+ >+ while (! shell.isDisposed()) { >+ if (! display.readAndDispatch()) display.sleep(); >+ } >+ instance.dispose(); >+ display.dispose(); >+ } >+ >+ >+} >+ >Index: src/org/eclipse/swt/examples/mirroringTest/CoolBarTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CoolBarTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CoolBarTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CoolBarTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,491 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+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 CoolBarTab extends Tab { >+ /* Example widgets and group that contains them */ >+ CoolBar coolBar; >+ CoolItem pushItem, dropDownItem, radioItem, checkItem, textItem; >+ Group coolBarGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button horizontalButton, verticalButton; >+ Button dropDownButton, flatButton; >+ >+ /* Other widgets added to the "Other" group */ >+ Button lockedButton; >+ >+ Point[] sizes; >+ int[] wrapIndices; >+ int[] order; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ CoolBarTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Other" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ >+ /* Create display controls specific to this example */ >+ lockedButton = new Button (otherGroup, SWT.CHECK); >+ lockedButton.setText (ControlExample.getResourceString("Locked")); >+ >+ /* Add the listeners */ >+ lockedButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetLocked (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ coolBarGroup = new Group (exampleGroup, SWT.NONE); >+ coolBarGroup.setLayout (new GridLayout ()); >+ coolBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ coolBarGroup.setText ("CoolBar"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ int style = getDefaultStyle(), itemStyle = 0; >+ >+ /* Compute the widget, item, and item toolBar styles */ >+ int toolBarStyle = SWT.FLAT; >+ boolean vertical = false; >+ if (horizontalButton.getSelection ()) { >+ style |= SWT.HORIZONTAL; >+ toolBarStyle |= SWT.HORIZONTAL; >+ } >+ if (verticalButton.getSelection ()) { >+ style |= SWT.VERTICAL; >+ toolBarStyle |= SWT.VERTICAL; >+ vertical = true; >+ } >+ if (borderButton.getSelection()) style |= SWT.BORDER; >+ if (flatButton.getSelection()) style |= SWT.FLAT; >+ if (dropDownButton.getSelection()) itemStyle |= SWT.DROP_DOWN; >+ >+ /* >+ * Create the example widgets. >+ */ >+ coolBar = new CoolBar (coolBarGroup, style); >+ >+ /* Create the push button toolbar cool item */ >+ ToolBar toolBar = new ToolBar (coolBar, toolBarStyle); >+ ToolItem item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[ControlExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[ControlExample.ciTarget]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (toolBar, SWT.SEPARATOR); >+ item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (toolBar, SWT.PUSH); >+ item.setImage (instance.images[ControlExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ pushItem = new CoolItem (coolBar, itemStyle); >+ pushItem.setControl (toolBar); >+ pushItem.addSelectionListener (new CoolItemSelectionListener()); >+ >+ /* Create the dropdown toolbar cool item */ >+ toolBar = new ToolBar (coolBar, toolBarStyle); >+ item = new ToolItem (toolBar, SWT.DROP_DOWN); >+ item.setImage (instance.images[ControlExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.DROP_DOWN"); >+ item.addSelectionListener (new DropDownSelectionListener()); >+ item = new ToolItem (toolBar, SWT.DROP_DOWN); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.DROP_DOWN"); >+ item.addSelectionListener (new DropDownSelectionListener()); >+ dropDownItem = new CoolItem (coolBar, itemStyle); >+ dropDownItem.setControl (toolBar); >+ dropDownItem.addSelectionListener (new CoolItemSelectionListener()); >+ >+ /* Create the radio button toolbar cool item */ >+ toolBar = new ToolBar (coolBar, toolBarStyle); >+ item = new ToolItem (toolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ item = new ToolItem (toolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ item = new ToolItem (toolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ radioItem = new CoolItem (coolBar, itemStyle); >+ radioItem.setControl (toolBar); >+ radioItem.addSelectionListener (new CoolItemSelectionListener()); >+ >+ /* Create the check button toolbar cool item */ >+ toolBar = new ToolBar (coolBar, toolBarStyle); >+ item = new ToolItem (toolBar, SWT.CHECK); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.CHECK"); >+ item = new ToolItem (toolBar, SWT.CHECK); >+ item.setImage (instance.images[ControlExample.ciTarget]); >+ item.setToolTipText ("SWT.CHECK"); >+ item = new ToolItem (toolBar, SWT.CHECK); >+ item.setImage (instance.images[ControlExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.CHECK"); >+ item = new ToolItem (toolBar, SWT.CHECK); >+ item.setImage (instance.images[ControlExample.ciTarget]); >+ item.setToolTipText ("SWT.CHECK"); >+ checkItem = new CoolItem (coolBar, itemStyle); >+ checkItem.setControl (toolBar); >+ checkItem.addSelectionListener (new CoolItemSelectionListener()); >+ >+ /* Create the text cool item */ >+ if (!vertical) { >+ Text text = new Text (coolBar, SWT.BORDER | SWT.SINGLE); >+ textItem = new CoolItem (coolBar, itemStyle); >+ textItem.setControl (text); >+ textItem.addSelectionListener (new CoolItemSelectionListener()); >+ Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ textSize = textItem.computeSize(textSize.x, textSize.y); >+ textItem.setMinimumSize(textSize); >+ textItem.setPreferredSize(textSize); >+ textItem.setSize(textSize); >+ } >+ >+ /* Set the sizes after adding all cool items */ >+ CoolItem[] coolItems = coolBar.getItems(); >+ for (int i = 0; i < coolItems.length; i++) { >+ CoolItem coolItem = coolItems[i]; >+ Control control = coolItem.getControl(); >+ Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ Point coolSize = coolItem.computeSize(size.x, size.y); >+ if (control instanceof ToolBar) { >+ ToolBar bar = (ToolBar)control; >+ if (bar.getItemCount() > 0) { >+ if (vertical) { >+ size.y = bar.getItem(0).getBounds().height; >+ } else { >+ size.x = bar.getItem(0).getWidth(); >+ } >+ } >+ } >+ coolItem.setMinimumSize(size); >+ coolItem.setPreferredSize(coolSize); >+ coolItem.setSize(coolSize); >+ } >+ >+ /* If we have saved state, restore it */ >+ if (order != null && order.length == coolBar.getItemCount()) { >+ coolBar.setItemLayout(order, wrapIndices, sizes); >+ } else { >+ coolBar.setWrapIndices(new int[] {1, 3}); >+ } >+ >+ /* Add a listener to resize the group box to match the coolbar */ >+ coolBar.addListener(SWT.Resize, new Listener() { >+ public void handleEvent(Event event) { >+ exampleGroup.layout(); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup(); >+ >+ /* Create the extra widgets */ >+ horizontalButton = new Button (styleGroup, SWT.RADIO); >+ horizontalButton.setText ("SWT.HORIZONTAL"); >+ verticalButton = new Button (styleGroup, SWT.RADIO); >+ verticalButton.setText ("SWT.VERTICAL"); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ flatButton = new Button (styleGroup, SWT.CHECK); >+ flatButton.setText ("SWT.FLAT"); >+ Group itemGroup = new Group(styleGroup, SWT.NONE); >+ itemGroup.setLayout (new GridLayout ()); >+ itemGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ itemGroup.setText(ControlExample.getResourceString("Item_Styles")); >+ dropDownButton = new Button (itemGroup, SWT.CHECK); >+ dropDownButton.setText ("SWT.DROP_DOWN"); >+ } >+ >+ /** >+ * Disposes the "Example" widgets. >+ */ >+ void disposeExampleWidgets () { >+ /* store the state of the toolbar if applicable */ >+ if (coolBar != null) { >+ sizes = coolBar.getItemSizes(); >+ wrapIndices = coolBar.getWrapIndices(); >+ order = coolBar.getItemOrder(); >+ } >+ super.disposeExampleWidgets(); >+ } >+ >+ /** >+ * Gets the "Example" widget children's items, if any. >+ * >+ * @return an array containing the example widget children's items >+ */ >+ Item [] getExampleWidgetItems () { >+ return coolBar.getItems(); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {coolBar}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"ToolTipText"}; >+ } >+ >+ /** >+ * Gets the short text for the tab folder item. >+ */ >+ String getShortTabText() { >+ return "CB"; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "CoolBar"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ horizontalButton.setSelection ((coolBar.getStyle () & SWT.HORIZONTAL) != 0); >+ verticalButton.setSelection ((coolBar.getStyle () & SWT.VERTICAL) != 0); >+ borderButton.setSelection ((coolBar.getStyle () & SWT.BORDER) != 0); >+ flatButton.setSelection ((coolBar.getStyle () & SWT.FLAT) != 0); >+ dropDownButton.setSelection ((coolBar.getItem(0).getStyle () & SWT.DROP_DOWN) != 0); >+ lockedButton.setSelection(coolBar.getLocked()); >+ if (!instance.startup) setWidgetLocked (); >+ } >+ >+ /** >+ * Sets the header visible state of the "Example" widgets. >+ */ >+ void setWidgetLocked () { >+ coolBar.setLocked (lockedButton.getSelection ()); >+ } >+ >+ /** >+ * Listens to widgetSelected() events on SWT.DROP_DOWN type ToolItems >+ * and opens/closes a menu when appropriate. >+ */ >+ class DropDownSelectionListener extends SelectionAdapter { >+ private Menu menu = null; >+ private boolean visible = false; >+ >+ public void widgetSelected(SelectionEvent event) { >+ // Create the menu if it has not already been created >+ if (menu == null) { >+ // Lazy create the menu. >+ menu = new Menu(shell, SWT.POP_UP | (coolBar.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT))); >+ menu.addMenuListener(new MenuAdapter() { >+ public void menuHidden(MenuEvent e) { >+ visible = false; >+ } >+ }); >+ for (int i = 0; i < 9; ++i) { >+ final String text = ControlExample.getResourceString("DropDownData_" + i); >+ if (text.length() != 0) { >+ MenuItem menuItem = new MenuItem(menu, SWT.NONE); >+ menuItem.setText(text); >+ /* >+ * Add a menu selection listener so that the menu is hidden >+ * when the user selects an item from the drop down menu. >+ */ >+ menuItem.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ setMenuVisible(false); >+ } >+ }); >+ } else { >+ new MenuItem(menu, SWT.SEPARATOR); >+ } >+ } >+ } >+ >+ /** >+ * 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. >+ */ >+ if (visible) { >+ // Hide the menu to give the Arrow the appearance of being a toggle button. >+ setMenuVisible(false); >+ } else { >+ // Position the menu below and vertically aligned with the the drop down tool button. >+ final ToolItem toolItem = (ToolItem) event.widget; >+ final ToolBar toolBar = toolItem.getParent(); >+ >+ Rectangle toolItemBounds = toolItem.getBounds(); >+ Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y)); >+ menu.setLocation(point.x, point.y + toolItemBounds.height); >+ setMenuVisible(true); >+ } >+ } else { >+ /* >+ * Main area of drop down tool item selected. >+ * An application would invoke the code to perform the action for the tool item. >+ */ >+ } >+ } >+ private void setMenuVisible(boolean visible) { >+ menu.setVisible(visible); >+ menu.setOrientation(menu.getParent().getOrientation()); >+ this.visible = visible; >+ } >+ } >+ >+ /** >+ * Listens to widgetSelected() events on SWT.DROP_DOWN type CoolItems >+ * and opens/closes a menu when appropriate. >+ */ >+ class CoolItemSelectionListener extends SelectionAdapter { >+ private Menu menu = null; >+ >+ public void widgetSelected(SelectionEvent event) { >+ /** >+ * A selection event will be fired when the cool item >+ * is selected by its gripper or if the drop down arrow >+ * (or 'chevron') is selected. Examine the event detail >+ * to determine where the widget was selected. >+ */ >+ if (event.detail == SWT.ARROW) { >+ /* If the popup menu is already up (i.e. user pressed arrow twice), >+ * then dispose it. >+ */ >+ if (menu != null) { >+ menu.dispose(); >+ menu = null; >+ return; >+ } >+ >+ /* Get the cool item and convert its bounds to display coordinates. */ >+ CoolItem coolItem = (CoolItem) event.widget; >+ Rectangle itemBounds = coolItem.getBounds (); >+ itemBounds.width = event.x - itemBounds.x; >+ Point pt = coolBar.toDisplay(new Point (itemBounds.x, itemBounds.y)); >+ itemBounds.x = pt.x; >+ itemBounds.y = pt.y; >+ >+ /* Get the toolbar from the cool item. */ >+ ToolBar toolBar = (ToolBar) coolItem.getControl (); >+ ToolItem[] tools = toolBar.getItems (); >+ int toolCount = tools.length; >+ >+ /* Convert the bounds of each tool item to display coordinates, >+ * and determine which ones are past the bounds of the cool item. >+ */ >+ int i = 0; >+ while (i < toolCount) { >+ Rectangle toolBounds = tools[i].getBounds (); >+ pt = toolBar.toDisplay(new Point(toolBounds.x, toolBounds.y)); >+ toolBounds.x = pt.x; >+ toolBounds.y = pt.y; >+ Rectangle intersection = itemBounds.intersection (toolBounds); >+ if (!intersection.equals (toolBounds)) break; >+ i++; >+ } >+ >+ /* Create a pop-up menu with items for each of the hidden buttons. */ >+ menu = new Menu (shell, SWT.POP_UP | (coolBar.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT))); >+ for (int j = i; j < toolCount; j++) { >+ ToolItem tool = tools[j]; >+ Image image = tool.getImage(); >+ if (image == null) { >+ new MenuItem (menu, SWT.SEPARATOR); >+ } else { >+ if ((tool.getStyle() & SWT.DROP_DOWN) != 0) { >+ MenuItem menuItem = new MenuItem (menu, SWT.CASCADE); >+ menuItem.setImage(image); >+ String text = tool.getToolTipText(); >+ if (text != null) menuItem.setText(text); >+ Menu m = new Menu(menu); >+ menuItem.setMenu(m); >+ for (int k = 0; k < 9; ++k) { >+ text = ControlExample.getResourceString("DropDownData_" + k); >+ if (text.length() != 0) { >+ MenuItem mi = new MenuItem(m, SWT.NONE); >+ mi.setText(text); >+ /* Application code to perform the action for the submenu item would go here. */ >+ } else { >+ new MenuItem(m, SWT.SEPARATOR); >+ } >+ } >+ } else { >+ MenuItem menuItem = new MenuItem (menu, SWT.NONE); >+ menuItem.setImage(image); >+ String text = tool.getToolTipText(); >+ if (text != null) menuItem.setText(text); >+ } >+ /* Application code to perform the action for the menu item would go here. */ >+ } >+ } >+ >+ /* Display the pop-up menu at the lower left corner of the arrow button. >+ * Dispose the menu when the user is done with it. >+ */ >+ pt = coolBar.toDisplay(new Point(event.x, event.y)); >+ menu.setLocation (pt.x, pt.y); >+ menu.setVisible (true); >+ while (menu != null && !menu.isDisposed() && menu.isVisible ()) { >+ if (!display.readAndDispatch ()) display.sleep (); >+ } >+ if (menu != null) { >+ menu.dispose (); >+ menu = null; >+ } >+ } >+ } >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/CustomControlExample.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/CustomControlExample.java >diff -N src/org/eclipse/swt/examples/mirroringTest/CustomControlExample.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/CustomControlExample.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,58 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+ >+ >+public class CustomControlExample extends ControlExample { >+ >+ /** >+ * Creates an instance of a CustomControlExample embedded >+ * inside the supplied parent Composite. >+ * >+ * @param parent the container of the example >+ */ >+ public CustomControlExample(Composite parent) { >+ super (parent); >+ } >+ >+ /** >+ * Answers the set of example Tabs >+ */ >+ Tab[] createTabs() { >+ return new Tab [] { >+ new CComboTab (this), >+ new CLabelTab (this), >+ new CTabFolderTab (this), >+ new SashFormTab (this), >+ new StyledTextTab (this), >+ }; >+ } >+ >+ /** >+ * Invokes as a standalone program. >+ */ >+ public static void main(String[] args) { >+ Display display = new Display(); >+ Shell shell = new Shell(display); >+ shell.setLayout(new FillLayout()); >+ CustomControlExample instance = new CustomControlExample(shell); >+ shell.setText(getResourceString("custom.window.title")); >+ setShellSize(instance, shell); >+ shell.open(); >+ while (! shell.isDisposed()) { >+ if (! display.readAndDispatch()) display.sleep(); >+ } >+ instance.dispose(); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/DateTimeTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/DateTimeTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/DateTimeTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/DateTimeTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,137 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+ >+class DateTimeTab extends Tab { >+ /* Example widgets and groups that contain them */ >+ DateTime dateTime1; >+ Group dateTimeGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ //Button /*dateButton, timeButton, calendarButton, shortButton, mediumButton, longButton, dropDownButton*/; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ DateTimeTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the list */ >+ dateTimeGroup = new Group (exampleGroup, SWT.NONE); >+ dateTimeGroup.setLayout (new GridLayout ()); >+ dateTimeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ dateTimeGroup.setText ("Calendar");//("DateTime"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ /* if (dateButton.getSelection ()) style |= SWT.DATE; >+ if (timeButton.getSelection ()) style |= SWT.TIME; >+ if (calendarButton.getSelection ()) style |= SWT.CALENDAR; >+*/ style |= SWT.CALENDAR; >+/* if (shortButton.getSelection ()) style |= SWT.SHORT; >+ if (mediumButton.getSelection ()) style |= SWT.MEDIUM; >+ if (longButton.getSelection ()) style |= SWT.LONG; >+ if (dropDownButton.getSelection ()) style |= SWT.DROP_DOWN; >+ */ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ >+ /* Create the example widgets */ >+ dateTime1 = new DateTime (dateTimeGroup, style); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+/* dateButton = new Button(styleGroup, SWT.RADIO); >+ dateButton.setText("SWT.DATE"); >+ timeButton = new Button(styleGroup, SWT.RADIO); >+ timeButton.setText("SWT.TIME"); >+ calendarButton = new Button(styleGroup, SWT.RADIO); >+ calendarButton.setText("SWT.CALENDAR"); >+ Group formatGroup = new Group(styleGroup, SWT.NONE); >+ formatGroup.setLayout(new GridLayout()); >+ shortButton = new Button(formatGroup, SWT.RADIO); >+ shortButton.setText("SWT.SHORT"); >+ mediumButton = new Button(formatGroup, SWT.RADIO); >+ mediumButton.setText("SWT.MEDIUM"); >+ longButton = new Button(formatGroup, SWT.RADIO); >+ longButton.setText("SWT.LONG"); >+ dropDownButton = new Button(styleGroup, SWT.CHECK); >+ dropDownButton.setText("SWT.DROP_DOWN"); >+*/ borderButton = new Button(styleGroup, SWT.CHECK); >+ borderButton.setText("SWT.BORDER"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {dateTime1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Day", "Hours", "Minutes", "Month", "Seconds", "Year"}; >+ } >+ >+ /** >+ * Gets the short text for the tab folder item. >+ */ >+ String getShortTabText() { >+ return "DT"; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "DateTime"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+/* dateButton.setSelection ((dateTime1.getStyle () & SWT.DATE) != 0); >+ timeButton.setSelection ((dateTime1.getStyle () & SWT.TIME) != 0); >+ calendarButton.setSelection ((dateTime1.getStyle () & SWT.CALENDAR) != 0); >+ shortButton.setSelection ((dateTime1.getStyle () & SWT.SHORT) != 0); >+ mediumButton.setSelection ((dateTime1.getStyle () & SWT.MEDIUM) != 0); >+ longButton.setSelection ((dateTime1.getStyle () & SWT.LONG) != 0); >+ dropDownButton.setSelection ((dateTime1.getStyle () & SWT.DROP_DOWN) != 0); >+*/ borderButton.setSelection ((dateTime1.getStyle () & SWT.BORDER) != 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/DialogTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/DialogTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/DialogTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/DialogTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,521 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.printing.*; >+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 createButton; >+ Button okButton, cancelButton; >+ Button yesButton, noButton; >+ Button retryButton; >+ Button abortButton, ignoreButton; >+ Button iconErrorButton, iconInformationButton, iconQuestionButton; >+ Button iconWarningButton, iconWorkingButton, noIconButton; >+ Button primaryModalButton, applicationModalButton, systemModalButton; >+ Button sheetButton; >+ Button saveButton, openButton, multiButton; >+ >+ static String [] FilterExtensions = {"*.txt", "*.bat", "*.doc", "*"}; >+ static String [] FilterNames = {ControlExample.getResourceString("FilterName_0"), >+ ControlExample.getResourceString("FilterName_1"), >+ ControlExample.getResourceString("FilterName_2"), >+ ControlExample.getResourceString("FilterName_3")}; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ DialogTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * 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. >+ */ >+ boolean ok = okButton.getSelection (); >+ boolean cancel = cancelButton.getSelection (); >+ boolean yes = yesButton.getSelection (); >+ boolean no = noButton.getSelection (); >+ boolean abort = abortButton.getSelection (); >+ boolean retry = retryButton.getSelection (); >+ boolean ignore = ignoreButton.getSelection (); >+ >+ okButton.setEnabled (!(yes || no || retry || abort || ignore)); >+ cancelButton.setEnabled (!(abort || ignore || (yes != no))); >+ yesButton.setEnabled (!(ok || retry || abort || ignore || (cancel && !yes && !no))); >+ noButton.setEnabled (!(ok || retry || abort || ignore || (cancel && !yes && !no))); >+ retryButton.setEnabled (!(ok || yes || no)); >+ abortButton.setEnabled (!(ok || cancel || yes || no)); >+ ignoreButton.setEnabled (!(ok || cancel || yes || no)); >+ >+ createButton.setEnabled ( >+ !(ok || cancel || yes || no || retry || abort || ignore) || >+ ok || >+ (ok && cancel) || >+ (yes && no) || >+ (yes && no && cancel) || >+ (retry && cancel) || >+ (abort && retry && ignore)); >+ >+ >+ } >+ >+ /** >+ * Handle the create button selection event. >+ * >+ * @param event org.eclipse.swt.events.SelectionEvent >+ */ >+ void createButtonSelected(SelectionEvent event) { >+ >+ /* Compute the appropriate dialog style */ >+ int style = getDefaultStyle(); >+ 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 (sheetButton.getSelection ()) style |= SWT.SHEET; >+ if (saveButton.getEnabled () && saveButton.getSelection ()) style |= SWT.SAVE; >+ if (openButton.getEnabled () && openButton.getSelection ()) style |= SWT.OPEN; >+ if (multiButton.getEnabled () && multiButton.getSelection ()) style |= SWT.MULTI; >+ >+ /* Open the appropriate dialog type */ >+ String name = dialogCombo.getText (); >+ >+ if (name.equals (ControlExample.getResourceString("ColorDialog"))) { >+ ColorDialog dialog = new ColorDialog (shell ,style); >+ dialog.setRGB (new RGB (100, 100, 100)); >+ dialog.setText (ControlExample.getResourceString("Title")); >+ RGB result = dialog.open (); >+ textWidget.append (ControlExample.getResourceString("ColorDialog") + Text.DELIMITER); >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); >+ textWidget.append ("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER); >+ return; >+ } >+ >+ if (name.equals (ControlExample.getResourceString("DirectoryDialog"))) { >+ DirectoryDialog dialog = new DirectoryDialog (shell, style); >+ dialog.setMessage (ControlExample.getResourceString("Example_string")); >+ dialog.setText (ControlExample.getResourceString("Title")); >+ String result = dialog.open (); >+ textWidget.append (ControlExample.getResourceString("DirectoryDialog") + Text.DELIMITER); >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER + Text.DELIMITER); >+ return; >+ } >+ >+ if (name.equals (ControlExample.getResourceString("FileDialog"))) { >+ FileDialog dialog = new FileDialog (shell, style); >+ dialog.setFileName (ControlExample.getResourceString("readme_txt")); >+ dialog.setFilterNames (FilterNames); >+ dialog.setFilterExtensions (FilterExtensions); >+ dialog.setText (ControlExample.getResourceString("Title")); >+ String result = dialog.open(); >+ textWidget.append (ControlExample.getResourceString("FileDialog") + Text.DELIMITER); >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); >+ textWidget.append ("getFilterPath() =" + dialog.getFilterPath() + Text.DELIMITER); >+ textWidget.append ("getFileName() =" + dialog.getFileName() + Text.DELIMITER); >+ textWidget.append ("getFileNames() =" + Text.DELIMITER); >+ String [] files = dialog.getFileNames (); >+ for (int i=0; i<files.length; i++) { >+ textWidget.append ("\t" + files [i] + Text.DELIMITER); >+ } >+ textWidget.append ("getFilterIndex() = " + dialog.getFilterIndex() + Text.DELIMITER + Text.DELIMITER); >+ return; >+ } >+ >+ if (name.equals (ControlExample.getResourceString("FontDialog"))) { >+ FontDialog dialog = new FontDialog (shell, style); >+ dialog.setText (ControlExample.getResourceString("Title")); >+ FontData result = dialog.open (); >+ textWidget.append (ControlExample.getResourceString("FontDialog") + Text.DELIMITER); >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); >+ textWidget.append ("getFontList() =" + Text.DELIMITER); >+ FontData [] fonts = dialog.getFontList (); >+ if (fonts != null) { >+ for (int i=0; i<fonts.length; i++) { >+ textWidget.append ("\t" + fonts [i] + Text.DELIMITER); >+ } >+ } >+ textWidget.append ("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER); >+ return; >+ } >+ >+ if (name.equals (ControlExample.getResourceString("PrintDialog"))) { >+ PrintDialog dialog = new PrintDialog (shell, style); >+ dialog.setText(ControlExample.getResourceString("Title")); >+ PrinterData result = dialog.open (); >+ textWidget.append (ControlExample.getResourceString("PrintDialog") + Text.DELIMITER); >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"" + result}) + Text.DELIMITER); >+ textWidget.append ("getScope() = " + dialog.getScope() + Text.DELIMITER); >+ textWidget.append ("getStartPage() = " + dialog.getStartPage() + Text.DELIMITER); >+ textWidget.append ("getEndPage() = " + dialog.getEndPage() + Text.DELIMITER); >+ textWidget.append ("getPrintToFile() = " + dialog.getPrintToFile() + Text.DELIMITER); >+ if (result != null) { >+ textWidget.append ("result.fileName = " + result.fileName + Text.DELIMITER); >+ textWidget.append ("result.orientation = " + (result.orientation == PrinterData.LANDSCAPE ? "PrinterData.LANDSCAPE" : "PrinterData.PORTRAIT") + Text.DELIMITER); >+ textWidget.append ("result.copyCount = " + result.copyCount + Text.DELIMITER); >+ textWidget.append ("result.collate = " + result.collate + Text.DELIMITER); >+ } >+ textWidget.append (Text.DELIMITER); >+ return; >+ } >+ >+ if (name.equals(ControlExample.getResourceString("MessageBox"))) { >+ MessageBox dialog = new MessageBox (shell, style); >+ dialog.setMessage (ControlExample.getResourceString("Example_string")); >+ dialog.setText (ControlExample.getResourceString("Title")); >+ int result = dialog.open (); >+ textWidget.append (ControlExample.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 (ControlExample.getResourceString("Result", new String [] {"SWT.OK"})); >+ break; >+ case SWT.YES: >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.YES"})); >+ break; >+ case SWT.NO: >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.NO"})); >+ break; >+ case SWT.CANCEL: >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.CANCEL"})); >+ break; >+ case SWT.ABORT: >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.ABORT"})); >+ break; >+ case SWT.RETRY: >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.RETRY"})); >+ break; >+ case SWT.IGNORE: >+ textWidget.append (ControlExample.getResourceString("Result", new String [] {"SWT.IGNORE"})); >+ break; >+ default: >+ textWidget.append(ControlExample.getResourceString("Result", new String [] {"" + result})); >+ break; >+ } >+ textWidget.append (Text.DELIMITER + Text.DELIMITER); >+ } >+ } >+ >+ /** >+ * Creates the "Control" group. >+ */ >+ void createControlGroup () { >+ /* >+ * Create the "Control" group. This is the group on the >+ * right 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 (ControlExample.getResourceString("Parameters")); >+ >+ /* >+ * Create a group to hold the dialog style combo box and >+ * create dialog button. >+ */ >+ dialogStyleGroup = new Group (controlGroup, SWT.NONE); >+ dialogStyleGroup.setLayout (new GridLayout ()); >+ GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER); >+ gridData.horizontalSpan = 2; >+ dialogStyleGroup.setLayoutData (gridData); >+ dialogStyleGroup.setText (ControlExample.getResourceString("Dialog_Type")); >+ } >+ >+ /** >+ * Creates the "Control" widget children. >+ */ >+ void createControlWidgets () { >+ >+ /* Create the combo */ >+ String [] strings = { >+ ControlExample.getResourceString("ColorDialog"), >+ ControlExample.getResourceString("DirectoryDialog"), >+ ControlExample.getResourceString("FileDialog"), >+ ControlExample.getResourceString("FontDialog"), >+ ControlExample.getResourceString("PrintDialog"), >+ ControlExample.getResourceString("MessageBox"), >+ }; >+ dialogCombo = new Combo (dialogStyleGroup, SWT.READ_ONLY); >+ dialogCombo.setItems (strings); >+ dialogCombo.setText (strings [0]); >+ dialogCombo.setVisibleItemCount(strings.length); >+ >+ /* Create the create dialog button */ >+ createButton = new Button(dialogStyleGroup, SWT.NONE); >+ createButton.setText (ControlExample.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.NONE); >+ buttonStyleGroup.setLayout (new GridLayout ()); >+ buttonStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ buttonStyleGroup.setText (ControlExample.getResourceString("Button_Styles")); >+ >+ /* Create the button style buttons */ >+ okButton = new Button (buttonStyleGroup, SWT.CHECK); >+ okButton.setText ("SWT.OK"); >+ cancelButton = new Button (buttonStyleGroup, SWT.CHECK); >+ cancelButton.setText ("SWT.CANCEL"); >+ yesButton = new Button (buttonStyleGroup, SWT.CHECK); >+ yesButton.setText ("SWT.YES"); >+ noButton = new Button (buttonStyleGroup, SWT.CHECK); >+ noButton.setText ("SWT.NO"); >+ retryButton = new Button (buttonStyleGroup, SWT.CHECK); >+ retryButton.setText ("SWT.RETRY"); >+ abortButton = new Button (buttonStyleGroup, SWT.CHECK); >+ abortButton.setText ("SWT.ABORT"); >+ ignoreButton = new Button (buttonStyleGroup, SWT.CHECK); >+ ignoreButton.setText ("SWT.IGNORE"); >+ >+ /* Create a group for the icon style controls */ >+ Group iconStyleGroup = new Group (controlGroup, SWT.NONE); >+ iconStyleGroup.setLayout (new GridLayout ()); >+ iconStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ iconStyleGroup.setText (ControlExample.getResourceString("Icon_Styles")); >+ >+ /* Create the icon style buttons */ >+ iconErrorButton = new Button (iconStyleGroup, SWT.RADIO); >+ iconErrorButton.setText ("SWT.ICON_ERROR"); >+ iconInformationButton = new Button (iconStyleGroup, SWT.RADIO); >+ iconInformationButton.setText ("SWT.ICON_INFORMATION"); >+ iconQuestionButton = new Button (iconStyleGroup, SWT.RADIO); >+ iconQuestionButton.setText ("SWT.ICON_QUESTION"); >+ iconWarningButton = new Button (iconStyleGroup, SWT.RADIO); >+ iconWarningButton.setText ("SWT.ICON_WARNING"); >+ iconWorkingButton = new Button (iconStyleGroup, SWT.RADIO); >+ iconWorkingButton.setText ("SWT.ICON_WORKING"); >+ noIconButton = new Button (iconStyleGroup, SWT.RADIO); >+ noIconButton.setText (ControlExample.getResourceString("No_Icon")); >+ >+ /* Create a group for the modal style controls */ >+ Group modalStyleGroup = new Group (controlGroup, SWT.NONE); >+ modalStyleGroup.setLayout (new GridLayout ()); >+ modalStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ modalStyleGroup.setText (ControlExample.getResourceString("Modal_Styles")); >+ >+ /* Create the modal style buttons */ >+ primaryModalButton = new Button (modalStyleGroup, SWT.RADIO); >+ primaryModalButton.setText ("SWT.PRIMARY_MODAL"); >+ applicationModalButton = new Button (modalStyleGroup, SWT.RADIO); >+ applicationModalButton.setText ("SWT.APPLICATION_MODAL"); >+ systemModalButton = new Button (modalStyleGroup, SWT.RADIO); >+ systemModalButton.setText ("SWT.SYSTEM_MODAL"); >+ >+ /* Create a group for other style controls */ >+ Group otherStyleGroup = new Group (controlGroup, SWT.NONE); >+ otherStyleGroup.setLayout (new GridLayout ()); >+ otherStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ otherStyleGroup.setText (ControlExample.getResourceString("Other_Styles")); >+ >+ /* Create the other style buttons */ >+ sheetButton = new Button(otherStyleGroup, SWT.CHECK); >+ sheetButton.setText("SWT.SHEET"); >+ >+ /* Create a group for the file dialog style controls */ >+ Group fileDialogStyleGroup = new Group (controlGroup, SWT.NONE); >+ fileDialogStyleGroup.setLayout (new GridLayout ()); >+ fileDialogStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ fileDialogStyleGroup.setText (ControlExample.getResourceString("File_Dialog_Styles")); >+ >+ /* Create the file dialog style buttons */ >+ openButton = new Button(fileDialogStyleGroup, SWT.RADIO); >+ openButton.setText("SWT.OPEN"); >+ saveButton = new Button (fileDialogStyleGroup, SWT.RADIO); >+ saveButton.setText ("SWT.SAVE"); >+ multiButton = new Button(fileDialogStyleGroup, SWT.CHECK); >+ multiButton.setText("SWT.MULTI"); >+ >+ /* Create the orientation group */ >+ if (RTL_SUPPORT_ENABLE) { >+ createOrientationGroup(); >+ } >+ >+ /* 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); >+ noIconButton.setEnabled (false); >+ saveButton.setEnabled (false); >+ openButton.setEnabled (false); >+ openButton.setSelection (true); >+ multiButton.setEnabled (false); >+ noIconButton.setSelection (true); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ >+ /* >+ * Create a group for the text widget to display >+ * the results returned by the example dialogs. >+ */ >+ resultGroup = new Group (exampleGroup, SWT.NONE); >+ resultGroup.setLayout (new GridLayout ()); >+ resultGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ resultGroup.setText (ControlExample.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.FILL_BOTH); >+ textWidget.setLayoutData (gridData); >+ } >+ >+ /** >+ * The platform dialogs do not have SWT listeners. >+ */ >+ void createListenersGroup () { >+ } >+ >+ /** >+ * 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 (ControlExample.getResourceString("MessageBox")); >+ boolean isFileDialog = name.equals (ControlExample.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); >+ noIconButton.setEnabled (isMessageBox); >+ saveButton.setEnabled (isFileDialog); >+ openButton.setEnabled (isFileDialog); >+ multiButton.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. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [0]; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Dialog"; >+ } >+ >+ /** >+ * Recreates the "Example" widgets. >+ */ >+ void recreateExampleWidgets () { >+ if (textWidget == null) { >+ super.recreateExampleWidgets (); >+ } >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ExpandBarTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ExpandBarTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ExpandBarTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ExpandBarTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,145 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+ >+class ExpandBarTab extends Tab { >+ /* Example widgets and groups that contain them */ >+ ExpandBar expandBar1; >+ Group expandBarGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button verticalButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ExpandBarTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the list */ >+ expandBarGroup = new Group (exampleGroup, SWT.NONE); >+ expandBarGroup.setLayout (new GridLayout ()); >+ expandBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ expandBarGroup.setText ("ExpandBar"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (verticalButton.getSelection()) style |= SWT.V_SCROLL; >+ >+ /* Create the example widgets */ >+ expandBar1 = new ExpandBar (expandBarGroup, style); >+ >+ // First item >+ Composite composite = new Composite (expandBar1, SWT.NONE); >+ composite.setLayout(new GridLayout ()); >+ new Button (composite, SWT.PUSH).setText("SWT.PUSH"); >+ new Button (composite, SWT.RADIO).setText("SWT.RADIO"); >+ new Button (composite, SWT.CHECK).setText("SWT.CHECK"); >+ new Button (composite, SWT.TOGGLE).setText("SWT.TOGGLE"); >+ ExpandItem item = new ExpandItem (expandBar1, SWT.NONE, 0); >+ item.setText(ControlExample.getResourceString("Item1_Text")); >+ item.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); >+ item.setControl(composite); >+ item.setImage(instance.images[ControlExample.ciClosedFolder]); >+ >+ // Second item >+ composite = new Composite (expandBar1, SWT.NONE); >+ composite.setLayout(new GridLayout (2, false)); >+ new Label (composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_ERROR)); >+ new Label (composite, SWT.NONE).setText("SWT.ICON_ERROR"); >+ new Label (composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_INFORMATION)); >+ new Label (composite, SWT.NONE).setText("SWT.ICON_INFORMATION"); >+ new Label (composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_WARNING)); >+ new Label (composite, SWT.NONE).setText("SWT.ICON_WARNING"); >+ new Label (composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_QUESTION)); >+ new Label (composite, SWT.NONE).setText("SWT.ICON_QUESTION"); >+ item = new ExpandItem (expandBar1, SWT.NONE, 1); >+ item.setText(ControlExample.getResourceString("Item2_Text")); >+ item.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); >+ item.setControl(composite); >+ item.setImage(instance.images[ControlExample.ciOpenFolder]); >+ item.setExpanded(true); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ verticalButton = new Button (styleGroup, SWT.CHECK); >+ verticalButton.setText ("SWT.V_SCROLL"); >+ verticalButton.setSelection(true); >+ borderButton = new Button(styleGroup, SWT.CHECK); >+ borderButton.setText("SWT.BORDER"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {expandBar1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Spacing"}; >+ } >+ >+ /** >+ * Gets the short text for the tab folder item. >+ */ >+ String getShortTabText() { >+ return "EB"; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "ExpandBar"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ Widget [] widgets = getExampleWidgets (); >+ if (widgets.length != 0){ >+ verticalButton.setSelection ((widgets [0].getStyle () & SWT.V_SCROLL) != 0); >+ borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0); >+ } >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/GroupTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/GroupTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/GroupTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/GroupTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,154 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+ >+class GroupTab extends Tab { >+ Button titleButton; >+ >+ /* Example widgets and groups that contain them */ >+ Group group1; >+ Group groupGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button shadowEtchedInButton, shadowEtchedOutButton, shadowInButton, shadowOutButton, shadowNoneButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ GroupTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Other" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ >+ /* Create display controls specific to this example */ >+ titleButton = new Button (otherGroup, SWT.CHECK); >+ titleButton.setText (ControlExample.getResourceString("Title_Text")); >+ >+ /* Add the listeners */ >+ titleButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setTitleText (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the Group */ >+ groupGroup = new Group (exampleGroup, SWT.NONE); >+ groupGroup.setLayout (new GridLayout ()); >+ groupGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ groupGroup.setText ("Group"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (shadowEtchedInButton.getSelection ()) style |= SWT.SHADOW_ETCHED_IN; >+ if (shadowEtchedOutButton.getSelection ()) style |= SWT.SHADOW_ETCHED_OUT; >+ if (shadowInButton.getSelection ()) style |= SWT.SHADOW_IN; >+ if (shadowOutButton.getSelection ()) style |= SWT.SHADOW_OUT; >+ if (shadowNoneButton.getSelection ()) style |= SWT.SHADOW_NONE; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ >+ /* Create the example widgets */ >+ group1 = new Group (groupGroup, style); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ shadowEtchedInButton = new Button (styleGroup, SWT.RADIO); >+ shadowEtchedInButton.setText ("SWT.SHADOW_ETCHED_IN"); >+ shadowEtchedInButton.setSelection(true); >+ shadowEtchedOutButton = new Button (styleGroup, SWT.RADIO); >+ shadowEtchedOutButton.setText ("SWT.SHADOW_ETCHED_OUT"); >+ shadowInButton = new Button (styleGroup, SWT.RADIO); >+ shadowInButton.setText ("SWT.SHADOW_IN"); >+ shadowOutButton = new Button (styleGroup, SWT.RADIO); >+ shadowOutButton.setText ("SWT.SHADOW_OUT"); >+ shadowNoneButton = new Button (styleGroup, SWT.RADIO); >+ shadowNoneButton.setText ("SWT.SHADOW_NONE"); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {group1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Text", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Group"; >+ } >+ >+ /** >+ * Sets the title text of the "Example" widgets. >+ */ >+ void setTitleText () { >+ if (titleButton.getSelection ()) { >+ group1.setText (ControlExample.getResourceString("Title_Text")); >+ } else { >+ group1.setText (""); >+ } >+ setExampleWidgetSize (); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ shadowEtchedInButton.setSelection ((group1.getStyle () & SWT.SHADOW_ETCHED_IN) != 0); >+ shadowEtchedOutButton.setSelection ((group1.getStyle () & SWT.SHADOW_ETCHED_OUT) != 0); >+ shadowInButton.setSelection ((group1.getStyle () & SWT.SHADOW_IN) != 0); >+ shadowOutButton.setSelection ((group1.getStyle () & SWT.SHADOW_OUT) != 0); >+ shadowNoneButton.setSelection ((group1.getStyle () & SWT.SHADOW_NONE) != 0); >+ borderButton.setSelection ((group1.getStyle () & SWT.BORDER) != 0); >+ if (!instance.startup) setTitleText (); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/LabelTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/LabelTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/LabelTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/LabelTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,184 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+ >+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 wrapButton, separatorButton, horizontalButton, verticalButton, shadowInButton, shadowOutButton, shadowNoneButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ LabelTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the text labels */ >+ textLabelGroup = new Group(exampleGroup, SWT.NONE); >+ GridLayout gridLayout = new GridLayout (); >+ textLabelGroup.setLayout (gridLayout); >+ gridLayout.numColumns = 3; >+ textLabelGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ textLabelGroup.setText (ControlExample.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 (SWT.FILL, SWT.FILL, true, true)); >+ imageLabelGroup.setText (ControlExample.getResourceString("Image_Labels")); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (wrapButton.getSelection ()) style |= SWT.WRAP; >+ 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 (shadowNoneButton.getSelection ()) style |= SWT.SHADOW_NONE; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (leftButton.getSelection ()) style |= SWT.LEFT; >+ if (centerButton.getSelection ()) style |= SWT.CENTER; >+ if (rightButton.getSelection ()) style |= SWT.RIGHT; >+ >+ /* Create the example widgets */ >+ label1 = new Label (textLabelGroup, style); >+ label1.setText(ControlExample.getResourceString("One")); >+ label2 = new Label (textLabelGroup, style); >+ label2.setText(ControlExample.getResourceString("Two")); >+ label3 = new Label (textLabelGroup, style); >+ if (wrapButton.getSelection ()) { >+ label3.setText (ControlExample.getResourceString("Wrap_Text")); >+ } else { >+ label3.setText (ControlExample.getResourceString("Three")); >+ } >+ label4 = new Label (imageLabelGroup, style); >+ label4.setImage (instance.images[ControlExample.ciClosedFolder]); >+ label5 = new Label (imageLabelGroup, style); >+ label5.setImage (instance.images[ControlExample.ciOpenFolder]); >+ label6 = new Label(imageLabelGroup, style); >+ label6.setImage (instance.images[ControlExample.ciTarget]); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ wrapButton = new Button (styleGroup, SWT.CHECK); >+ wrapButton.setText ("SWT.WRAP"); >+ separatorButton = new Button (styleGroup, SWT.CHECK); >+ separatorButton.setText ("SWT.SEPARATOR"); >+ horizontalButton = new Button (styleGroup, SWT.RADIO); >+ horizontalButton.setText ("SWT.HORIZONTAL"); >+ verticalButton = new Button (styleGroup, SWT.RADIO); >+ verticalButton.setText ("SWT.VERTICAL"); >+ Group styleSubGroup = new Group (styleGroup, SWT.NONE); >+ styleSubGroup.setLayout (new GridLayout ()); >+ shadowInButton = new Button (styleSubGroup, SWT.RADIO); >+ shadowInButton.setText ("SWT.SHADOW_IN"); >+ shadowOutButton = new Button (styleSubGroup, SWT.RADIO); >+ shadowOutButton.setText ("SWT.SHADOW_OUT"); >+ shadowNoneButton = new Button (styleSubGroup, SWT.RADIO); >+ shadowNoneButton.setText ("SWT.SHADOW_NONE"); >+ borderButton = new Button(styleGroup, SWT.CHECK); >+ borderButton.setText("SWT.BORDER"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {label1, label2, label3, label4, label5, label6}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Text", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Label"; >+ } >+ >+ /** >+ * Sets the alignment of the "Example" widgets. >+ */ >+ void setExampleWidgetAlignment () { >+ int alignment = 0; >+ if (leftButton.getSelection ()) alignment = SWT.LEFT; >+ if (centerButton.getSelection ()) alignment = SWT.CENTER; >+ if (rightButton.getSelection ()) alignment = SWT.RIGHT; >+ label1.setAlignment (alignment); >+ label2.setAlignment (alignment); >+ label3.setAlignment (alignment); >+ label4.setAlignment (alignment); >+ label5.setAlignment (alignment); >+ label6.setAlignment (alignment); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ boolean isSeparator = (label1.getStyle () & SWT.SEPARATOR) != 0; >+ wrapButton.setSelection (!isSeparator && (label1.getStyle () & SWT.WRAP) != 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); >+ shadowNoneButton.setSelection (isSeparator && (label1.getStyle () & SWT.SHADOW_NONE) != 0); >+ horizontalButton.setSelection (isSeparator && (label1.getStyle () & SWT.HORIZONTAL) != 0); >+ verticalButton.setSelection (isSeparator && (label1.getStyle () & SWT.VERTICAL) != 0); >+ wrapButton.setEnabled (!isSeparator); >+ leftButton.setEnabled (!isSeparator); >+ centerButton.setEnabled (!isSeparator); >+ rightButton.setEnabled (!isSeparator); >+ shadowInButton.setEnabled (isSeparator); >+ shadowOutButton.setEnabled (isSeparator); >+ shadowNoneButton.setEnabled (isSeparator); >+ horizontalButton.setEnabled (isSeparator); >+ verticalButton.setEnabled (isSeparator); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/LinkTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/LinkTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/LinkTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/LinkTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,98 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+ >+class LinkTab extends Tab { >+ /* Example widgets and groups that contain them */ >+ Link link1; >+ Group linkGroup; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ LinkTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the list */ >+ linkGroup = new Group (exampleGroup, SWT.NONE); >+ linkGroup.setLayout (new GridLayout ()); >+ linkGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ linkGroup.setText ("Link"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ >+ /* Create the example widgets */ >+ try { >+ link1 = new Link (linkGroup, style); >+ link1.setText (ControlExample.getResourceString("LinkText")); >+ } catch (SWTError e) { >+ // temporary code for photon >+ Label label = new Label (linkGroup, SWT.CENTER | SWT.WRAP); >+ label.setText ("Link widget not suported"); >+ } >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ borderButton = new Button(styleGroup, SWT.CHECK); >+ borderButton.setText("SWT.BORDER"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+// temporary code for photon >+ if (link1 != null) return new Widget [] {link1}; >+ return new Widget[] {}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Text", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Link"; >+ } >+ >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ListTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ListTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ListTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ListTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,93 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+ >+class ListTab extends ScrollableTab { >+ >+ /* Example widgets and groups that contain them */ >+ List list1; >+ Group listGroup; >+ >+ static String [] ListData1 = {ControlExample.getResourceString("ListData1_0"), >+ ControlExample.getResourceString("ListData1_1"), >+ ControlExample.getResourceString("ListData1_2"), >+ ControlExample.getResourceString("ListData1_3"), >+ ControlExample.getResourceString("ListData1_4"), >+ ControlExample.getResourceString("ListData1_5"), >+ ControlExample.getResourceString("ListData1_6"), >+ ControlExample.getResourceString("ListData1_7"), >+ ControlExample.getResourceString("ListData1_8")}; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ListTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the list */ >+ listGroup = new Group (exampleGroup, SWT.NONE); >+ listGroup.setLayout (new GridLayout ()); >+ listGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ listGroup.setText ("List"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ 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. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {list1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Items", "Selection", "ToolTipText", "TopIndex"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "List"; >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/MenuTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/MenuTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/MenuTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/MenuTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,319 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.events.*; >+ >+class MenuTab extends Tab { >+ /* Widgets added to the "Menu Style", "MenuItem Style" and "Other" groups */ >+ Button barButton, dropDownButton, popUpButton, noRadioGroupButton, leftToRightButton, rightToLeftButton; >+ Button checkButton, cascadeButton, pushButton, radioButton, separatorButton; >+ Button imagesButton, acceleratorsButton, mnemonicsButton, subMenuButton, subSubMenuButton; >+ Button createButton, closeAllButton, enabledButton; >+ Group menuItemStyleGroup; >+ >+ /* Variables used to track the open shells */ >+ int shellCount = 0; >+ Shell [] shells = new Shell [4]; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ MenuTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * 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; >+ } >+ >+ int orientation = 0; >+ if (leftToRightButton.getSelection()) orientation |= SWT.LEFT_TO_RIGHT; >+ if (rightToLeftButton.getSelection()) orientation |= SWT.RIGHT_TO_LEFT; >+ int radioBehavior = 0; >+ if (noRadioGroupButton.getSelection()) radioBehavior |= SWT.NO_RADIO_GROUP; >+ >+ /* Create the shell and menu(s) */ >+ Shell shell = new Shell (SWT.SHELL_TRIM | orientation); >+ shells [shellCount] = shell; >+ if (barButton.getSelection ()) { >+ /* Create menu bar. */ >+ Menu menuBar = new Menu(shell, SWT.BAR | radioBehavior ); >+ shell.setMenuBar(menuBar); >+ hookListeners(menuBar); >+ >+ if (dropDownButton.getSelection() && cascadeButton.getSelection()) { >+ /* Create cascade button and drop-down menu in menu bar. */ >+ MenuItem item = new MenuItem(menuBar, SWT.CASCADE); >+ item.setText(getMenuItemText("Cascade")); >+ item.setEnabled(enabledButton.getSelection()); >+ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]); >+ hookListeners(item); >+ Menu dropDownMenu = new Menu(shell, SWT.DROP_DOWN | radioBehavior); >+ item.setMenu(dropDownMenu); >+ hookListeners(dropDownMenu); >+ >+ /* Create various menu items, depending on selections. */ >+ createMenuItems(dropDownMenu, subMenuButton.getSelection(), subSubMenuButton.getSelection()); >+ } >+ } >+ >+ if (popUpButton.getSelection()) { >+ /* Create pop-up menu. */ >+ Menu popUpMenu = new Menu(shell, SWT.POP_UP | radioBehavior); >+ shell.setMenu(popUpMenu); >+ hookListeners(popUpMenu); >+ >+ /* Create various menu items, depending on selections. */ >+ createMenuItems(popUpMenu, subMenuButton.getSelection(), subSubMenuButton.getSelection()); >+ } >+ >+ /* Set the size, title and open the shell. */ >+ shell.setSize (300, 100); >+ shell.setText (ControlExample.getResourceString("Title") + shellCount); >+ shell.addPaintListener(new PaintListener() { >+ public void paintControl(PaintEvent e) { >+ e.gc.drawString(ControlExample.getResourceString("PopupMenuHere"), 20, 20); >+ } >+ }); >+ shell.open (); >+ shellCount++; >+ } >+ >+ /** >+ * Creates the "Control" group. >+ */ >+ void createControlGroup () { >+ /* >+ * Create the "Control" group. This is the group on the >+ * right half of each example tab. For MenuTab, it consists of >+ * the Menu style group, the MenuItem style group and the 'other' group. >+ */ >+ controlGroup = new Group (tabFolderPage, SWT.NONE); >+ controlGroup.setLayout (new GridLayout (2, true)); >+ controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ controlGroup.setText (ControlExample.getResourceString("Parameters")); >+ >+ /* Create a group for the menu style controls */ >+ styleGroup = new Group (controlGroup, SWT.NONE); >+ styleGroup.setLayout (new GridLayout ()); >+ styleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ styleGroup.setText (ControlExample.getResourceString("Menu_Styles")); >+ >+ /* Create a group for the menu item style controls */ >+ menuItemStyleGroup = new Group (controlGroup, SWT.NONE); >+ menuItemStyleGroup.setLayout (new GridLayout ()); >+ menuItemStyleGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ menuItemStyleGroup.setText (ControlExample.getResourceString("MenuItem_Styles")); >+ >+ /* Create a group for the 'other' controls */ >+ otherGroup = new Group (controlGroup, SWT.NONE); >+ otherGroup.setLayout (new GridLayout ()); >+ otherGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ otherGroup.setText (ControlExample.getResourceString("Other")); >+ } >+ >+ /** >+ * Creates the "Control" widget children. >+ */ >+ void createControlWidgets () { >+ >+ /* Create the menu style buttons */ >+ barButton = new Button (styleGroup, SWT.CHECK); >+ barButton.setText ("SWT.BAR"); >+ dropDownButton = new Button (styleGroup, SWT.CHECK); >+ dropDownButton.setText ("SWT.DROP_DOWN"); >+ popUpButton = new Button (styleGroup, SWT.CHECK); >+ popUpButton.setText ("SWT.POP_UP"); >+ noRadioGroupButton = new Button (styleGroup, SWT.CHECK); >+ noRadioGroupButton.setText ("SWT.NO_RADIO_GROUP"); >+ leftToRightButton = new Button (styleGroup, SWT.RADIO); >+ leftToRightButton.setText ("SWT.LEFT_TO_RIGHT"); >+ leftToRightButton.setSelection(true); >+ rightToLeftButton = new Button (styleGroup, SWT.RADIO); >+ rightToLeftButton.setText ("SWT.RIGHT_TO_LEFT"); >+ >+ /* Create the menu item style buttons */ >+ cascadeButton = new Button (menuItemStyleGroup, SWT.CHECK); >+ cascadeButton.setText ("SWT.CASCADE"); >+ checkButton = new Button (menuItemStyleGroup, SWT.CHECK); >+ checkButton.setText ("SWT.CHECK"); >+ pushButton = new Button (menuItemStyleGroup, SWT.CHECK); >+ pushButton.setText ("SWT.PUSH"); >+ radioButton = new Button (menuItemStyleGroup, SWT.CHECK); >+ radioButton.setText ("SWT.RADIO"); >+ separatorButton = new Button (menuItemStyleGroup, SWT.CHECK); >+ separatorButton.setText ("SWT.SEPARATOR"); >+ >+ /* Create the 'other' buttons */ >+ imagesButton = new Button (otherGroup, SWT.CHECK); >+ imagesButton.setText (ControlExample.getResourceString("Images")); >+ acceleratorsButton = new Button (otherGroup, SWT.CHECK); >+ acceleratorsButton.setText (ControlExample.getResourceString("Accelerators")); >+ mnemonicsButton = new Button (otherGroup, SWT.CHECK); >+ mnemonicsButton.setText (ControlExample.getResourceString("Mnemonics")); >+ subMenuButton = new Button (otherGroup, SWT.CHECK); >+ subMenuButton.setText (ControlExample.getResourceString("SubMenu")); >+ subSubMenuButton = new Button (otherGroup, SWT.CHECK); >+ subSubMenuButton.setText (ControlExample.getResourceString("SubSubMenu")); >+ enabledButton = new Button(otherGroup, SWT.CHECK); >+ enabledButton.setText(ControlExample.getResourceString("Cascade Menu Enabled")); >+ >+ >+ /* Create the "create" and "closeAll" buttons (and a 'filler' label to place them) */ >+ new Label(controlGroup, SWT.NONE); >+ createButton = new Button (controlGroup, SWT.NONE); >+ createButton.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_END)); >+ createButton.setText (ControlExample.getResourceString("Create_Shell")); >+ closeAllButton = new Button (controlGroup, SWT.NONE); >+ closeAllButton.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING)); >+ closeAllButton.setText (ControlExample.getResourceString("Close_All_Shells")); >+ >+ /* Add the listeners */ >+ enabledButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleWidgetEnabled (); >+ } >+ }); >+ >+ createButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ createButtonSelected(e); >+ } >+ }); >+ closeAllButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ closeAllShells (); >+ } >+ }); >+ subMenuButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ subSubMenuButton.setEnabled (subMenuButton.getSelection ()); >+ } >+ }); >+ >+ /* Set the default state */ >+ barButton.setSelection (true); >+ dropDownButton.setSelection (true); >+ popUpButton.setSelection (true); >+ cascadeButton.setSelection (true); >+ checkButton.setSelection (true); >+ pushButton.setSelection (true); >+ radioButton.setSelection (true); >+ separatorButton.setSelection (true); >+ subSubMenuButton.setEnabled (subMenuButton.getSelection ()); >+ } >+ >+ /* Create various menu items, depending on selections. */ >+ void createMenuItems(Menu menu, boolean createSubMenu, boolean createSubSubMenu) { >+ MenuItem item; >+ if (pushButton.getSelection()) { >+ item = new MenuItem(menu, SWT.PUSH); >+ item.setText(getMenuItemText("Push")); >+ if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + 'P'); >+ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciClosedFolder]); >+ hookListeners(item); >+ } >+ >+ if (separatorButton.getSelection()) { >+ new MenuItem(menu, SWT.SEPARATOR); >+ } >+ >+ if (checkButton.getSelection()) { >+ item = new MenuItem(menu, SWT.CHECK); >+ item.setText(getMenuItemText("Check")); >+ if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + 'C'); >+ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]); >+ hookListeners(item); >+ } >+ >+ if (radioButton.getSelection()) { >+ item = new MenuItem(menu, SWT.RADIO); >+ item.setText(getMenuItemText("1Radio")); >+ if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + '1'); >+ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciTarget]); >+ item.setSelection(true); >+ hookListeners(item); >+ >+ item = new MenuItem(menu, SWT.RADIO); >+ item.setText(getMenuItemText("2Radio")); >+ if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + '2'); >+ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciTarget]); >+ hookListeners(item); >+ } >+ >+ if (createSubMenu && cascadeButton.getSelection()) { >+ /* Create cascade button and drop-down menu for the sub-menu. */ >+ item = new MenuItem(menu, SWT.CASCADE); >+ item.setText(getMenuItemText("Cascade")); >+ if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]); >+ hookListeners(item); >+ Menu subMenu = new Menu(menu.getShell(), SWT.DROP_DOWN); >+ item.setMenu(subMenu); >+ hookListeners(subMenu); >+ >+ createMenuItems(subMenu, createSubSubMenu, false); >+ } >+ } >+ >+ String getMenuItemText(String item) { >+ boolean cascade = item.equals("Cascade"); >+ boolean mnemonic = mnemonicsButton.getSelection(); >+ boolean accelerator = acceleratorsButton.getSelection(); >+ char acceleratorKey = item.charAt(0); >+ if (mnemonic && accelerator && !cascade) { >+ return ControlExample.getResourceString(item + "WithMnemonic") + "\tCtrl+Shift+" + acceleratorKey; >+ } >+ if (accelerator && !cascade) { >+ return ControlExample.getResourceString(item) + "\tCtrl+Shift+" + acceleratorKey; >+ } >+ if (mnemonic) { >+ return ControlExample.getResourceString(item + "WithMnemonic"); >+ } >+ return ControlExample.getResourceString(item); >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Menu"; >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ProgressBarTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ProgressBarTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ProgressBarTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ProgressBarTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,178 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+ >+class ProgressBarTab extends RangeTab { >+ /* Example widgets and groups that contain them */ >+ ProgressBar progressBar1; >+ Group progressBarGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button smoothButton; >+ Button indeterminateButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ProgressBarTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup() { >+ super.createExampleGroup (); >+ >+ /* Create a group for the progress bar */ >+ progressBarGroup = new Group (exampleGroup, SWT.NONE); >+ progressBarGroup.setLayout (new GridLayout ()); >+ progressBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ progressBarGroup.setText ("ProgressBar"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL; >+ if (verticalButton.getSelection ()) style |= SWT.VERTICAL; >+ if (smoothButton.getSelection ()) style |= SWT.SMOOTH; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (indeterminateButton.getSelection ()) style |= SWT.INDETERMINATE; >+ >+ /* Create the example widgets */ >+ progressBar1 = new ProgressBar (progressBarGroup, style); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup () { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ smoothButton = new Button (styleGroup, SWT.CHECK); >+ smoothButton.setText ("SWT.SMOOTH"); >+ indeterminateButton = new Button (styleGroup, SWT.CHECK); >+ indeterminateButton.setText ("SWT.INDETERMINATE"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {progressBar1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Selection", "State", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the short text for the tab folder item. >+ */ >+ String getShortTabText() { >+ return "PB"; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "ProgressBar"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ if (indeterminateButton.getSelection ()) { >+ selectionSpinner.setEnabled (false); >+ minimumSpinner.setEnabled (false); >+ maximumSpinner.setEnabled (false); >+ } else { >+ selectionSpinner.setEnabled (true); >+ minimumSpinner.setEnabled (true); >+ maximumSpinner.setEnabled (true); >+ } >+ smoothButton.setSelection ((progressBar1.getStyle () & SWT.SMOOTH) != 0); >+ indeterminateButton.setSelection ((progressBar1.getStyle () & SWT.INDETERMINATE) != 0); >+ } >+ >+ /** >+ * Gets the default maximum of the "Example" widgets. >+ */ >+ int getDefaultMaximum () { >+ return progressBar1.getMaximum(); >+ } >+ >+ /** >+ * Gets the default minimim of the "Example" widgets. >+ */ >+ int getDefaultMinimum () { >+ return progressBar1.getMinimum(); >+ } >+ >+ /** >+ * Gets the default selection of the "Example" widgets. >+ */ >+ int getDefaultSelection () { >+ return progressBar1.getSelection(); >+ } >+ >+ /** >+ * Sets the maximum of the "Example" widgets. >+ */ >+ void setWidgetMaximum () { >+ progressBar1.setMaximum (maximumSpinner.getSelection ()); >+ updateSpinners (); >+ } >+ >+ /** >+ * Sets the minimim of the "Example" widgets. >+ */ >+ void setWidgetMinimum () { >+ progressBar1.setMinimum (minimumSpinner.getSelection ()); >+ updateSpinners (); >+ } >+ >+ /** >+ * Sets the selection of the "Example" widgets. >+ */ >+ void setWidgetSelection () { >+ progressBar1.setSelection (selectionSpinner.getSelection ()); >+ updateSpinners (); >+ } >+ >+ /** >+ * Update the Spinner widgets to reflect the actual value set >+ * on the "Example" widget. >+ */ >+ void updateSpinners () { >+ minimumSpinner.setSelection (progressBar1.getMinimum ()); >+ selectionSpinner.setSelection (progressBar1.getSelection ()); >+ maximumSpinner.setSelection (progressBar1.getMaximum ()); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/RangeTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/RangeTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/RangeTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/RangeTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,197 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+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; >+ boolean orientationButtons = true; >+ >+ /* Scale widgets added to the "Control" group */ >+ Spinner minimumSpinner, selectionSpinner, maximumSpinner; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ RangeTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Control" widget children. >+ */ >+ void createControlWidgets () { >+ /* 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.NONE); >+ maximumGroup.setLayout (new GridLayout ()); >+ maximumGroup.setText (ControlExample.getResourceString("Maximum")); >+ maximumGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create a Spinner widget */ >+ maximumSpinner = new Spinner (maximumGroup, SWT.BORDER); >+ maximumSpinner.setMaximum (100000); >+ maximumSpinner.setSelection (getDefaultMaximum()); >+ maximumSpinner.setPageIncrement (100); >+ maximumSpinner.setIncrement (1); >+ maximumSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ maximumSpinner.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.NONE); >+ minimumGroup.setLayout (new GridLayout ()); >+ minimumGroup.setText (ControlExample.getResourceString("Minimum")); >+ minimumGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create a Spinner widget */ >+ minimumSpinner = new Spinner (minimumGroup, SWT.BORDER); >+ minimumSpinner.setMaximum (100000); >+ minimumSpinner.setSelection(getDefaultMinimum()); >+ minimumSpinner.setPageIncrement (100); >+ minimumSpinner.setIncrement (1); >+ minimumSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ minimumSpinner.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.NONE); >+ selectionGroup.setLayout(new GridLayout()); >+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, false, false); >+ selectionGroup.setLayoutData(gridData); >+ selectionGroup.setText(ControlExample.getResourceString("Selection")); >+ >+ /* Create a Spinner widget */ >+ selectionSpinner = new Spinner (selectionGroup, SWT.BORDER); >+ selectionSpinner.setMaximum (100000); >+ selectionSpinner.setSelection (getDefaultSelection()); >+ selectionSpinner.setPageIncrement (100); >+ selectionSpinner.setIncrement (1); >+ selectionSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ selectionSpinner.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ setWidgetSelection (); >+ } >+ }); >+ >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup () { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ if (orientationButtons) { >+ horizontalButton = new Button (styleGroup, SWT.RADIO); >+ horizontalButton.setText ("SWT.HORIZONTAL"); >+ verticalButton = new Button (styleGroup, SWT.RADIO); >+ verticalButton.setText ("SWT.VERTICAL"); >+ } >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ if (!instance.startup) { >+ setWidgetMinimum (); >+ setWidgetMaximum (); >+ setWidgetSelection (); >+ } >+ Widget [] widgets = getExampleWidgets (); >+ if (widgets.length != 0) { >+ if (orientationButtons) { >+ horizontalButton.setSelection ((widgets [0].getStyle () & SWT.HORIZONTAL) != 0); >+ verticalButton.setSelection ((widgets [0].getStyle () & SWT.VERTICAL) != 0); >+ } >+ borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0); >+ } >+ } >+ >+ /** >+ * Gets the default maximum of the "Example" widgets. >+ */ >+ abstract int getDefaultMaximum (); >+ >+ /** >+ * Gets the default minimim of the "Example" widgets. >+ */ >+ abstract int getDefaultMinimum (); >+ >+ /** >+ * Gets the default selection of the "Example" widgets. >+ */ >+ abstract int getDefaultSelection (); >+ >+ /** >+ * 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 (); >+} >Index: src/org/eclipse/swt/examples/mirroringTest/SashFormTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/SashFormTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/SashFormTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/SashFormTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,122 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.custom.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+ >+class SashFormTab extends Tab { >+ /* Example widgets and groups that contain them */ >+ Group sashFormGroup; >+ SashForm form; >+ List list1, list2; >+ Text text; >+ >+ /* Style widgets added to the "Style" group */ >+ Button horizontalButton, verticalButton, smoothButton; >+ >+ static String [] ListData0 = {ControlExample.getResourceString("ListData0_0"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData0_1"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData0_2"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData0_3"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData0_4"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData0_5"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData0_6"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData0_7")}; //$NON-NLS-1$ >+ >+ static String [] ListData1 = {ControlExample.getResourceString("ListData1_0"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData1_1"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData1_2"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData1_3"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData1_4"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData1_5"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData1_6"), //$NON-NLS-1$ >+ ControlExample.getResourceString("ListData1_7")}; //$NON-NLS-1$ >+ >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ SashFormTab(ControlExample instance) { >+ super(instance); >+ } >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the sashform widget */ >+ sashFormGroup = new Group (exampleGroup, SWT.NONE); >+ sashFormGroup.setLayout (new GridLayout ()); >+ sashFormGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ sashFormGroup.setText ("SashForm"); >+ } >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL; >+ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL; >+ if (smoothButton.getSelection ()) style |= SWT.SMOOTH; >+ >+ /* Create the example widgets */ >+ form = new SashForm (sashFormGroup, style); >+ list1 = new List (form, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >+ list1.setItems (ListData0); >+ list2 = new List (form, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >+ list2.setItems (ListData1); >+ text = new Text (form, SWT.MULTI | SWT.BORDER); >+ text.setText (ControlExample.getResourceString("Multi_line")); //$NON-NLS-1$ >+ form.setWeights(new int[] {1, 1, 1}); >+ } >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup(); >+ >+ /* Create the extra widgets */ >+ horizontalButton = new Button (styleGroup, SWT.RADIO); >+ horizontalButton.setText ("SWT.HORIZONTAL"); >+ horizontalButton.setSelection(true); >+ verticalButton = new Button (styleGroup, SWT.RADIO); >+ verticalButton.setText ("SWT.VERTICAL"); >+ verticalButton.setSelection(false); >+ smoothButton = new Button (styleGroup, SWT.CHECK); >+ smoothButton.setText ("SWT.SMOOTH"); >+ smoothButton.setSelection(false); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {form}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "SashForm"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ horizontalButton.setSelection ((form.getStyle () & SWT.H_SCROLL) != 0); >+ verticalButton.setSelection ((form.getStyle () & SWT.V_SCROLL) != 0); >+ smoothButton.setSelection ((form.getStyle () & SWT.SMOOTH) != 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/SashTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/SashTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/SashTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/SashTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,241 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.events.*; >+ >+class SashTab extends Tab { >+ /* Example widgets and groups that contain them */ >+ Sash hSash, vSash; >+ Composite sashComp; >+ Group sashGroup; >+ List list1, list2, list3; >+ Text text; >+ Button smoothButton; >+ >+ static String [] ListData0 = {ControlExample.getResourceString("ListData0_0"), >+ ControlExample.getResourceString("ListData0_1"), >+ ControlExample.getResourceString("ListData0_2"), >+ ControlExample.getResourceString("ListData0_3"), >+ ControlExample.getResourceString("ListData0_4"), >+ ControlExample.getResourceString("ListData0_5"), >+ ControlExample.getResourceString("ListData0_6"), >+ ControlExample.getResourceString("ListData0_7"), >+ ControlExample.getResourceString("ListData0_8")}; >+ >+ static String [] ListData1 = {ControlExample.getResourceString("ListData1_0"), >+ ControlExample.getResourceString("ListData1_1"), >+ ControlExample.getResourceString("ListData1_2"), >+ ControlExample.getResourceString("ListData1_3"), >+ ControlExample.getResourceString("ListData1_4"), >+ ControlExample.getResourceString("ListData1_5"), >+ ControlExample.getResourceString("ListData1_6"), >+ ControlExample.getResourceString("ListData1_7"), >+ ControlExample.getResourceString("ListData1_8")}; >+ >+ /* Constants */ >+ static final int SASH_WIDTH = 3; >+ static final int SASH_LIMIT = 20; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ SashTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ exampleGroup.setLayout(new FillLayout()); >+ >+ /* Create a group for the sash widgets */ >+ sashGroup = new Group (exampleGroup, SWT.NONE); >+ FillLayout layout = new FillLayout(); >+ layout.marginHeight = layout.marginWidth = 5; >+ sashGroup.setLayout(layout); >+ sashGroup.setText ("Sash"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ /* >+ * Create the page. This example does not use layouts. >+ */ >+ int style = getDefaultStyle(); >+ sashComp = new Composite(sashGroup, SWT.BORDER | style); >+ >+ /* Create the list and text widgets */ >+ list1 = new List (sashComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >+ list1.setItems (ListData0); >+ list2 = new List (sashComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >+ list2.setItems (ListData1); >+ text = new Text (sashComp, SWT.MULTI | SWT.BORDER); >+ text.setText (ControlExample.getResourceString("Multi_line")); >+ >+ /* Create the sashes */ >+ style = smoothButton.getSelection() ? SWT.SMOOTH : SWT.NONE; >+ vSash = new Sash (sashComp, SWT.VERTICAL | style); >+ hSash = new Sash (sashComp, SWT.HORIZONTAL | style); >+ >+ /* Add the listeners */ >+ hSash.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ Rectangle rect = vSash.getParent().getClientArea(); >+ event.y = Math.min (Math.max (event.y, SASH_LIMIT), rect.height - SASH_LIMIT); >+ 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) { >+ Rectangle rect = vSash.getParent().getClientArea(); >+ event.x = Math.min (Math.max (event.x, SASH_LIMIT), rect.width - SASH_LIMIT); >+ if (event.detail != SWT.DRAG) { >+ vSash.setBounds (event.x, event.y, event.width, event.height); >+ layout (); >+ } >+ } >+ }); >+ sashComp.addControlListener (new ControlAdapter () { >+ public void controlResized (ControlEvent event) { >+ resized (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Size" group. The "Size" group contains >+ * controls that allow the user to change the size of >+ * the example widgets. >+ */ >+ void createSizeGroup () { >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ smoothButton = new Button (styleGroup, SWT.CHECK); >+ smoothButton.setText("SWT.SMOOTH"); >+ } >+ >+ void disposeExampleWidgets () { >+ sashComp.dispose(); >+ sashComp = null; >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {hSash, vSash}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Sash"; >+ } >+ >+ /** >+ * Layout the list and text widgets according to the new >+ * positions of the sashes..events.SelectionEvent >+ */ >+ void layout () { >+ >+ Rectangle clientArea = sashComp.getClientArea (); >+ Rectangle hSashBounds = hSash.getBounds (); >+ Rectangle vSashBounds = vSash.getBounds (); >+ >+ list1.setBounds (0, 0, vSashBounds.x, hSashBounds.y); >+ list2.setBounds (vSashBounds.x + vSashBounds.width, 0, clientArea.width - (vSashBounds.x + vSashBounds.width), hSashBounds.y); >+ text.setBounds (0, hSashBounds.y + hSashBounds.height, clientArea.width, clientArea.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); >+ } >+ /** >+ * Sets the size of the "Example" widgets. >+ */ >+ void setExampleWidgetSize () { >+ sashGroup.layout (true); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ smoothButton.setSelection ((hSash.getStyle () & SWT.SMOOTH) != 0); >+ } >+ >+ /** >+ * Handle the shell resized event. >+ */ >+ void resized () { >+ >+ /* Get the client area for the shell */ >+ Rectangle clientArea = sashComp.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, (clientArea.width - SASH_WIDTH) / 2, (clientArea.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, clientArea.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, clientArea.width, clientArea.height - (list1Bounds.height + SASH_WIDTH)); >+ >+ /* Position the sashes */ >+ vSash.setBounds (list1Bounds.width, 0, SASH_WIDTH, list1Bounds.height); >+ hSash.setBounds (0, list1Bounds.height, clientArea.width, SASH_WIDTH); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ScaleTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ScaleTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ScaleTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ScaleTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,230 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.events.*; >+ >+class ScaleTab extends RangeTab { >+ /* Example widgets and groups that contain them */ >+ Scale scale1; >+ Group scaleGroup; >+ >+ /* Spinner widgets added to the "Control" group */ >+ Spinner incrementSpinner, pageIncrementSpinner; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ScaleTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Control" widget children. >+ */ >+ void createControlWidgets () { >+ super.createControlWidgets (); >+ createIncrementGroup (); >+ createPageIncrementGroup (); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the scale */ >+ scaleGroup = new Group (exampleGroup, SWT.NONE); >+ scaleGroup.setLayout (new GridLayout ()); >+ scaleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ scaleGroup.setText ("Scale"); >+ >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ 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); >+ } >+ >+ /** >+ * 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.NONE); >+ incrementGroup.setLayout (new GridLayout ()); >+ incrementGroup.setText (ControlExample.getResourceString("Increment")); >+ incrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create the Spinner widget */ >+ incrementSpinner = new Spinner (incrementGroup, SWT.BORDER); >+ incrementSpinner.setMaximum (100000); >+ incrementSpinner.setSelection (getDefaultIncrement()); >+ incrementSpinner.setPageIncrement (100); >+ incrementSpinner.setIncrement (1); >+ incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ incrementSpinner.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.NONE); >+ pageIncrementGroup.setLayout (new GridLayout ()); >+ pageIncrementGroup.setText (ControlExample.getResourceString("Page_Increment")); >+ pageIncrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create the Spinner widget */ >+ pageIncrementSpinner = new Spinner (pageIncrementGroup, SWT.BORDER); >+ pageIncrementSpinner.setMaximum (100000); >+ pageIncrementSpinner.setSelection (getDefaultPageIncrement()); >+ pageIncrementSpinner.setPageIncrement (100); >+ pageIncrementSpinner.setIncrement (1); >+ pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ pageIncrementSpinner.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetPageIncrement (); >+ } >+ }); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {scale1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Selection", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Scale"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ if (!instance.startup) { >+ setWidgetIncrement (); >+ setWidgetPageIncrement (); >+ } >+ } >+ >+ /** >+ * Gets the default maximum of the "Example" widgets. >+ */ >+ int getDefaultMaximum () { >+ return scale1.getMaximum(); >+ } >+ >+ /** >+ * Gets the default minimim of the "Example" widgets. >+ */ >+ int getDefaultMinimum () { >+ return scale1.getMinimum(); >+ } >+ >+ /** >+ * Gets the default selection of the "Example" widgets. >+ */ >+ int getDefaultSelection () { >+ return scale1.getSelection(); >+ } >+ >+ /** >+ * Gets the default increment of the "Example" widgets. >+ */ >+ int getDefaultIncrement () { >+ return scale1.getIncrement(); >+ } >+ >+ /** >+ * Gets the default page increment of the "Example" widgets. >+ */ >+ int getDefaultPageIncrement () { >+ return scale1.getPageIncrement(); >+ } >+ >+ /** >+ * Sets the increment of the "Example" widgets. >+ */ >+ void setWidgetIncrement () { >+ scale1.setIncrement (incrementSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the minimim of the "Example" widgets. >+ */ >+ void setWidgetMaximum () { >+ scale1.setMaximum (maximumSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the minimim of the "Example" widgets. >+ */ >+ void setWidgetMinimum () { >+ scale1.setMinimum (minimumSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the page increment of the "Example" widgets. >+ */ >+ void setWidgetPageIncrement () { >+ scale1.setPageIncrement (pageIncrementSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the selection of the "Example" widgets. >+ */ >+ void setWidgetSelection () { >+ scale1.setSelection (selectionSpinner.getSelection ()); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ScrollableTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ScrollableTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ScrollableTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ScrollableTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+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; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ScrollableTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup () { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ singleButton = new Button (styleGroup, SWT.RADIO); >+ singleButton.setText ("SWT.SINGLE"); >+ multiButton = new Button (styleGroup, SWT.RADIO); >+ multiButton.setText ("SWT.MULTI"); >+ horizontalButton = new Button (styleGroup, SWT.CHECK); >+ horizontalButton.setText ("SWT.H_SCROLL"); >+ horizontalButton.setSelection(true); >+ verticalButton = new Button (styleGroup, SWT.CHECK); >+ verticalButton.setText ("SWT.V_SCROLL"); >+ verticalButton.setSelection(true); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ Widget [] widgets = getExampleWidgets (); >+ if (widgets.length != 0){ >+ singleButton.setSelection ((widgets [0].getStyle () & SWT.SINGLE) != 0); >+ multiButton.setSelection ((widgets [0].getStyle () & SWT.MULTI) != 0); >+ horizontalButton.setSelection ((widgets [0].getStyle () & SWT.H_SCROLL) != 0); >+ verticalButton.setSelection ((widgets [0].getStyle () & SWT.V_SCROLL) != 0); >+ borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0); >+ } >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ShellTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ShellTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ShellTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ShellTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,341 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+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" groups, and "Other" group */ >+ Button noParentButton, parentButton; >+ Button noTrimButton, closeButton, titleButton, minButton, maxButton, borderButton, resizeButton, onTopButton, toolButton, sheetButton, shellTrimButton, dialogTrimButton; >+ Button createButton, closeAllButton; >+ Button modelessButton, primaryModalButton, applicationModalButton, systemModalButton; >+ Button imageButton; >+ Group parentStyleGroup, modalStyleGroup; >+ >+ /* Variables used to track the open shells */ >+ int shellCount = 0; >+ Shell [] shells = new Shell [4]; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ShellTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Close all the example shells. >+ */ >+ void closeAllShells() { >+ for (int i = 0; i<shellCount; i++) { >+ if (shells [i] != null & !shells [i].isDisposed ()) { >+ shells [i].dispose(); >+ shells [i] = null; >+ } >+ } >+ 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; >+ if (onTopButton.getSelection()) style |= SWT.ON_TOP; >+ if (toolButton.getSelection()) style |= SWT.TOOL; >+ if (sheetButton.getSelection()) style |= SWT.SHEET; >+ if (modelessButton.getSelection()) style |= SWT.MODELESS; >+ if (primaryModalButton.getSelection()) style |= SWT.PRIMARY_MODAL; >+ if (applicationModalButton.getSelection()) style |= SWT.APPLICATION_MODAL; >+ if (systemModalButton.getSelection()) style |= SWT.SYSTEM_MODAL; >+ >+ /* Create the shell with or without a parent */ >+ if (noParentButton.getSelection ()) { >+ shells [shellCount] = new Shell (style); >+ } else { >+ shells [shellCount] = new Shell (shell, style); >+ } >+ final Shell currentShell = shells [shellCount]; >+ currentShell.setBackgroundMode(SWT.INHERIT_DEFAULT); >+ final Button button = new Button(currentShell, SWT.CHECK); >+ button.setBounds(20, 20, 120, 30); >+ button.setText(ControlExample.getResourceString("FullScreen")); >+ button.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ currentShell.setFullScreen(button.getSelection()); >+ } >+ }); >+ Button close = new Button(currentShell, SWT.PUSH); >+ close.setBounds(160, 20, 120, 30); >+ close.setText(ControlExample.getResourceString("Close")); >+ close.addListener(SWT.Selection, new Listener() { >+ public void handleEvent(Event event) { >+ currentShell.dispose(); >+ } >+ }); >+ >+ /* Set the size, title, and image, and open the shell */ >+ currentShell.setSize (300, 100); >+ currentShell.setText (ControlExample.getResourceString("Title") + shellCount); >+ if (imageButton.getSelection()) currentShell.setImage(instance.images[ControlExample.ciTarget]); >+ if (backgroundImageButton.getSelection()) currentShell.setBackgroundImage(instance.images[ControlExample.ciBackground]); >+ hookListeners (currentShell); >+ currentShell.open (); >+ shellCount++; >+ } >+ >+ /** >+ * Creates the "Control" group. >+ */ >+ void createControlGroup () { >+ /* >+ * Create the "Control" group. This is the group on the >+ * right half of each example tab. It consists of the >+ * style group, the 'other' group and the size group. >+ */ >+ controlGroup = new Group (tabFolderPage, SWT.NONE); >+ controlGroup.setLayout (new GridLayout (2, true)); >+ controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ controlGroup.setText (ControlExample.getResourceString("Parameters")); >+ >+ /* Create a group for the decoration style controls */ >+ styleGroup = new Group (controlGroup, SWT.NONE); >+ styleGroup.setLayout (new GridLayout ()); >+ styleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false, 1, 3)); >+ styleGroup.setText (ControlExample.getResourceString("Decoration_Styles")); >+ >+ /* Create a group for the modal style controls */ >+ modalStyleGroup = new Group (controlGroup, SWT.NONE); >+ modalStyleGroup.setLayout (new GridLayout ()); >+ modalStyleGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); >+ modalStyleGroup.setText (ControlExample.getResourceString("Modal_Styles")); >+ >+ /* Create a group for the 'other' controls */ >+ otherGroup = new Group (controlGroup, SWT.NONE); >+ otherGroup.setLayout (new GridLayout ()); >+ otherGroup.setLayoutData (new GridData(SWT.FILL, SWT.FILL, false, false)); >+ otherGroup.setText (ControlExample.getResourceString("Other")); >+ >+ /* Create a group for the parent style controls */ >+ parentStyleGroup = new Group (controlGroup, SWT.NONE); >+ parentStyleGroup.setLayout (new GridLayout ()); >+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); >+ parentStyleGroup.setLayoutData (gridData); >+ parentStyleGroup.setText (ControlExample.getResourceString("Parent")); >+ } >+ >+ /** >+ * Creates the "Control" widget children. >+ */ >+ void createControlWidgets () { >+ >+ /* Create the parent style buttons */ >+ noParentButton = new Button (parentStyleGroup, SWT.RADIO); >+ noParentButton.setText (ControlExample.getResourceString("No_Parent")); >+ parentButton = new Button (parentStyleGroup, SWT.RADIO); >+ parentButton.setText (ControlExample.getResourceString("Parent")); >+ >+ /* Create the decoration style buttons */ >+ noTrimButton = new Button (styleGroup, SWT.CHECK); >+ noTrimButton.setText ("SWT.NO_TRIM"); >+ closeButton = new Button (styleGroup, SWT.CHECK); >+ closeButton.setText ("SWT.CLOSE"); >+ titleButton = new Button (styleGroup, SWT.CHECK); >+ titleButton.setText ("SWT.TITLE"); >+ minButton = new Button (styleGroup, SWT.CHECK); >+ minButton.setText ("SWT.MIN"); >+ maxButton = new Button (styleGroup, SWT.CHECK); >+ maxButton.setText ("SWT.MAX"); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ resizeButton = new Button (styleGroup, SWT.CHECK); >+ resizeButton.setText ("SWT.RESIZE"); >+ onTopButton = new Button (styleGroup, SWT.CHECK); >+ onTopButton.setText ("SWT.ON_TOP"); >+ toolButton = new Button (styleGroup, SWT.CHECK); >+ toolButton.setText ("SWT.TOOL"); >+ sheetButton = new Button (styleGroup, SWT.CHECK); >+ sheetButton.setText ("SWT.SHEET"); >+ Label separator = new Label(styleGroup, SWT.SEPARATOR | SWT.HORIZONTAL); >+ separator.setLayoutData(new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ shellTrimButton = new Button (styleGroup, SWT.CHECK); >+ shellTrimButton.setText ("SWT.SHELL_TRIM"); >+ dialogTrimButton = new Button (styleGroup, SWT.CHECK); >+ dialogTrimButton.setText ("SWT.DIALOG_TRIM"); >+ >+ /* Create the modal style buttons */ >+ modelessButton = new Button (modalStyleGroup, SWT.RADIO); >+ modelessButton.setText ("SWT.MODELESS"); >+ primaryModalButton = new Button (modalStyleGroup, SWT.RADIO); >+ primaryModalButton.setText ("SWT.PRIMARY_MODAL"); >+ applicationModalButton = new Button (modalStyleGroup, SWT.RADIO); >+ applicationModalButton.setText ("SWT.APPLICATION_MODAL"); >+ systemModalButton = new Button (modalStyleGroup, SWT.RADIO); >+ systemModalButton.setText ("SWT.SYSTEM_MODAL"); >+ >+ /* Create the 'other' buttons */ >+ imageButton = new Button (otherGroup, SWT.CHECK); >+ imageButton.setText (ControlExample.getResourceString("Image")); >+ backgroundImageButton = new Button(otherGroup, SWT.CHECK); >+ backgroundImageButton.setText(ControlExample.getResourceString("BackgroundImage")); >+ >+ /* Create the "create" and "closeAll" buttons */ >+ createButton = new Button (controlGroup, SWT.NONE); >+ GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_END); >+ createButton.setLayoutData (gridData); >+ createButton.setText (ControlExample.getResourceString("Create_Shell")); >+ closeAllButton = new Button (controlGroup, SWT.NONE); >+ gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING); >+ closeAllButton.setText (ControlExample.getResourceString("Close_All_Shells")); >+ closeAllButton.setLayoutData (gridData); >+ >+ /* 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); >+ dialogTrimButton.addSelectionListener (decorationButtonListener); >+ shellTrimButton.addSelectionListener (decorationButtonListener); >+ applicationModalButton.addSelectionListener (decorationButtonListener); >+ systemModalButton.addSelectionListener (decorationButtonListener); >+ >+ /* Set the default state */ >+ noParentButton.setSelection (true); >+ modelessButton.setSelection (true); >+ } >+ >+ /** >+ * Handle a decoration button selection event. >+ * >+ * @param event org.eclipse.swt.events.SelectionEvent >+ */ >+ public void decorationButtonSelected(SelectionEvent event) { >+ Button widget = (Button) event.widget; >+ >+ /* >+ * Make sure that if the modal style is SWT.APPLICATION_MODAL >+ * or SWT.SYSTEM_MODAL the style SWT.CLOSE is also selected. >+ * This is to make sure the user can close the shell. >+ */ >+ if (widget == applicationModalButton || widget == systemModalButton) { >+ if (widget.getSelection()) { >+ closeButton.setSelection (true); >+ noTrimButton.setSelection (false); >+ } >+ return; >+ } >+ if (widget == closeButton) { >+ if (applicationModalButton.getSelection() || systemModalButton.getSelection()) { >+ closeButton.setSelection (true); >+ } >+ } >+ /* >+ * Make sure that if the SWT.NO_TRIM button is selected >+ * then all other decoration buttons are deselected. >+ */ >+ if (widget.getSelection()) { >+ if (widget == noTrimButton) { >+ if (applicationModalButton.getSelection() || systemModalButton.getSelection()) { >+ noTrimButton.setSelection (false); >+ return; >+ } >+ closeButton.setSelection (false); >+ titleButton.setSelection (false); >+ minButton.setSelection (false); >+ maxButton.setSelection (false); >+ borderButton.setSelection (false); >+ resizeButton.setSelection (false); >+ } else { >+ noTrimButton.setSelection (false); >+ } >+ } >+ >+ /* >+ * Make sure that the SWT.DIALOG_TRIM and SWT.SHELL_TRIM buttons >+ * are consistent. >+ */ >+ if (widget == dialogTrimButton || widget == shellTrimButton) { >+ if (widget.getSelection() && widget == dialogTrimButton) { >+ shellTrimButton.setSelection(false); >+ } else { >+ dialogTrimButton.setSelection(false); >+ } >+ //SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE; >+ //DIALOG_TRIM = TITLE | CLOSE | BORDER; >+ closeButton.setSelection (widget.getSelection ()); >+ titleButton.setSelection (widget.getSelection ()); >+ minButton.setSelection (widget == shellTrimButton && widget.getSelection( )); >+ maxButton.setSelection (widget == shellTrimButton && widget.getSelection ()); >+ borderButton.setSelection (widget == dialogTrimButton && widget.getSelection ()); >+ resizeButton.setSelection (widget == shellTrimButton && widget.getSelection ()); >+ } else { >+ boolean title = titleButton.getSelection (); >+ boolean close = closeButton.getSelection (); >+ boolean min = minButton.getSelection (); >+ boolean max = maxButton.getSelection (); >+ boolean border = borderButton.getSelection (); >+ boolean resize = resizeButton.getSelection (); >+ dialogTrimButton.setSelection(title && close && border && !min && !max && !resize); >+ shellTrimButton.setSelection(title && close && min && max && resize && !border); >+ } >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Shell"; >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/SliderTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/SliderTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/SliderTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/SliderTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,273 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+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 */ >+ Slider slider1; >+ Group sliderGroup; >+ >+ /* Spinner widgets added to the "Control" group */ >+ Spinner incrementSpinner, pageIncrementSpinner, thumbSpinner; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ SliderTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * 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.NONE); >+ sliderGroup.setLayout (new GridLayout ()); >+ sliderGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ sliderGroup.setText ("Slider"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL; >+ if (verticalButton.getSelection ()) style |= SWT.VERTICAL; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ >+ /* Create the example widgets */ >+ slider1 = new Slider(sliderGroup, style); >+ } >+ >+ /** >+ * 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.NONE); >+ incrementGroup.setLayout (new GridLayout ()); >+ incrementGroup.setText (ControlExample.getResourceString("Increment")); >+ incrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create the Spinner widget */ >+ incrementSpinner = new Spinner (incrementGroup, SWT.BORDER); >+ incrementSpinner.setMaximum (100000); >+ incrementSpinner.setSelection (getDefaultIncrement()); >+ incrementSpinner.setPageIncrement (100); >+ incrementSpinner.setIncrement (1); >+ incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ incrementSpinner.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.NONE); >+ pageIncrementGroup.setLayout (new GridLayout ()); >+ pageIncrementGroup.setText (ControlExample.getResourceString("Page_Increment")); >+ pageIncrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create the Spinner widget */ >+ pageIncrementSpinner = new Spinner (pageIncrementGroup, SWT.BORDER); >+ pageIncrementSpinner.setMaximum (100000); >+ pageIncrementSpinner.setSelection (getDefaultPageIncrement()); >+ pageIncrementSpinner.setPageIncrement (100); >+ pageIncrementSpinner.setIncrement (1); >+ pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ pageIncrementSpinner.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetPageIncrement (); >+ } >+ }); >+ } >+ >+ /** >+ * 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.NONE); >+ thumbGroup.setLayout (new GridLayout ()); >+ thumbGroup.setText (ControlExample.getResourceString("Thumb")); >+ thumbGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create the Spinner widget */ >+ thumbSpinner = new Spinner (thumbGroup, SWT.BORDER); >+ thumbSpinner.setMaximum (100000); >+ thumbSpinner.setSelection (getDefaultThumb()); >+ thumbSpinner.setPageIncrement (100); >+ thumbSpinner.setIncrement (1); >+ thumbSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ thumbSpinner.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetThumb (); >+ } >+ }); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {slider1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Selection", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Slider"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ if (!instance.startup) { >+ setWidgetIncrement (); >+ setWidgetPageIncrement (); >+ setWidgetThumb (); >+ } >+ } >+ >+ /** >+ * Gets the default maximum of the "Example" widgets. >+ */ >+ int getDefaultMaximum () { >+ return slider1.getMaximum(); >+ } >+ >+ /** >+ * Gets the default minimim of the "Example" widgets. >+ */ >+ int getDefaultMinimum () { >+ return slider1.getMinimum(); >+ } >+ >+ /** >+ * Gets the default selection of the "Example" widgets. >+ */ >+ int getDefaultSelection () { >+ return slider1.getSelection(); >+ } >+ >+ /** >+ * Gets the default increment of the "Example" widgets. >+ */ >+ int getDefaultIncrement () { >+ return slider1.getIncrement(); >+ } >+ >+ /** >+ * Gets the default page increment of the "Example" widgets. >+ */ >+ int getDefaultPageIncrement () { >+ return slider1.getPageIncrement(); >+ } >+ >+ /** >+ * Gets the default thumb of the "Example" widgets. >+ */ >+ int getDefaultThumb () { >+ return slider1.getThumb(); >+ } >+ >+ /** >+ * Sets the increment of the "Example" widgets. >+ */ >+ void setWidgetIncrement () { >+ slider1.setIncrement (incrementSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the minimim of the "Example" widgets. >+ */ >+ void setWidgetMaximum () { >+ slider1.setMaximum (maximumSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the minimim of the "Example" widgets. >+ */ >+ void setWidgetMinimum () { >+ slider1.setMinimum (minimumSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the page increment of the "Example" widgets. >+ */ >+ void setWidgetPageIncrement () { >+ slider1.setPageIncrement (pageIncrementSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the selection of the "Example" widgets. >+ */ >+ void setWidgetSelection () { >+ slider1.setSelection (selectionSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the thumb of the "Example" widgets. >+ */ >+ void setWidgetThumb () { >+ slider1.setThumb (thumbSpinner.getSelection ()); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/SpinnerTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/SpinnerTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/SpinnerTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/SpinnerTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,317 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.*; >+ >+class SpinnerTab extends RangeTab { >+ >+ /* Example widgets and groups that contain them */ >+ Spinner spinner1; >+ Group spinnerGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button readOnlyButton, wrapButton; >+ >+ /* Spinner widgets added to the "Control" group */ >+ Spinner incrementSpinner, pageIncrementSpinner, digitsSpinner; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ SpinnerTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Control" widget children. >+ */ >+ void createControlWidgets () { >+ super.createControlWidgets (); >+ createIncrementGroup (); >+ createPageIncrementGroup (); >+ createDigitsGroup (); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the spinner */ >+ spinnerGroup = new Group (exampleGroup, SWT.NONE); >+ spinnerGroup.setLayout (new GridLayout ()); >+ spinnerGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ spinnerGroup.setText ("Spinner"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (wrapButton.getSelection ()) style |= SWT.WRAP; >+ >+ /* Create the example widgets */ >+ spinner1 = new Spinner (spinnerGroup, style); >+ } >+ >+ /** >+ * 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.NONE); >+ incrementGroup.setLayout (new GridLayout ()); >+ incrementGroup.setText (ControlExample.getResourceString("Increment")); >+ incrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create the Spinner widget */ >+ incrementSpinner = new Spinner (incrementGroup, SWT.BORDER); >+ incrementSpinner.setMaximum (100000); >+ incrementSpinner.setSelection (getDefaultIncrement()); >+ incrementSpinner.setPageIncrement (100); >+ incrementSpinner.setIncrement (1); >+ incrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ incrementSpinner.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.NONE); >+ pageIncrementGroup.setLayout (new GridLayout ()); >+ pageIncrementGroup.setText (ControlExample.getResourceString("Page_Increment")); >+ pageIncrementGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create the Spinner widget */ >+ pageIncrementSpinner = new Spinner (pageIncrementGroup, SWT.BORDER); >+ pageIncrementSpinner.setMaximum (100000); >+ pageIncrementSpinner.setSelection (getDefaultPageIncrement()); >+ pageIncrementSpinner.setPageIncrement (100); >+ pageIncrementSpinner.setIncrement (1); >+ pageIncrementSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ pageIncrementSpinner.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetPageIncrement (); >+ } >+ }); >+ } >+ >+ /** >+ * Create a group of widgets to control the digits >+ * attribute of the example widget. >+ */ >+ void createDigitsGroup() { >+ >+ /* Create the group */ >+ Group digitsGroup = new Group (controlGroup, SWT.NONE); >+ digitsGroup.setLayout (new GridLayout ()); >+ digitsGroup.setText (ControlExample.getResourceString("Digits")); >+ digitsGroup.setLayoutData (new GridData (GridData.FILL_HORIZONTAL)); >+ >+ /* Create the Spinner widget */ >+ digitsSpinner = new Spinner (digitsGroup, SWT.BORDER); >+ digitsSpinner.setMaximum (100000); >+ digitsSpinner.setSelection (getDefaultDigits()); >+ digitsSpinner.setPageIncrement (100); >+ digitsSpinner.setIncrement (1); >+ digitsSpinner.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ >+ /* Add the listeners */ >+ digitsSpinner.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent e) { >+ setWidgetDigits (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the tab folder page. >+ * >+ * @param tabFolder org.eclipse.swt.widgets.TabFolder >+ * @return the new page for the tab folder >+ */ >+ Composite createTabFolderPage (TabFolder tabFolder) { >+ super.createTabFolderPage (tabFolder); >+ >+ /* >+ * Add a resize listener to the tabFolderPage so that >+ * if the user types into the example widget to change >+ * its preferred size, and then resizes the shell, we >+ * recalculate the preferred size correctly. >+ */ >+ tabFolderPage.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) { >+ setExampleWidgetSize (); >+ } >+ }); >+ >+ return tabFolderPage; >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup () { >+ orientationButtons = false; >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ readOnlyButton = new Button (styleGroup, SWT.CHECK); >+ readOnlyButton.setText ("SWT.READ_ONLY"); >+ wrapButton = new Button (styleGroup, SWT.CHECK); >+ wrapButton.setText ("SWT.WRAP"); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {spinner1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Selection", "TextLimit", "ToolTipText"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Spinner"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ readOnlyButton.setSelection ((spinner1.getStyle () & SWT.READ_ONLY) != 0); >+ wrapButton.setSelection ((spinner1.getStyle () & SWT.WRAP) != 0); >+ if (!instance.startup) { >+ setWidgetIncrement (); >+ setWidgetPageIncrement (); >+ setWidgetDigits (); >+ } >+ } >+ >+ /** >+ * Gets the default maximum of the "Example" widgets. >+ */ >+ int getDefaultMaximum () { >+ return spinner1.getMaximum(); >+ } >+ >+ /** >+ * Gets the default minimim of the "Example" widgets. >+ */ >+ int getDefaultMinimum () { >+ return spinner1.getMinimum(); >+ } >+ >+ /** >+ * Gets the default selection of the "Example" widgets. >+ */ >+ int getDefaultSelection () { >+ return spinner1.getSelection(); >+ } >+ >+ /** >+ * Gets the default increment of the "Example" widgets. >+ */ >+ int getDefaultIncrement () { >+ return spinner1.getIncrement(); >+ } >+ >+ /** >+ * Gets the default page increment of the "Example" widgets. >+ */ >+ int getDefaultPageIncrement () { >+ return spinner1.getPageIncrement(); >+ } >+ >+ /** >+ * Gets the default digits of the "Example" widgets. >+ */ >+ int getDefaultDigits () { >+ return spinner1.getDigits(); >+ } >+ >+ /** >+ * Sets the increment of the "Example" widgets. >+ */ >+ void setWidgetIncrement () { >+ spinner1.setIncrement (incrementSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the minimim of the "Example" widgets. >+ */ >+ void setWidgetMaximum () { >+ spinner1.setMaximum (maximumSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the minimim of the "Example" widgets. >+ */ >+ void setWidgetMinimum () { >+ spinner1.setMinimum (minimumSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the page increment of the "Example" widgets. >+ */ >+ void setWidgetPageIncrement () { >+ spinner1.setPageIncrement (pageIncrementSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the digits of the "Example" widgets. >+ */ >+ void setWidgetDigits () { >+ spinner1.setDigits (digitsSpinner.getSelection ()); >+ } >+ >+ /** >+ * Sets the selection of the "Example" widgets. >+ */ >+ void setWidgetSelection () { >+ spinner1.setSelection (selectionSpinner.getSelection ()); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/StyledTextTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/StyledTextTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/StyledTextTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/StyledTextTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,413 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import java.io.*; >+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 StyledTextTab extends ScrollableTab { >+ /* Example widgets and groups that contain them */ >+ StyledText styledText; >+ Group styledTextGroup, styledTextStyleGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button wrapButton, readOnlyButton, fullSelectionButton; >+ >+ /* Buttons for adding StyleRanges to StyledText */ >+ Button boldButton, italicButton, redButton, yellowButton, underlineButton, strikeoutButton; >+ Image boldImage, italicImage, redImage, yellowImage, underlineImage, strikeoutImage; >+ >+ /* Variables for saving state. */ >+ String text; >+ StyleRange[] styleRanges; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ StyledTextTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates a bitmap image. >+ */ >+ Image createBitmapImage (Display display, String name) { >+ InputStream sourceStream = ControlExample.class.getResourceAsStream (name + ".bmp"); >+ InputStream maskStream = ControlExample.class.getResourceAsStream (name + "_mask.bmp"); >+ ImageData source = new ImageData (sourceStream); >+ ImageData mask = new ImageData (maskStream); >+ Image result = new Image (display, source, mask); >+ try { >+ sourceStream.close (); >+ maskStream.close (); >+ } catch (IOException e) { >+ e.printStackTrace (); >+ } >+ return result; >+ } >+ >+ /** >+ * Creates the "Control" widget children. >+ */ >+ void createControlWidgets () { >+ super.createControlWidgets (); >+ >+ /* Add a group for modifying the StyledText widget */ >+ createStyledTextStyleGroup (); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the styled text widget */ >+ styledTextGroup = new Group (exampleGroup, SWT.NONE); >+ styledTextGroup.setLayout (new GridLayout ()); >+ styledTextGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ styledTextGroup.setText ("StyledText"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ 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 (wrapButton.getSelection ()) style |= SWT.WRAP; >+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (fullSelectionButton.getSelection ()) style |= SWT.FULL_SELECTION; >+ >+ /* Create the example widgets */ >+ styledText = new StyledText (styledTextGroup, style); >+ styledText.setText (ControlExample.getResourceString("Example_string")); >+ styledText.append ("\n"); >+ styledText.append (ControlExample.getResourceString("One_Two_Three")); >+ >+ if (text != null) { >+ styledText.setText(text); >+ text = null; >+ } >+ if (styleRanges != null) { >+ styledText.setStyleRanges(styleRanges); >+ styleRanges = null; >+ } >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup(); >+ >+ /* Create the extra widgets */ >+ wrapButton = new Button (styleGroup, SWT.CHECK); >+ wrapButton.setText ("SWT.WRAP"); >+ readOnlyButton = new Button (styleGroup, SWT.CHECK); >+ readOnlyButton.setText ("SWT.READ_ONLY"); >+ fullSelectionButton = new Button (styleGroup, SWT.CHECK); >+ fullSelectionButton.setText ("SWT.FULL_SELECTION"); >+ } >+ >+ /** >+ * Creates the "StyledText Style" group. >+ */ >+ void createStyledTextStyleGroup () { >+ styledTextStyleGroup = new Group (controlGroup, SWT.NONE); >+ styledTextStyleGroup.setText (ControlExample.getResourceString ("StyledText_Styles")); >+ styledTextStyleGroup.setLayout (new GridLayout(6, false)); >+ GridData data = new GridData (GridData.HORIZONTAL_ALIGN_FILL); >+ data.horizontalSpan = 2; >+ styledTextStyleGroup.setLayoutData (data); >+ >+ /* Get images */ >+ boldImage = createBitmapImage (display, "bold"); >+ italicImage = createBitmapImage (display, "italic"); >+ redImage = createBitmapImage (display, "red"); >+ yellowImage = createBitmapImage (display, "yellow"); >+ underlineImage = createBitmapImage (display, "underline"); >+ strikeoutImage = createBitmapImage (display, "strikeout"); >+ >+ /* Create controls to modify the StyledText */ >+ Label label = new Label (styledTextStyleGroup, SWT.NONE); >+ label.setText (ControlExample.getResourceString ("StyledText_Style_Instructions")); >+ label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 6, 1)); >+ label = new Label (styledTextStyleGroup, SWT.NONE); >+ label.setText (ControlExample.getResourceString ("Bold")); >+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >+ boldButton = new Button (styledTextStyleGroup, SWT.PUSH); >+ boldButton.setImage (boldImage); >+ label = new Label (styledTextStyleGroup, SWT.NONE); >+ label.setText (ControlExample.getResourceString ("Underline")); >+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >+ underlineButton = new Button (styledTextStyleGroup, SWT.PUSH); >+ underlineButton.setImage (underlineImage); >+ label = new Label (styledTextStyleGroup, SWT.NONE); >+ label.setText (ControlExample.getResourceString ("Foreground_Style")); >+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >+ redButton = new Button (styledTextStyleGroup, SWT.PUSH); >+ redButton.setImage (redImage); >+ label = new Label (styledTextStyleGroup, SWT.NONE); >+ label.setText (ControlExample.getResourceString ("Italic")); >+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >+ italicButton = new Button (styledTextStyleGroup, SWT.PUSH); >+ italicButton.setImage (italicImage); >+ label = new Label (styledTextStyleGroup, SWT.NONE); >+ label.setText (ControlExample.getResourceString ("Strikeout")); >+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >+ strikeoutButton = new Button (styledTextStyleGroup, SWT.PUSH); >+ strikeoutButton.setImage (strikeoutImage); >+ label = new Label (styledTextStyleGroup, SWT.NONE); >+ label.setText (ControlExample.getResourceString ("Background_Style")); >+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false)); >+ yellowButton = new Button (styledTextStyleGroup, SWT.PUSH); >+ yellowButton.setImage (yellowImage); >+ SelectionListener styleListener = new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent e) { >+ Point sel = styledText.getSelectionRange(); >+ if ((sel == null) || (sel.y == 0)) return; >+ StyleRange style; >+ for (int i = sel.x; i<sel.x+sel.y; i++) { >+ StyleRange range = styledText.getStyleRangeAtOffset(i); >+ if (range != null) { >+ style = (StyleRange)range.clone(); >+ style.start = i; >+ style.length = 1; >+ } else { >+ style = new StyleRange(i, 1, null, null, SWT.NORMAL); >+ } >+ if (e.widget == boldButton) { >+ style.fontStyle ^= SWT.BOLD; >+ } else if (e.widget == italicButton) { >+ style.fontStyle ^= SWT.ITALIC; >+ } else if (e.widget == underlineButton) { >+ style.underline = !style.underline; >+ } else if (e.widget == strikeoutButton) { >+ style.strikeout = !style.strikeout; >+ } >+ styledText.setStyleRange(style); >+ } >+ styledText.setSelectionRange(sel.x + sel.y, 0); >+ } >+ }; >+ SelectionListener colorListener = new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent e) { >+ Point sel = styledText.getSelectionRange(); >+ if ((sel == null) || (sel.y == 0)) return; >+ Color fg = null, bg = null; >+ if (e.widget == redButton) { >+ fg = display.getSystemColor (SWT.COLOR_RED); >+ } else if (e.widget == yellowButton) { >+ bg = display.getSystemColor (SWT.COLOR_YELLOW); >+ } >+ StyleRange style; >+ for (int i = sel.x; i<sel.x+sel.y; i++) { >+ StyleRange range = styledText.getStyleRangeAtOffset(i); >+ if (range != null) { >+ style = (StyleRange)range.clone(); >+ style.start = i; >+ style.length = 1; >+ style.foreground = style.foreground != null ? null : fg; >+ style.background = style.background != null ? null : bg; >+ } else { >+ style = new StyleRange (i, 1, fg, bg, SWT.NORMAL); >+ } >+ styledText.setStyleRange(style); >+ } >+ styledText.setSelectionRange(sel.x + sel.y, 0); >+ } >+ }; >+ boldButton.addSelectionListener(styleListener); >+ italicButton.addSelectionListener(styleListener); >+ underlineButton.addSelectionListener(styleListener); >+ strikeoutButton.addSelectionListener(styleListener); >+ redButton.addSelectionListener(colorListener); >+ yellowButton.addSelectionListener(colorListener); >+ yellowButton.addDisposeListener(new DisposeListener () { >+ public void widgetDisposed (DisposeEvent e) { >+ boldImage.dispose(); >+ italicImage.dispose(); >+ redImage.dispose(); >+ yellowImage.dispose(); >+ underlineImage.dispose(); >+ strikeoutImage.dispose(); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the tab folder page. >+ * >+ * @param tabFolder org.eclipse.swt.widgets.TabFolder >+ * @return the new page for the tab folder >+ */ >+ Composite createTabFolderPage (TabFolder tabFolder) { >+ super.createTabFolderPage (tabFolder); >+ >+ /* >+ * Add a resize listener to the tabFolderPage so that >+ * if the user types into the example widget to change >+ * its preferred size, and then resizes the shell, we >+ * recalculate the preferred size correctly. >+ */ >+ tabFolderPage.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) { >+ setExampleWidgetSize (); >+ } >+ }); >+ >+ return tabFolderPage; >+ } >+ >+ /** >+ * Disposes the "Example" widgets. >+ */ >+ void disposeExampleWidgets () { >+ /* store the state of the styledText if applicable */ >+ if (styledText != null) { >+ styleRanges = styledText.getStyleRanges(); >+ text = styledText.getText(); >+ } >+ super.disposeExampleWidgets(); >+ } >+ >+ /** >+ * Gets the list of custom event names. >+ * >+ * @return an array containing custom event names >+ */ >+ String [] getCustomEventNames () { >+ return new String [] { >+ "ExtendedModifyListener", "BidiSegmentListener", "LineBackgroundListener", >+ "LineStyleListener", "PaintObjectListener", "TextChangeListener", >+ "VerifyKeyListener", "WordMovementListener"}; >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {styledText}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Alignment", "BlockSelection", "BottomMargin", "CaretOffset", "DoubleClickEnabled", "Editable", "HorizontalIndex", "HorizontalPixel", "Indent", "Justify", "LeftMargin", "LineSpacing", "Orientation", "RightMargin", "Selection", "Tabs", "Text", "TextLimit", "ToolTipText", "TopIndex", "TopMargin", "TopPixel", "WordWrap"}; >+ } >+ >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "StyledText"; >+ } >+ >+ /** >+ * Hooks the custom listener specified by eventName. >+ */ >+ void hookCustomListener (final String eventName) { >+ if (eventName == "ExtendedModifyListener") { >+ styledText.addExtendedModifyListener (new ExtendedModifyListener() { >+ public void modifyText(ExtendedModifyEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "BidiSegmentListener") { >+ styledText.addBidiSegmentListener (new BidiSegmentListener() { >+ public void lineGetSegments(BidiSegmentEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "LineBackgroundListener") { >+ styledText.addLineBackgroundListener (new LineBackgroundListener() { >+ public void lineGetBackground(LineBackgroundEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "LineStyleListener") { >+ styledText.addLineStyleListener (new LineStyleListener() { >+ public void lineGetStyle(LineStyleEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "PaintObjectListener") { >+ styledText.addPaintObjectListener (new PaintObjectListener() { >+ public void paintObject(PaintObjectEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "TextChangeListener") { >+ styledText.getContent().addTextChangeListener (new TextChangeListener() { >+ public void textChanged(TextChangedEvent event) { >+ log (eventName + ".textChanged", event); >+ } >+ public void textChanging(TextChangingEvent event) { >+ log (eventName + ".textChanging", event); >+ } >+ public void textSet(TextChangedEvent event) { >+ log (eventName + ".textSet", event); >+ } >+ }); >+ } >+ if (eventName == "VerifyKeyListener") { >+ styledText.addVerifyKeyListener (new VerifyKeyListener() { >+ public void verifyKey(VerifyEvent event) { >+ log (eventName, event); >+ } >+ }); >+ } >+ if (eventName == "WordMovementListener") { >+ styledText.addWordMovementListener (new MovementListener() { >+ public void getNextOffset(MovementEvent event) { >+ log (eventName + ".getNextOffset", event); >+ } >+ public void getPreviousOffset(MovementEvent event) { >+ log (eventName + ".getPreviousOffset", event); >+ } >+ }); >+ } >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ wrapButton.setSelection ((styledText.getStyle () & SWT.WRAP) != 0); >+ readOnlyButton.setSelection ((styledText.getStyle () & SWT.READ_ONLY) != 0); >+ fullSelectionButton.setSelection ((styledText.getStyle () & SWT.FULL_SELECTION) != 0); >+ horizontalButton.setEnabled ((styledText.getStyle () & SWT.MULTI) != 0); >+ verticalButton.setEnabled ((styledText.getStyle () & SWT.MULTI) != 0); >+ wrapButton.setEnabled ((styledText.getStyle () & SWT.MULTI) != 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/Tab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/Tab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/Tab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/Tab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1831 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+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>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", "Other" and "Size" group. Subclasses >+ * can override these defaults to augment a group or stop >+ * a group from being created. >+ */ >+abstract class Tab { >+ Shell shell; >+ Display display; >+ >+ /* Common control buttons */ >+ Button borderButton, enabledButton, visibleButton, backgroundImageButton, popupMenuButton; >+ Button preferredButton, tooSmallButton, smallButton, largeButton, fillHButton, fillVButton; >+ >+ /* Common groups and composites */ >+ Composite tabFolderPage; >+ Group exampleGroup, controlGroup, listenersGroup, otherGroup, sizeGroup, styleGroup, colorGroup, backgroundModeGroup; >+ >+ /* Controlling instance */ >+ final ControlExample instance; >+ >+ /* 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; >+ >+ /* Right-to-left support */ >+ static final boolean RTL_SUPPORT_ENABLE = "win32".equals(SWT.getPlatform()) || "gtk".equals(SWT.getPlatform()); >+ Group orientationGroup; >+ Button rtlButtonRecreate, rtlButtonSet, ltrButtonRecreate, ltrButtonSet, defaultOrietationButton; >+ >+ /* Controls and resources for the "Colors & Fonts" group */ >+ static final int IMAGE_SIZE = 12; >+ static final int FOREGROUND_COLOR = 0; >+ static final int BACKGROUND_COLOR = 1; >+ static final int FONT = 2; >+ Table colorAndFontTable; >+ ColorDialog colorDialog; >+ FontDialog fontDialog; >+ Color foregroundColor, backgroundColor; >+ Font font; >+ >+ /* Controls and resources for the "Background Mode" group */ >+ Combo backgroundModeCombo; >+ Button backgroundModeImageButton, backgroundModeColorButton; >+ >+ boolean samplePopup = false; >+ >+ /* Set/Get API controls */ >+ Combo nameCombo; >+ Label returnTypeLabel; >+ Button getButton, setButton; >+ Text setText, getText; >+ Shell setGetDialog; >+ >+ /* Event logging variables and controls */ >+ Text eventConsole; >+ boolean logging = false; >+ boolean [] eventsFilter; >+ int setFieldsMask = 0; >+ Event setFieldsEvent = new Event (); >+ boolean ignore = false; >+ >+ /* Event logging constants */ >+ static final int DOIT = 0x0100; >+ static final int DETAIL = 0x0200; >+ static final int TEXT = 0x0400; >+ static final int X = 0x0800; >+ static final int Y = 0x1000; >+ static final int WIDTH = 0x2000; >+ static final int HEIGHT = 0x4000; >+ >+ static final int DETAIL_IME = 0; >+ static final int DETAIL_ERASE_ITEM = 1; >+ static final int DETAIL_TRAVERSE = 2; >+ >+ static class EventInfo { >+ String name; >+ int type; >+ int settableFields; >+ int setFields; >+ Event event; >+ EventInfo (String name, int type, int settableFields, int setFields, Event event) { >+ this.name = name; >+ this.type = type; >+ this.settableFields = settableFields; >+ this.setFields = setFields; >+ this.event = event; >+ } >+ } >+ >+ final EventInfo [] EVENT_INFO = { >+ new EventInfo ("Activate", SWT.Activate, 0, 0, new Event()), >+ new EventInfo ("Arm", SWT.Arm, 0, 0, new Event()), >+ new EventInfo ("Close", SWT.Close, DOIT, 0, new Event()), >+ new EventInfo ("Collapse", SWT.Collapse, 0, 0, new Event()), >+ new EventInfo ("Deactivate", SWT.Deactivate, 0, 0, new Event()), >+ new EventInfo ("DefaultSelection", SWT.DefaultSelection, 0, 0, new Event()), >+ new EventInfo ("Deiconify", SWT.Deiconify, 0, 0, new Event()), >+ new EventInfo ("Dispose", SWT.Dispose, 0, 0, new Event()), >+ new EventInfo ("DragDetect", SWT.DragDetect, 0, 0, new Event()), >+ new EventInfo ("EraseItem", SWT.EraseItem, DETAIL | DETAIL_ERASE_ITEM, 0, new Event()), >+ new EventInfo ("Expand", SWT.Expand, 0, 0, new Event()), >+ new EventInfo ("FocusIn", SWT.FocusIn, 0, 0, new Event()), >+ new EventInfo ("FocusOut", SWT.FocusOut, 0, 0, new Event()), >+ new EventInfo ("HardKeyDown", SWT.HardKeyDown, 0, 0, new Event()), >+ new EventInfo ("HardKeyUp", SWT.HardKeyUp, 0, 0, new Event()), >+ new EventInfo ("Help", SWT.Help, 0, 0, new Event()), >+ new EventInfo ("Hide", SWT.Hide, 0, 0, new Event()), >+ new EventInfo ("Iconify", SWT.Iconify, 0, 0, new Event()), >+ new EventInfo ("KeyDown", SWT.KeyDown, DOIT, 0, new Event()), >+ new EventInfo ("KeyUp", SWT.KeyUp, DOIT, 0, new Event()), >+ new EventInfo ("MeasureItem", SWT.MeasureItem, 0, 0, new Event()), >+ new EventInfo ("MenuDetect", SWT.MenuDetect, X | Y | DOIT, 0, new Event()), >+ new EventInfo ("Modify", SWT.Modify, 0, 0, new Event()), >+ new EventInfo ("MouseDoubleClick", SWT.MouseDoubleClick, 0, 0, new Event()), >+ new EventInfo ("MouseDown", SWT.MouseDown, 0, 0, new Event()), >+ new EventInfo ("MouseEnter", SWT.MouseEnter, 0, 0, new Event()), >+ new EventInfo ("MouseExit", SWT.MouseExit, 0, 0, new Event()), >+ new EventInfo ("MouseHover", SWT.MouseHover, 0, 0, new Event()), >+ new EventInfo ("MouseMove", SWT.MouseMove, 0, 0, new Event()), >+ new EventInfo ("MouseUp", SWT.MouseUp, 0, 0, new Event()), >+ new EventInfo ("MouseWheel", SWT.MouseWheel, 0, 0, new Event()), >+ new EventInfo ("Move", SWT.Move, 0, 0, new Event()), >+ new EventInfo ("Paint", SWT.Paint, 0, 0, new Event()), >+ new EventInfo ("PaintItem", SWT.PaintItem, 0, 0, new Event()), >+ new EventInfo ("Resize", SWT.Resize, 0, 0, new Event()), >+ new EventInfo ("Selection", SWT.Selection, X | Y | DOIT, 0, new Event()), // sash >+ new EventInfo ("SetData", SWT.SetData, 0, 0, new Event()), >+// new EventInfo ("Settings", SWT.Settings, 0, 0, new Event()), // note: this event only goes to Display >+ new EventInfo ("Show", SWT.Show, 0, 0, new Event()), >+ new EventInfo ("Traverse", SWT.Traverse, DETAIL | DETAIL_TRAVERSE | DOIT, 0, new Event()), >+ new EventInfo ("Verify", SWT.Verify, TEXT | DOIT, 0, new Event()), >+ new EventInfo ("ImeComposition", SWT.ImeComposition, DETAIL | DETAIL_IME | TEXT | DOIT, 0, new Event()), >+ }; >+ >+ static final String [][] DETAIL_CONSTANTS = { >+ { // DETAIL_IME = 0 >+ "SWT.COMPOSITION_CHANGED", >+ "SWT.COMPOSITION_OFFSET", >+ "SWT.COMPOSITION_SELECTION", >+ }, >+ { // DETAIL_ERASE_ITEM = 1 >+ "SWT.SELECTED", >+ "SWT.FOCUSED", >+ "SWT.BACKGROUND", >+ "SWT.FOREGROUND", >+ "SWT.HOT", >+ }, >+ { // DETAIL_TRAVERSE = 2 >+ "SWT.TRAVERSE_NONE", >+ "SWT.TRAVERSE_ESCAPE", >+ "SWT.TRAVERSE_RETURN", >+ "SWT.TRAVERSE_TAB_PREVIOUS", >+ "SWT.TRAVERSE_TAB_NEXT", >+ "SWT.TRAVERSE_ARROW_PREVIOUS", >+ "SWT.TRAVERSE_ARROW_NEXT", >+ "SWT.TRAVERSE_MNEMONIC", >+ "SWT.TRAVERSE_PAGE_PREVIOUS", >+ "SWT.TRAVERSE_PAGE_NEXT", >+ }, >+ }; >+ >+ static final Object [] DETAIL_VALUES = { >+ "SWT.COMPOSITION_CHANGED", new Integer(SWT.COMPOSITION_CHANGED), >+ "SWT.COMPOSITION_OFFSET", new Integer(SWT.COMPOSITION_OFFSET), >+ "SWT.COMPOSITION_SELECTION", new Integer(SWT.COMPOSITION_SELECTION), >+ "SWT.SELECTED", new Integer(SWT.SELECTED), >+ "SWT.FOCUSED", new Integer(SWT.FOCUSED), >+ "SWT.BACKGROUND", new Integer(SWT.BACKGROUND), >+ "SWT.FOREGROUND", new Integer(SWT.FOREGROUND), >+ "SWT.HOT", new Integer(SWT.HOT), >+ "SWT.TRAVERSE_NONE", new Integer(SWT.TRAVERSE_NONE), >+ "SWT.TRAVERSE_ESCAPE", new Integer(SWT.TRAVERSE_ESCAPE), >+ "SWT.TRAVERSE_RETURN", new Integer(SWT.TRAVERSE_RETURN), >+ "SWT.TRAVERSE_TAB_PREVIOUS", new Integer(SWT.TRAVERSE_TAB_PREVIOUS), >+ "SWT.TRAVERSE_TAB_NEXT", new Integer(SWT.TRAVERSE_TAB_NEXT), >+ "SWT.TRAVERSE_ARROW_PREVIOUS", new Integer(SWT.TRAVERSE_ARROW_PREVIOUS), >+ "SWT.TRAVERSE_ARROW_NEXT", new Integer(SWT.TRAVERSE_ARROW_NEXT), >+ "SWT.TRAVERSE_MNEMONIC", new Integer(SWT.TRAVERSE_MNEMONIC), >+ "SWT.TRAVERSE_PAGE_PREVIOUS", new Integer(SWT.TRAVERSE_PAGE_PREVIOUS), >+ "SWT.TRAVERSE_PAGE_NEXT", new Integer(SWT.TRAVERSE_PAGE_NEXT), >+ }; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ Tab(ControlExample instance) { >+ this.instance = instance; >+ } >+ >+ /** >+ * 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 >+ * right half of each example tab. It consists of the >+ * "Style" group, the "Other" group and the "Size" group. >+ */ >+ controlGroup = new Group (tabFolderPage, SWT.NONE); >+ controlGroup.setLayout (new GridLayout (2, true)); >+ controlGroup.setLayoutData (new GridData(SWT.FILL, SWT.FILL, false, false)); >+ controlGroup.setText (ControlExample.getResourceString("Parameters")); >+ >+ /* Create individual groups inside the "Control" group */ >+ createStyleGroup (); >+ createOtherGroup (); >+ createSetGetGroup(); >+ createSizeGroup (); >+ createColorAndFontGroup (); >+ if (rtlSupport()) { >+ createOrientationGroup (); >+ } >+// createBackgroundModeGroup (); >+ >+ /* >+ * 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 current 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); >+ } else { >+ if (children [i] instanceof Composite) { >+ /* Look down one more level of children in the style group. */ >+ Composite composite = (Composite) children [i]; >+ Control [] grandchildren = composite.getChildren (); >+ for (int j=0; j<grandchildren.length; j++) { >+ if (grandchildren [j] instanceof Button) { >+ Button button = (Button) grandchildren [j]; >+ button.addSelectionListener (selectionListener); >+ } >+ } >+ } >+ } >+ } >+ if (rtlSupport()) { >+ rtlButtonRecreate.addSelectionListener (selectionListener); >+ ltrButtonRecreate.addSelectionListener (selectionListener); >+ defaultOrietationButton.addSelectionListener (selectionListener); >+ >+ SelectionListener bidiListener = new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ Control [] controls = getExampleControls (); >+ int flag = event.widget == rtlButtonSet ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT; >+ for (int i=0; i<controls.length; i++) { >+ controls [i].setOrientation(flag); >+ //controls [i].setTextDirectionRTL(); >+ } >+ } >+ }; >+ rtlButtonSet.addSelectionListener (bidiListener); >+ ltrButtonSet.addSelectionListener (bidiListener); >+ } >+ } >+ >+ /** >+ * Append the Set/Get API controls to the "Other" group. >+ */ >+ void createSetGetGroup() { >+ /* >+ * Create the button to access set/get API functionality. >+ */ >+ final String [] methodNames = getMethodNames (); >+ if (methodNames != null) { >+ final Button setGetButton = new Button (otherGroup, SWT.PUSH); >+ setGetButton.setText (ControlExample.getResourceString ("Set_Get")); >+ setGetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >+ setGetButton.addSelectionListener (new SelectionAdapter() { >+ public void widgetSelected (SelectionEvent e) { >+ if (getExampleWidgets().length > 0) { >+ if (setGetDialog == null) { >+ setGetDialog = createSetGetDialog(methodNames); >+ } >+ Point pt = setGetButton.getLocation(); >+ pt = display.map(setGetButton.getParent(), null, pt); >+ setGetDialog.setLocation(pt.x, pt.y); >+ setGetDialog.open(); >+ } >+ } >+ }); >+ } >+ } >+ >+ /** >+ * Creates the "Control" widget children. >+ * Subclasses override this method to augment >+ * the standard controls created in the "Style", >+ * "Other" and "Size" groups. >+ */ >+ void createControlWidgets () { >+ } >+ >+ /** >+ * Creates the "Colors and Fonts" group. This is typically >+ * a child of the "Control" group. Subclasses override >+ * this method to customize color and font settings. >+ */ >+ void createColorAndFontGroup () { >+ /* Create the group. */ >+ colorGroup = new Group(controlGroup, SWT.NONE); >+ colorGroup.setLayout (new GridLayout (2, true)); >+ colorGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >+ colorGroup.setText (ControlExample.getResourceString ("Colors")); >+ colorAndFontTable = new Table(colorGroup, SWT.BORDER | SWT.V_SCROLL); >+ colorAndFontTable.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1)); >+ TableItem item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Foreground_Color")); >+ colorAndFontTable.setSelection(0); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Background_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Font")); >+ Button changeButton = new Button (colorGroup, SWT.PUSH); >+ changeButton.setText(ControlExample.getResourceString("Change")); >+ changeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >+ Button defaultsButton = new Button (colorGroup, SWT.PUSH); >+ defaultsButton.setText(ControlExample.getResourceString("Defaults")); >+ defaultsButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >+ >+ /* Add listeners to set/reset colors and fonts. */ >+ colorDialog = new ColorDialog (shell); >+ fontDialog = new FontDialog (shell); >+ colorAndFontTable.addSelectionListener(new SelectionAdapter() { >+ public void widgetDefaultSelected(SelectionEvent event) { >+ changeFontOrColor (colorAndFontTable.getSelectionIndex()); >+ } >+ }); >+ changeButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ changeFontOrColor (colorAndFontTable.getSelectionIndex()); >+ } >+ }); >+ defaultsButton.addSelectionListener(new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent e) { >+ resetColorsAndFonts (); >+ } >+ }); >+ shell.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent event) { >+ if (foregroundColor != null) foregroundColor.dispose(); >+ if (backgroundColor != null) backgroundColor.dispose(); >+ if (font != null) font.dispose(); >+ foregroundColor = null; >+ backgroundColor = null; >+ font = null; >+ if (colorAndFontTable != null && !colorAndFontTable.isDisposed()) { >+ TableItem [] items = colorAndFontTable.getItems(); >+ for (int i = 0; i < items.length; i++) { >+ Image image = items[i].getImage(); >+ if (image != null) image.dispose(); >+ } >+ } >+ } >+ }); >+ } >+ >+ void changeFontOrColor(int index) { >+ switch (index) { >+ case FOREGROUND_COLOR: { >+ Color oldColor = foregroundColor; >+ if (oldColor == null) { >+ Control [] controls = getExampleControls (); >+ if (controls.length > 0) oldColor = controls [0].getForeground (); >+ } >+ if (oldColor != null) colorDialog.setRGB(oldColor.getRGB()); // seed dialog with current color >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = foregroundColor; // save old foreground color to dispose when done >+ foregroundColor = new Color (display, rgb); >+ setExampleWidgetForeground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case BACKGROUND_COLOR: { >+ Color oldColor = backgroundColor; >+ if (oldColor == null) { >+ Control [] controls = getExampleControls (); >+ if (controls.length > 0) oldColor = controls [0].getBackground (); // seed dialog with current color >+ } >+ if (oldColor != null) colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = backgroundColor; // save old background color to dispose when done >+ backgroundColor = new Color (display, rgb); >+ setExampleWidgetBackground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case FONT: { >+ Font oldFont = font; >+ if (oldFont == null) { >+ Control [] controls = getExampleControls (); >+ if (controls.length > 0) oldFont = controls [0].getFont (); >+ } >+ if (oldFont != null) fontDialog.setFontList(oldFont.getFontData()); // seed dialog with current font >+ FontData fontData = fontDialog.open (); >+ if (fontData == null) return; >+ oldFont = font; // dispose old font when done >+ font = new Font (display, fontData); >+ setExampleWidgetFont (); >+ setExampleWidgetSize (); >+ if (oldFont != null) oldFont.dispose (); >+ } >+ break; >+ } >+ } >+ >+ /** >+ * Creates the "Other" group. This is typically >+ * a child of the "Control" group. >+ */ >+ void createOtherGroup () { >+ /* Create the group */ >+ otherGroup = new Group (controlGroup, SWT.NONE); >+ otherGroup.setLayout (new GridLayout ()); >+ otherGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >+ otherGroup.setText (ControlExample.getResourceString("Other")); >+ >+ /* Create the controls */ >+ enabledButton = new Button(otherGroup, SWT.CHECK); >+ enabledButton.setText(ControlExample.getResourceString("Enabled")); >+ visibleButton = new Button(otherGroup, SWT.CHECK); >+ visibleButton.setText(ControlExample.getResourceString("Visible")); >+ backgroundImageButton = new Button(otherGroup, SWT.CHECK); >+ backgroundImageButton.setText(ControlExample.getResourceString("BackgroundImage")); >+ popupMenuButton = new Button(otherGroup, SWT.CHECK); >+ popupMenuButton.setText(ControlExample.getResourceString("PopupMenu")); >+ >+ /* Add the listeners */ >+ enabledButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleWidgetEnabled (); >+ } >+ }); >+ visibleButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleWidgetVisibility (); >+ } >+ }); >+ backgroundImageButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleWidgetBackgroundImage (); >+ } >+ }); >+ popupMenuButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleWidgetPopupMenu (); >+ } >+ }); >+ >+ /* Set the default state */ >+ enabledButton.setSelection(true); >+ visibleButton.setSelection(true); >+ backgroundImageButton.setSelection(false); >+ popupMenuButton.setSelection(false); >+ } >+ >+ /** >+ * Creates the "Background Mode" group. >+ */ >+ void createBackgroundModeGroup () { >+ /* Create the group */ >+ backgroundModeGroup = new Group (controlGroup, SWT.NONE); >+ backgroundModeGroup.setLayout (new GridLayout ()); >+ backgroundModeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >+ backgroundModeGroup.setText (ControlExample.getResourceString("Background_Mode")); >+ >+ /* Create the controls */ >+ backgroundModeCombo = new Combo(backgroundModeGroup, SWT.READ_ONLY); >+ backgroundModeCombo.setItems(new String[] {"SWT.INHERIT_NONE", "SWT.INHERIT_DEFAULT", "SWT.INHERIT_FORCE"}); >+ backgroundModeImageButton = new Button(backgroundModeGroup, SWT.CHECK); >+ backgroundModeImageButton.setText(ControlExample.getResourceString("BackgroundImage")); >+ backgroundModeColorButton = new Button(backgroundModeGroup, SWT.CHECK); >+ backgroundModeColorButton.setText(ControlExample.getResourceString("BackgroundColor")); >+ >+ /* Add the listeners */ >+ backgroundModeCombo.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleGroupBackgroundMode (); >+ } >+ }); >+ backgroundModeImageButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleGroupBackgroundImage (); >+ } >+ }); >+ backgroundModeColorButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleGroupBackgroundColor (); >+ } >+ }); >+ >+ /* Set the default state */ >+ backgroundModeCombo.setText(backgroundModeCombo.getItem(0)); >+ backgroundModeImageButton.setSelection(false); >+ backgroundModeColorButton.setSelection(false); >+ } >+ >+ void createEditEventDialog(Shell parent, int x, int y, final int index) { >+ final Shell dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); >+ dialog.setLayout(new GridLayout()); >+ dialog.setText(ControlExample.getResourceString ("Edit_Event")); >+ Label label = new Label (dialog, SWT.NONE); >+ label.setText (ControlExample.getResourceString ("Edit_Event_Fields", new String [] {EVENT_INFO[index].name})); >+ >+ Group group = new Group (dialog, SWT.NONE); >+ group.setLayout(new GridLayout(2, false)); >+ group.setLayoutData(new GridData (SWT.FILL, SWT.FILL, true, true)); >+ >+ final int fields = EVENT_INFO[index].settableFields; >+ final int eventType = EVENT_INFO[index].type; >+ setFieldsMask = EVENT_INFO[index].setFields; >+ setFieldsEvent = EVENT_INFO[index].event; >+ >+ if ((fields & DOIT) != 0) { >+ new Label (group, SWT.NONE).setText ("doit"); >+ final Combo doitCombo = new Combo (group, SWT.READ_ONLY); >+ doitCombo.setItems (new String [] {"", "true", "false"}); >+ if ((setFieldsMask & DOIT) != 0) doitCombo.setText(Boolean.toString(setFieldsEvent.doit)); >+ doitCombo.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ doitCombo.addSelectionListener(new SelectionAdapter () { >+ public void widgetSelected(SelectionEvent e) { >+ String newValue = doitCombo.getText(); >+ if (newValue.length() == 0) { >+ setFieldsMask &= ~DOIT; >+ } else { >+ setFieldsEvent.type = eventType; >+ setFieldsEvent.doit = newValue.equals("true"); >+ setFieldsMask |= DOIT; >+ } >+ } >+ }); >+ } >+ >+ if ((fields & DETAIL) != 0) { >+ new Label (group, SWT.NONE).setText ("detail"); >+ int detailType = fields & 0xFF; >+ final Combo detailCombo = new Combo (group, SWT.READ_ONLY); >+ detailCombo.setItems (DETAIL_CONSTANTS[detailType]); >+ detailCombo.add ("", 0); >+ detailCombo.setVisibleItemCount(detailCombo.getItemCount()); >+ if ((setFieldsMask & DETAIL) != 0) detailCombo.setText (DETAIL_CONSTANTS[detailType][setFieldsEvent.detail]); >+ detailCombo.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ detailCombo.addSelectionListener(new SelectionAdapter () { >+ public void widgetSelected(SelectionEvent e) { >+ String newValue = detailCombo.getText(); >+ if (newValue.length() == 0) { >+ setFieldsMask &= ~DETAIL; >+ } else { >+ setFieldsEvent.type = eventType; >+ for (int i = 0; i < DETAIL_VALUES.length; i += 2) { >+ if (newValue.equals (DETAIL_VALUES [i])) { >+ setFieldsEvent.detail = ((Integer) DETAIL_VALUES [i + 1]).intValue(); >+ break; >+ } >+ } >+ setFieldsMask |= DETAIL; >+ } >+ } >+ }); >+ } >+ >+ if ((fields & TEXT) != 0) { >+ new Label (group, SWT.NONE).setText ("text"); >+ final Text textText = new Text (group, SWT.BORDER); >+ if ((setFieldsMask & TEXT) != 0) textText.setText(setFieldsEvent.text); >+ textText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ textText.addModifyListener(new ModifyListener () { >+ public void modifyText(ModifyEvent e) { >+ String newValue = textText.getText(); >+ if (newValue.length() == 0) { >+ setFieldsMask &= ~TEXT; >+ } else { >+ setFieldsEvent.type = eventType; >+ setFieldsEvent.text = newValue; >+ setFieldsMask |= TEXT; >+ } >+ } >+ }); >+ } >+ >+ if ((fields & X) != 0) { >+ new Label (group, SWT.NONE).setText ("x"); >+ final Text xText = new Text (group, SWT.BORDER); >+ if ((setFieldsMask & X) != 0) xText.setText(Integer.toString(setFieldsEvent.x)); >+ xText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ xText.addModifyListener(new ModifyListener () { >+ public void modifyText(ModifyEvent e) { >+ String newValue = xText.getText (); >+ try { >+ int newIntValue = Integer.parseInt (newValue); >+ setFieldsEvent.type = eventType; >+ setFieldsEvent.x = newIntValue; >+ setFieldsMask |= X; >+ } catch (NumberFormatException ex) { >+ setFieldsMask &= ~X; >+ } >+ } >+ }); >+ } >+ >+ if ((fields & Y) != 0) { >+ new Label (group, SWT.NONE).setText ("y"); >+ final Text yText = new Text (group, SWT.BORDER); >+ if ((setFieldsMask & Y) != 0) yText.setText(Integer.toString(setFieldsEvent.y)); >+ yText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ yText.addModifyListener(new ModifyListener () { >+ public void modifyText(ModifyEvent e) { >+ String newValue = yText.getText (); >+ try { >+ int newIntValue = Integer.parseInt (newValue); >+ setFieldsEvent.type = eventType; >+ setFieldsEvent.y = newIntValue; >+ setFieldsMask |= Y; >+ } catch (NumberFormatException ex) { >+ setFieldsMask &= ~Y; >+ } >+ } >+ }); >+ } >+ >+ if ((fields & WIDTH) != 0) { >+ new Label (group, SWT.NONE).setText ("width"); >+ final Text widthText = new Text (group, SWT.BORDER); >+ if ((setFieldsMask & WIDTH) != 0) widthText.setText(Integer.toString(setFieldsEvent.width)); >+ widthText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ widthText.addModifyListener(new ModifyListener () { >+ public void modifyText(ModifyEvent e) { >+ String newValue = widthText.getText (); >+ try { >+ int newIntValue = Integer.parseInt (newValue); >+ setFieldsEvent.type = eventType; >+ setFieldsEvent.width = newIntValue; >+ setFieldsMask |= WIDTH; >+ } catch (NumberFormatException ex) { >+ setFieldsMask &= ~WIDTH; >+ } >+ } >+ }); >+ } >+ >+ if ((fields & HEIGHT) != 0) { >+ new Label (group, SWT.NONE).setText ("height"); >+ final Text heightText = new Text (group, SWT.BORDER); >+ if ((setFieldsMask & HEIGHT) != 0) heightText.setText(Integer.toString(setFieldsEvent.height)); >+ heightText.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false)); >+ heightText.addModifyListener(new ModifyListener () { >+ public void modifyText(ModifyEvent e) { >+ String newValue = heightText.getText (); >+ try { >+ int newIntValue = Integer.parseInt (newValue); >+ setFieldsEvent.type = eventType; >+ setFieldsEvent.height = newIntValue; >+ setFieldsMask |= HEIGHT; >+ } catch (NumberFormatException ex) { >+ setFieldsMask &= ~HEIGHT; >+ } >+ } >+ }); >+ } >+ >+ Button ok = new Button (dialog, SWT.PUSH); >+ ok.setText (ControlExample.getResourceString("OK")); >+ GridData data = new GridData (70, SWT.DEFAULT); >+ data.horizontalAlignment = SWT.RIGHT; >+ ok.setLayoutData (data); >+ ok.addSelectionListener (new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ EVENT_INFO[index].setFields = setFieldsMask; >+ EVENT_INFO[index].event = setFieldsEvent; >+ dialog.dispose(); >+ } >+ }); >+ >+ dialog.setDefaultButton(ok); >+ dialog.pack(); >+ dialog.setLocation(x, y); >+ dialog.open(); >+ } >+ >+ /** >+ * Create the event console popup menu. >+ */ >+ void createEventConsolePopup () { >+ Menu popup = new Menu (shell, SWT.POP_UP); >+ eventConsole.setMenu (popup); >+ >+ MenuItem cut = new MenuItem (popup, SWT.PUSH); >+ cut.setText (ControlExample.getResourceString("MenuItem_Cut")); >+ cut.addListener (SWT.Selection, new Listener () { >+ public void handleEvent (Event event) { >+ eventConsole.cut (); >+ } >+ }); >+ MenuItem copy = new MenuItem (popup, SWT.PUSH); >+ copy.setText (ControlExample.getResourceString("MenuItem_Copy")); >+ copy.addListener (SWT.Selection, new Listener () { >+ public void handleEvent (Event event) { >+ eventConsole.copy (); >+ } >+ }); >+ MenuItem paste = new MenuItem (popup, SWT.PUSH); >+ paste.setText (ControlExample.getResourceString("MenuItem_Paste")); >+ paste.addListener (SWT.Selection, new Listener () { >+ public void handleEvent (Event event) { >+ eventConsole.paste (); >+ } >+ }); >+ new MenuItem (popup, SWT.SEPARATOR); >+ MenuItem selectAll = new MenuItem (popup, SWT.PUSH); >+ selectAll.setText(ControlExample.getResourceString("MenuItem_SelectAll")); >+ selectAll.addListener (SWT.Selection, new Listener () { >+ public void handleEvent (Event event) { >+ eventConsole.selectAll (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Example" group. The "Example" group >+ * is typically the left hand column in the tab. >+ */ >+ void createExampleGroup () { >+ exampleGroup = new Group (tabFolderPage, SWT.NONE); >+ exampleGroup.setLayout (new GridLayout ()); >+ exampleGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ } >+ >+ /** >+ * Creates the "Example" widget children of the "Example" group. >+ * Subclasses override this method to create the particular >+ * example control. >+ */ >+ void createExampleWidgets () { >+ /* Do nothing */ >+ } >+ >+ /** >+ * Creates and opens the "Listener selection" dialog. >+ */ >+ void createListenerSelectionDialog () { >+ final Shell dialog = new Shell (shell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); >+ dialog.setText (ControlExample.getResourceString ("Select_Listeners")); >+ dialog.setLayout (new GridLayout (2, false)); >+ final Table table = new Table (dialog, SWT.BORDER | SWT.V_SCROLL | SWT.CHECK); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ data.verticalSpan = 3; >+ table.setLayoutData(data); >+ for (int i = 0; i < EVENT_INFO.length; i++) { >+ TableItem item = new TableItem (table, SWT.NONE); >+ item.setText (EVENT_INFO[i].name); >+ item.setChecked (eventsFilter[i]); >+ } >+ final String [] customNames = getCustomEventNames (); >+ for (int i = 0; i < customNames.length; i++) { >+ TableItem item = new TableItem (table, SWT.NONE); >+ item.setText (customNames[i]); >+ item.setChecked (eventsFilter[EVENT_INFO.length + i]); >+ } >+ Button selectAll = new Button (dialog, SWT.PUSH); >+ selectAll.setText(ControlExample.getResourceString ("Select_All")); >+ selectAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >+ selectAll.addSelectionListener (new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ TableItem [] items = table.getItems(); >+ for (int i = 0; i < EVENT_INFO.length; i++) { >+ items[i].setChecked(true); >+ } >+ for (int i = 0; i < customNames.length; i++) { >+ items[EVENT_INFO.length + i].setChecked(true); >+ } >+ } >+ }); >+ Button deselectAll = new Button (dialog, SWT.PUSH); >+ deselectAll.setText(ControlExample.getResourceString ("Deselect_All")); >+ deselectAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >+ deselectAll.addSelectionListener (new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ TableItem [] items = table.getItems(); >+ for (int i = 0; i < EVENT_INFO.length; i++) { >+ items[i].setChecked(false); >+ } >+ for (int i = 0; i < customNames.length; i++) { >+ items[EVENT_INFO.length + i].setChecked(false); >+ } >+ } >+ }); >+ final Button editEvent = new Button (dialog, SWT.PUSH); >+ editEvent.setText (ControlExample.getResourceString ("Edit_Event")); >+ editEvent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING)); >+ editEvent.addSelectionListener (new SelectionAdapter() { >+ public void widgetSelected (SelectionEvent e) { >+ Point pt = editEvent.getLocation(); >+ pt = e.display.map(editEvent, null, pt); >+ int index = table.getSelectionIndex(); >+ if (getExampleWidgets().length > 0 && index != -1) { >+ createEditEventDialog(dialog, pt.x, pt.y, index); >+ } >+ } >+ }); >+ editEvent.setEnabled(false); >+ table.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ int fields = 0; >+ int index = table.getSelectionIndex(); >+ if (index != -1 && index < EVENT_INFO.length) { // TODO: Allow custom widgets to specify event info >+ fields = (EVENT_INFO[index].settableFields); >+ } >+ editEvent.setEnabled(fields != 0); >+ } >+ public void widgetDefaultSelected(SelectionEvent e) { >+ if (editEvent.getEnabled()) { >+ Point pt = editEvent.getLocation(); >+ pt = e.display.map(editEvent, null, pt); >+ int index = table.getSelectionIndex(); >+ if (getExampleWidgets().length > 0 && index != -1 && index < EVENT_INFO.length) { >+ createEditEventDialog(dialog, pt.x, pt.y, index); >+ } >+ } >+ } >+ }); >+ >+ new Label(dialog, SWT.NONE); /* Filler */ >+ Button ok = new Button (dialog, SWT.PUSH); >+ ok.setText(ControlExample.getResourceString ("OK")); >+ dialog.setDefaultButton(ok); >+ ok.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >+ ok.addSelectionListener (new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ TableItem [] items = table.getItems(); >+ for (int i = 0; i < EVENT_INFO.length; i++) { >+ eventsFilter[i] = items[i].getChecked(); >+ } >+ for (int i = 0; i < customNames.length; i++) { >+ eventsFilter[EVENT_INFO.length + i] = items[EVENT_INFO.length + i].getChecked(); >+ } >+ dialog.dispose(); >+ } >+ }); >+ dialog.pack (); >+ /* >+ * If the preferred size of the dialog is too tall for the display, >+ * then reduce the height, so that the vertical scrollbar will appear. >+ */ >+ Rectangle bounds = dialog.getBounds(); >+ Rectangle trim = dialog.computeTrim(0, 0, 0, 0); >+ Rectangle clientArea = display.getClientArea(); >+ if (bounds.height > clientArea.height) { >+ dialog.setSize(bounds.width, clientArea.height - trim.height); >+ } >+ dialog.setLocation(bounds.x, clientArea.y); >+ dialog.open (); >+ while (! dialog.isDisposed()) { >+ if (! display.readAndDispatch()) display.sleep(); >+ } >+ } >+ >+ /** >+ * Creates the "Listeners" group. The "Listeners" group >+ * goes below the "Example" and "Control" groups. >+ */ >+ void createListenersGroup () { >+ listenersGroup = new Group (tabFolderPage, SWT.NONE); >+ listenersGroup.setLayout (new GridLayout (3, false)); >+ listenersGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true, 2, 1)); >+ listenersGroup.setText (ControlExample.getResourceString ("Listeners")); >+ >+ /* >+ * Create the button to access the 'Listeners' dialog. >+ */ >+ Button listenersButton = new Button (listenersGroup, SWT.PUSH); >+ listenersButton.setText (ControlExample.getResourceString ("Select_Listeners")); >+ listenersButton.addSelectionListener (new SelectionAdapter() { >+ public void widgetSelected (SelectionEvent e) { >+ createListenerSelectionDialog (); >+ recreateExampleWidgets (); >+ } >+ }); >+ >+ /* >+ * Create the checkbox to add/remove listeners to/from the example widgets. >+ */ >+ final Button listenCheckbox = new Button (listenersGroup, SWT.CHECK); >+ listenCheckbox.setText (ControlExample.getResourceString ("Listen")); >+ listenCheckbox.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected(SelectionEvent e) { >+ logging = listenCheckbox.getSelection (); >+ recreateExampleWidgets (); >+ } >+ }); >+ >+ /* >+ * Create the button to clear the text. >+ */ >+ Button clearButton = new Button (listenersGroup, SWT.PUSH); >+ clearButton.setText (ControlExample.getResourceString ("Clear")); >+ clearButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); >+ clearButton.addSelectionListener (new SelectionAdapter() { >+ public void widgetSelected (SelectionEvent e) { >+ eventConsole.setText (""); >+ } >+ }); >+ >+ /* Initialize the eventsFilter to log all events. */ >+ int customEventCount = getCustomEventNames ().length; >+ eventsFilter = new boolean [EVENT_INFO.length + customEventCount]; >+ for (int i = 0; i < EVENT_INFO.length + customEventCount; i++) { >+ eventsFilter [i] = true; >+ } >+ >+ /* Create the event console Text. */ >+ eventConsole = new Text (listenersGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); >+ GridData data = new GridData (GridData.FILL_BOTH); >+ data.horizontalSpan = 3; >+ data.heightHint = 80; >+ eventConsole.setLayoutData (data); >+ createEventConsolePopup (); >+ eventConsole.addKeyListener (new KeyAdapter () { >+ public void keyPressed (KeyEvent e) { >+ if ((e.keyCode == 'A' || e.keyCode == 'a') && (e.stateMask & SWT.MOD1) != 0) { >+ eventConsole.selectAll (); >+ e.doit = false; >+ } >+ } >+ }); >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return null; >+ } >+ >+ Shell createSetGetDialog(String[] methodNames) { >+ final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MODELESS); >+ dialog.setLayout(new GridLayout(2, false)); >+ dialog.setText(getTabText() + " " + ControlExample.getResourceString ("Set_Get")); >+ nameCombo = new Combo(dialog, SWT.READ_ONLY); >+ nameCombo.setItems(methodNames); >+ nameCombo.setText(methodNames[0]); >+ nameCombo.setVisibleItemCount(methodNames.length); >+ nameCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >+ nameCombo.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ resetLabels(); >+ } >+ }); >+ returnTypeLabel = new Label(dialog, SWT.NONE); >+ returnTypeLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false)); >+ setButton = new Button(dialog, SWT.PUSH); >+ setButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false)); >+ setButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ setValue(); >+ setText.selectAll(); >+ setText.setFocus(); >+ } >+ }); >+ setText = new Text(dialog, SWT.SINGLE | SWT.BORDER); >+ setText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); >+ getButton = new Button(dialog, SWT.PUSH); >+ getButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false)); >+ getButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ getValue(); >+ } >+ }); >+ getText = new Text(dialog, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL); >+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); >+ data.widthHint = 240; >+ data.heightHint = 200; >+ getText.setLayoutData(data); >+ resetLabels(); >+ dialog.setDefaultButton(setButton); >+ dialog.pack(); >+ dialog.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ setGetDialog = null; >+ } >+ }); >+ return dialog; >+ } >+ >+ void resetLabels() { >+ String methodRoot = nameCombo.getText(); >+ returnTypeLabel.setText(parameterInfo(methodRoot)); >+ setButton.setText(setMethodName(methodRoot)); >+ getButton.setText("get" + methodRoot); >+ setText.setText(""); >+ getText.setText(""); >+ getValue(); >+ setText.setFocus(); >+ } >+ >+ String setMethodName(String methodRoot) { >+ return "set" + methodRoot; >+ } >+ >+ String parameterInfo(String methodRoot) { >+ String typeName = null; >+ Class returnType = getReturnType(methodRoot); >+ boolean isArray = returnType.isArray(); >+ if (isArray) { >+ typeName = returnType.getComponentType().getName(); >+ } else { >+ typeName = returnType.getName(); >+ } >+ String typeNameString = typeName; >+ int index = typeName.lastIndexOf('.'); >+ if (index != -1 && index+1 < typeName.length()) typeNameString = typeName.substring(index+1); >+ String info = ControlExample.getResourceString("Info_" + typeNameString + (isArray ? "A" : "")); >+ if (isArray) { >+ typeNameString += "[]"; >+ } >+ return ControlExample.getResourceString("Parameter_Info", new Object[] {typeNameString, info}); >+ } >+ >+ void getValue() { >+ String methodName = "get" + nameCombo.getText(); >+ getText.setText(""); >+ Widget[] widgets = getExampleWidgets(); >+ for (int i = 0; i < widgets.length; i++) { >+ try { >+ java.lang.reflect.Method method = widgets[i].getClass().getMethod(methodName, null); >+ Object result = method.invoke(widgets[i], null); >+ if (result == null) { >+ getText.append("null"); >+ } else if (result.getClass().isArray()) { >+ int length = java.lang.reflect.Array.getLength(result); >+ if (length == 0) { >+ getText.append(result.getClass().getComponentType() + "[0]"); >+ } >+ for (int j = 0; j < length; j++) { >+ getText.append(java.lang.reflect.Array.get(result,j).toString() + "\n"); >+ } >+ } else { >+ getText.append(result.toString()); >+ } >+ } catch (Exception e) { >+ getText.append(e.toString()); >+ } >+ if (i + 1 < widgets.length) { >+ getText.append("\n\n"); >+ } >+ } >+ } >+ >+ Class getReturnType(String methodRoot) { >+ Class returnType = null; >+ String methodName = "get" + methodRoot; >+ Widget[] widgets = getExampleWidgets(); >+ try { >+ java.lang.reflect.Method method = widgets[0].getClass().getMethod(methodName, null); >+ returnType = method.getReturnType(); >+ } catch (Exception e) { >+ } >+ return returnType; >+ } >+ >+ void setValue() { >+ /* The parameter type must be the same as the get method's return type */ >+ String methodRoot = nameCombo.getText(); >+ Class returnType = getReturnType(methodRoot); >+ String methodName = setMethodName(methodRoot); >+ String value = setText.getText(); >+ Widget[] widgets = getExampleWidgets(); >+ for (int i = 0; i < widgets.length; i++) { >+ try { >+ java.lang.reflect.Method method = widgets[i].getClass().getMethod(methodName, new Class[] {returnType}); >+ String typeName = returnType.getName(); >+ Object[] parameter = null; >+ if (value.equals("null")) { >+ parameter = new Object[] {null}; >+ } else if (typeName.equals("int")) { >+ parameter = new Object[] {new Integer(value)}; >+ } else if (typeName.equals("long")) { >+ parameter = new Object[] {new Long(value)}; >+ } else if (typeName.equals("char")) { >+ parameter = new Object[] {value.length() == 1 ? new Character(value.charAt(0)) : new Character('\0')}; >+ } else if (typeName.equals("boolean")) { >+ parameter = new Object[] {new Boolean(value)}; >+ } else if (typeName.equals("java.lang.String")) { >+ parameter = new Object[] {value}; >+ } else if (typeName.equals("org.eclipse.swt.graphics.Point")) { >+ String xy[] = split(value, ','); >+ parameter = new Object[] {new Point(new Integer(xy[0]).intValue(),new Integer(xy[1]).intValue())}; >+ } else if (typeName.equals("[I")) { >+ String strings[] = split(value, ','); >+ int[] ints = new int[strings.length]; >+ for (int j = 0; j < strings.length; j++) { >+ ints[j] = new Integer(strings[j]).intValue(); >+ } >+ parameter = new Object[] {ints}; >+ } else if (typeName.equals("[Ljava.lang.String;")) { >+ parameter = new Object[] {split(value, ',')}; >+ } else { >+ parameter = parameterForType(typeName, value, widgets[i]); >+ } >+ method.invoke(widgets[i], parameter); >+ } catch (Exception e) { >+ Throwable cause = e.getCause(); >+ String message = e.getMessage(); >+ getText.setText(e.toString()); >+ if (cause != null) getText.append(", cause=\n" + cause.toString()); >+ if (message != null) getText.append(", message=\n" + message); >+ } >+ } >+ } >+ >+ Object[] parameterForType(String typeName, String value, Widget widget) { >+ return new Object[] {value}; >+ } >+ >+ void createOrientationGroup () { >+ /* Create Orientation group*/ >+ orientationGroup = new Group (controlGroup, SWT.NONE); >+ orientationGroup.setLayout (new GridLayout()); >+ orientationGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >+ orientationGroup.setText (ControlExample.getResourceString("Orientation")); >+ defaultOrietationButton = new Button (orientationGroup, SWT.RADIO); >+ defaultOrietationButton.setText (ControlExample.getResourceString("Default")); >+ defaultOrietationButton.setSelection (true); >+ ltrButtonRecreate = new Button (orientationGroup, SWT.RADIO); >+ ltrButtonRecreate.setText ("create new SWT.LEFT_TO_RIGHT"); >+ rtlButtonRecreate = new Button (orientationGroup, SWT.RADIO); >+ rtlButtonRecreate.setText ("create new SWT.RIGHT_TO_LEFT"); >+ ltrButtonSet= new Button (orientationGroup, SWT.RADIO); >+ ltrButtonSet.setText ("set orientation SWT.LEFT_TO_RIGHT"); >+ rtlButtonSet = new Button (orientationGroup, SWT.RADIO); >+ rtlButtonSet.setText ("set orientation SWT.RIGHT_TO_LEFT"); >+ >+ >+ } >+ >+ /** >+ * 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 (SWT.FILL, SWT.FILL, false, false)); >+ sizeGroup.setText (ControlExample.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 (ControlExample.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); >+ fillHButton = new Button (sizeGroup, SWT.CHECK); >+ fillHButton.setText (ControlExample.getResourceString("Fill_X")); >+ fillVButton = new Button (sizeGroup, SWT.CHECK); >+ fillVButton.setText (ControlExample.getResourceString("Fill_Y")); >+ >+ /* Add the listeners */ >+ SelectionAdapter selectionListener = new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleWidgetSize (); >+ } >+ }; >+ preferredButton.addSelectionListener(selectionListener); >+ tooSmallButton.addSelectionListener(selectionListener); >+ smallButton.addSelectionListener(selectionListener); >+ largeButton.addSelectionListener(selectionListener); >+ fillHButton.addSelectionListener(selectionListener); >+ fillVButton.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 (SWT.FILL, SWT.FILL, false, false)); >+ styleGroup.setText (ControlExample.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) { >+ /* Cache the shell and display. */ >+ shell = tabFolder.getShell (); >+ display = shell.getDisplay (); >+ >+ /* Create a two column page. */ >+ tabFolderPage = new Composite (tabFolder, SWT.NONE); >+ tabFolderPage.setLayout (new GridLayout (2, false)); >+ >+ /* Create the "Example" and "Control" groups. */ >+ createExampleGroup (); >+ createControlGroup (); >+ >+ /* Create the "Listeners" group under the "Control" group. */ >+ createListenersGroup (); >+ >+ /* Create and initialize the example and control widgets. */ >+ createExampleWidgets (); >+ hookExampleWidgetListeners (); >+ createControlWidgets (); >+ setExampleWidgetState (); >+ >+ return tabFolderPage; >+ } >+ >+ void setExampleWidgetPopupMenu() { >+ Control[] controls = getExampleControls(); >+ for (int i = 0; i < controls.length; i++) { >+ final Control control = controls [i]; >+ control.addListener(SWT.MenuDetect, new Listener() { >+ public void handleEvent(Event event) { >+ Menu menu = control.getMenu(); >+ if (menu != null && samplePopup) { >+ menu.dispose(); >+ menu = null; >+ } >+ if (menu == null && popupMenuButton.getSelection()) { >+ menu = new Menu(shell, SWT.POP_UP | (control.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT))); >+ MenuItem item = new MenuItem(menu, SWT.PUSH); >+ item.setText("Sample popup menu item"); >+ specialPopupMenuItems(menu, event); >+ control.setMenu(menu); >+ samplePopup = true; >+ } >+ } >+ }); >+ } >+ } >+ >+ protected void specialPopupMenuItems(final Menu menu, final Event event) { >+ } >+ >+ /** >+ * Disposes the "Example" widgets. >+ */ >+ void disposeExampleWidgets () { >+ Widget [] widgets = getExampleWidgets (); >+ for (int i=0; i<widgets.length; i++) { >+ widgets [i].dispose (); >+ } >+ } >+ >+ Image colorImage (Color color) { >+ Image image = new Image (display, IMAGE_SIZE, IMAGE_SIZE); >+ GC gc = new GC(image); >+ gc.setBackground(color); >+ Rectangle bounds = image.getBounds(); >+ gc.fillRectangle(0, 0, bounds.width, bounds.height); >+ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); >+ gc.drawRectangle(0, 0, bounds.width - 1, bounds.height - 1); >+ gc.dispose(); >+ return image; >+ } >+ >+ Image fontImage (Font font) { >+ Image image = new Image (display, IMAGE_SIZE, IMAGE_SIZE); >+ GC gc = new GC(image); >+ Rectangle bounds = image.getBounds(); >+ gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); >+ gc.fillRectangle(0, 0, bounds.width, bounds.height); >+ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); >+ gc.drawRectangle(0, 0, bounds.width - 1, bounds.height - 1); >+ FontData data[] = font.getFontData(); >+ int style = data[0].getStyle(); >+ switch (style) { >+ case SWT.NORMAL: >+ gc.drawLine(3, 3, 3, 8); >+ gc.drawLine(4, 3, 7, 8); >+ gc.drawLine(8, 3, 8, 8); >+ break; >+ case SWT.BOLD: >+ gc.drawLine(3, 2, 3, 9); >+ gc.drawLine(4, 2, 4, 9); >+ gc.drawLine(5, 2, 7, 2); >+ gc.drawLine(5, 3, 8, 3); >+ gc.drawLine(5, 5, 7, 5); >+ gc.drawLine(5, 6, 7, 6); >+ gc.drawLine(5, 8, 8, 8); >+ gc.drawLine(5, 9, 7, 9); >+ gc.drawLine(7, 4, 8, 4); >+ gc.drawLine(7, 7, 8, 7); >+ break; >+ case SWT.ITALIC: >+ gc.drawLine(6, 2, 8, 2); >+ gc.drawLine(7, 3, 4, 8); >+ gc.drawLine(3, 9, 5, 9); >+ break; >+ case SWT.BOLD | SWT.ITALIC: >+ gc.drawLine(5, 2, 8, 2); >+ gc.drawLine(5, 3, 8, 3); >+ gc.drawLine(6, 4, 4, 7); >+ gc.drawLine(7, 4, 5, 7); >+ gc.drawLine(3, 8, 6, 8); >+ gc.drawLine(3, 9, 6, 9); >+ break; >+ } >+ gc.dispose(); >+ return image; >+ } >+ >+ /** >+ * Gets the list of custom event names. >+ * Subclasses override this method to allow adding of custom events. >+ * >+ * @return an array containing custom event names >+ * @see hookCustomListener >+ */ >+ String [] getCustomEventNames () { >+ return new String [0]; >+ } >+ >+ /** >+ * Gets the default style for a widget >+ * >+ * @return the default style bit >+ */ >+ int getDefaultStyle () { >+ if (ltrButtonRecreate != null && ltrButtonRecreate.getSelection()) { >+ return SWT.LEFT_TO_RIGHT; >+ } >+ if (rtlButtonRecreate != null && rtlButtonRecreate.getSelection()) { >+ return SWT.RIGHT_TO_LEFT; >+ } >+ if (rtlButtonSet != null && rtlButtonSet.getSelection()) { >+ return SWT.RIGHT_TO_LEFT; >+ } >+ if (ltrButtonSet != null && ltrButtonSet.getSelection()) { >+ return SWT.LEFT_TO_RIGHT; >+ } >+ return SWT.NONE; >+ } >+ >+ /** >+ * Gets the "Example" widgets. >+ * >+ * @return an array containing the example widgets >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [0]; >+ } >+ >+ /** >+ * Gets the "Example" controls. >+ * This is the subset of "Example" widgets that are controls. >+ * >+ * @return an array containing the example controls >+ */ >+ Control [] getExampleControls () { >+ Widget [] widgets = getExampleWidgets (); >+ Control [] controls = new Control [0]; >+ for (int i = 0; i < widgets.length; i++) { >+ if (widgets[i] instanceof Control) { >+ Control[] newControls = new Control[controls.length + 1]; >+ System.arraycopy(controls, 0, newControls, 0, controls.length); >+ controls = newControls; >+ controls[controls.length - 1] = (Control)widgets[i]; >+ } >+ } >+ return controls; >+ } >+ >+ /** >+ * Gets the "Example" widget's items, if any. >+ * >+ * @return an array containing the example widget's items >+ */ >+ Item [] getExampleWidgetItems () { >+ return new Item [0]; >+ } >+ >+ /** >+ * Gets the short text for the tab folder item. >+ * >+ * @return the short text for the tab item >+ */ >+ String getShortTabText() { >+ return getTabText(); >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ * >+ * @return the text for the tab item >+ */ >+ String getTabText () { >+ return ""; >+ } >+ >+ /** >+ * Hooks all listeners to all example controls >+ * and example control items. >+ */ >+ void hookExampleWidgetListeners () { >+ if (logging) { >+ Widget[] widgets = getExampleWidgets (); >+ for (int i = 0; i < widgets.length; i++) { >+ hookListeners (widgets [i]); >+ } >+ Item[] exampleItems = getExampleWidgetItems (); >+ for (int i = 0; i < exampleItems.length; i++) { >+ hookListeners (exampleItems [i]); >+ } >+ String [] customNames = getCustomEventNames (); >+ for (int i = 0; i < customNames.length; i++) { >+ if (eventsFilter [EVENT_INFO.length + i]) { >+ hookCustomListener (customNames[i]); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Hooks the custom listener specified by eventName. >+ * Subclasses override this method to add custom listeners. >+ * @see getCustomEventNames >+ */ >+ void hookCustomListener (String eventName) { >+ } >+ >+ /** >+ * Hooks all listeners to the specified widget. >+ */ >+ void hookListeners (Widget widget) { >+ if (logging) { >+ Listener listener = new Listener() { >+ public void handleEvent (Event event) { >+ log (event); >+ } >+ }; >+ for (int i = 0; i < EVENT_INFO.length; i++) { >+ if (eventsFilter [i]) { >+ widget.addListener (EVENT_INFO[i].type, listener); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Logs an untyped event to the event console. >+ */ >+ void log(Event event) { >+ int i = 0; >+ while (i < EVENT_INFO.length) { >+ if (EVENT_INFO[i].type == event.type) break; >+ i++; >+ } >+ String toString = EVENT_INFO[i].name + " [" + event.type + "]: "; >+ switch (event.type) { >+ case SWT.KeyDown: >+ case SWT.KeyUp: toString += new KeyEvent (event).toString (); break; >+ case SWT.MouseDown: >+ case SWT.MouseUp: >+ case SWT.MouseMove: >+ case SWT.MouseEnter: >+ case SWT.MouseExit: >+ case SWT.MouseDoubleClick: >+ case SWT.MouseWheel: >+ case SWT.MouseHover: toString += new MouseEvent (event).toString (); break; >+ case SWT.Paint: toString += new PaintEvent (event).toString (); break; >+ case SWT.Move: >+ case SWT.Resize: toString += new ControlEvent (event).toString (); break; >+ case SWT.Dispose: toString += new DisposeEvent (event).toString (); break; >+ case SWT.Selection: >+ case SWT.DefaultSelection: toString += new SelectionEvent (event).toString (); break; >+ case SWT.FocusIn: >+ case SWT.FocusOut: toString += new FocusEvent (event).toString (); break; >+ case SWT.Expand: >+ case SWT.Collapse: toString += new TreeEvent (event).toString (); break; >+ case SWT.Iconify: >+ case SWT.Deiconify: >+ case SWT.Close: >+ case SWT.Activate: >+ case SWT.Deactivate: toString += new ShellEvent (event).toString (); break; >+ case SWT.Show: >+ case SWT.Hide: toString += (event.widget instanceof Menu) ? new MenuEvent (event).toString () : event.toString(); break; >+ case SWT.Modify: toString += new ModifyEvent (event).toString (); break; >+ case SWT.Verify: toString += new VerifyEvent (event).toString (); break; >+ case SWT.Help: toString += new HelpEvent (event).toString (); break; >+ case SWT.Arm: toString += new ArmEvent (event).toString (); break; >+ case SWT.Traverse: toString += new TraverseEvent (event).toString (); break; >+ case SWT.HardKeyDown: >+ case SWT.HardKeyUp: >+ case SWT.DragDetect: >+ case SWT.MenuDetect: >+ case SWT.SetData: >+ default: toString += event.toString (); >+ } >+ log (toString); >+ >+ /* Return values for event fields. */ >+ int mask = EVENT_INFO[i].setFields; >+ if (!ignore && mask != 0) { >+ Event setFieldsEvent = EVENT_INFO[i].event; >+ if ((mask & DOIT) != 0) event.doit = setFieldsEvent.doit; >+ if ((mask & DETAIL) != 0) event.detail = setFieldsEvent.detail; >+ if ((mask & TEXT) != 0) event.text = setFieldsEvent.text; >+ if ((mask & X) != 0) event.x = setFieldsEvent.x; >+ if ((mask & Y) != 0) event.y = setFieldsEvent.y; >+ if ((mask & WIDTH) != 0) event.width = setFieldsEvent.width; >+ if ((mask & HEIGHT) != 0) event.height = setFieldsEvent.height; >+ eventConsole.append (ControlExample.getResourceString("Returning")); >+ ignore = true; >+ log (event); >+ ignore = false; >+ } >+ } >+ >+ /** >+ * Logs a string to the event console. >+ */ >+ void log (String string) { >+ if (!eventConsole.isDisposed()) { >+ eventConsole.append (string); >+ eventConsole.append ("\n"); >+ } >+ } >+ >+ /** >+ * Logs a typed event to the event console. >+ */ >+ void log (String eventName, TypedEvent event) { >+ log (eventName + ": " + event.toString ()); >+ } >+ >+ /** >+ * Recreates the "Example" widgets. >+ */ >+ void recreateExampleWidgets () { >+ disposeExampleWidgets (); >+ createExampleWidgets (); >+ hookExampleWidgetListeners (); >+ setExampleWidgetState (); >+ } >+ >+ /** >+ * Sets the foreground color, background color, and font >+ * of the "Example" widgets to their default settings. >+ * Subclasses may extend in order to reset other colors >+ * and fonts to default settings as well. >+ */ >+ void resetColorsAndFonts () { >+ Color oldColor = foregroundColor; >+ foregroundColor = null; >+ setExampleWidgetForeground (); >+ if (oldColor != null) oldColor.dispose(); >+ oldColor = backgroundColor; >+ backgroundColor = null; >+ setExampleWidgetBackground (); >+ if (oldColor != null) oldColor.dispose(); >+ Font oldFont = font; >+ font = null; >+ setExampleWidgetFont (); >+ setExampleWidgetSize (); >+ if (oldFont != null) oldFont.dispose(); >+ } >+ >+ boolean rtlSupport() { >+ return RTL_SUPPORT_ENABLE; >+ } >+ >+ /** >+ * Sets the background color of the "Example" widgets' parent. >+ */ >+ void setExampleGroupBackgroundColor () { >+ if (backgroundModeGroup == null) return; >+ exampleGroup.setBackground (backgroundModeColorButton.getSelection () ? display.getSystemColor(SWT.COLOR_BLUE) : null); >+ } >+ /** >+ * Sets the background image of the "Example" widgets' parent. >+ */ >+ void setExampleGroupBackgroundImage () { >+ if (backgroundModeGroup == null) return; >+ exampleGroup.setBackgroundImage (backgroundModeImageButton.getSelection () ? instance.images[ControlExample.ciParentBackground] : null); >+ } >+ >+ /** >+ * Sets the background mode of the "Example" widgets' parent. >+ */ >+ void setExampleGroupBackgroundMode () { >+ if (backgroundModeGroup == null) return; >+ String modeString = backgroundModeCombo.getText (); >+ int mode = SWT.INHERIT_NONE; >+ if (modeString.equals("SWT.INHERIT_DEFAULT")) mode = SWT.INHERIT_DEFAULT; >+ if (modeString.equals("SWT.INHERIT_FORCE")) mode = SWT.INHERIT_FORCE; >+ exampleGroup.setBackgroundMode (mode); >+ } >+ >+ /** >+ * Sets the background color of the "Example" widgets. >+ */ >+ void setExampleWidgetBackground () { >+ if (colorAndFontTable == null) return; // user cannot change color/font on this tab >+ Control [] controls = getExampleControls (); >+ if (!instance.startup) { >+ for (int i = 0; i < controls.length; i++) { >+ controls[i].setBackground (backgroundColor); >+ } >+ } >+ // Set the background color item's image to match the background color of the example widget(s). >+ Color color = backgroundColor; >+ if (controls.length == 0) return; >+ if (color == null) color = controls [0].getBackground (); >+ TableItem item = colorAndFontTable.getItem(BACKGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage (color)); >+ } >+ >+ /** >+ * Sets the enabled state of the "Example" widgets. >+ */ >+ void setExampleWidgetEnabled () { >+ Control [] controls = getExampleControls (); >+ for (int i=0; i<controls.length; i++) { >+ controls [i].setEnabled (enabledButton.getSelection ()); >+ } >+ } >+ >+ /** >+ * Sets the font of the "Example" widgets. >+ */ >+ void setExampleWidgetFont () { >+ if (colorAndFontTable == null) return; // user cannot change color/font on this tab >+ Control [] controls = getExampleControls (); >+ if (!instance.startup) { >+ for (int i = 0; i < controls.length; i++) { >+ controls[i].setFont(font); >+ } >+ } >+ /* Set the font item's image and font to match the font of the example widget(s). */ >+ Font ft = font; >+ if (controls.length == 0) return; >+ if (ft == null) ft = controls [0].getFont (); >+ TableItem item = colorAndFontTable.getItem(FONT); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (fontImage (ft)); >+ item.setFont(ft); >+ colorAndFontTable.layout (); >+ } >+ >+ /** >+ * Sets the foreground color of the "Example" widgets. >+ */ >+ void setExampleWidgetForeground () { >+ if (colorAndFontTable == null) return; // user cannot change color/font on this tab >+ Control [] controls = getExampleControls (); >+ if (!instance.startup) { >+ for (int i = 0; i < controls.length; i++) { >+ controls[i].setForeground (foregroundColor); >+ } >+ } >+ /* Set the foreground color item's image to match the foreground color of the example widget(s). */ >+ Color color = foregroundColor; >+ if (controls.length == 0) return; >+ if (color == null) color = controls [0].getForeground (); >+ TableItem item = colorAndFontTable.getItem(FOREGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * 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 = getExampleControls (); >+ for (int i=0; i<controls.length; i++) { >+ GridData gridData = new GridData(size, size); >+ gridData.grabExcessHorizontalSpace = fillHButton.getSelection(); >+ gridData.grabExcessVerticalSpace = fillVButton.getSelection(); >+ gridData.horizontalAlignment = fillHButton.getSelection() ? SWT.FILL : SWT.LEFT; >+ gridData.verticalAlignment = fillVButton.getSelection() ? SWT.FILL : SWT.TOP; >+ controls [i].setLayoutData (gridData); >+ } >+ tabFolderPage.layout (controls); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. Subclasses >+ * may extend this method to set "Example" widget state >+ * that is specific to the widget. >+ */ >+ void setExampleWidgetState () { >+ setExampleWidgetBackground (); >+ setExampleWidgetForeground (); >+ setExampleWidgetFont (); >+ if (!instance.startup) { >+ setExampleWidgetEnabled (); >+ setExampleWidgetVisibility (); >+ setExampleGroupBackgroundMode (); >+ setExampleGroupBackgroundColor (); >+ setExampleGroupBackgroundImage (); >+ setExampleWidgetBackgroundImage (); >+ setExampleWidgetPopupMenu (); >+ setExampleWidgetSize (); >+ } >+ //TEMPORARY CODE >+// Control [] controls = getExampleControls (); >+// for (int i=0; i<controls.length; i++) { >+// log ("Control=" + controls [i] + ", border width=" + controls [i].getBorderWidth ()); >+// } >+ } >+ >+ /** >+ * Sets the visibility of the "Example" widgets. >+ */ >+ void setExampleWidgetVisibility () { >+ Control [] controls = getExampleControls (); >+ for (int i=0; i<controls.length; i++) { >+ controls [i].setVisible (visibleButton.getSelection ()); >+ } >+ } >+ >+ /** >+ * Sets the background image of the "Example" widgets. >+ */ >+ void setExampleWidgetBackgroundImage () { >+ if (backgroundImageButton != null && backgroundImageButton.isDisposed()) return; >+ Control [] controls = getExampleControls (); >+ for (int i=0; i<controls.length; i++) { >+ controls [i].setBackgroundImage (backgroundImageButton.getSelection () ? instance.images[ControlExample.ciBackground] : null); >+ } >+ } >+ >+ /** >+ * Splits the given string around matches of the given character. >+ * >+ * This subset of java.lang.String.split(String regex) >+ * uses only code that can be run on CLDC platforms. >+ */ >+ String [] split (String string, char ch) { >+ String [] result = new String[0]; >+ int start = 0; >+ int length = string.length(); >+ while (start < length) { >+ int end = string.indexOf(ch, start); >+ if (end == -1) end = length; >+ String substr = string.substring(start, end); >+ String [] newResult = new String[result.length + 1]; >+ System.arraycopy(result, 0, newResult, 0, result.length); >+ newResult [result.length] = substr; >+ result = newResult; >+ start = end + 1; >+ } >+ return result; >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/TabFolderTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/TabFolderTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/TabFolderTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/TabFolderTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,166 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+ >+class TabFolderTab extends Tab { >+ /* Example widgets and groups that contain them */ >+ TabFolder tabFolder1; >+ Group tabFolderGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button topButton, bottomButton; >+ >+ static String [] TabItems1 = {ControlExample.getResourceString("TabItem1_0"), >+ ControlExample.getResourceString("TabItem1_1"), >+ ControlExample.getResourceString("TabItem1_2")}; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ TabFolderTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the TabFolder */ >+ tabFolderGroup = new Group (exampleGroup, SWT.NONE); >+ tabFolderGroup.setLayout (new GridLayout ()); >+ tabFolderGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ tabFolderGroup.setText ("TabFolder"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (topButton.getSelection ()) style |= SWT.TOP; >+ if (bottomButton.getSelection ()) style |= SWT.BOTTOM; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ >+ /* Create the example widgets */ >+ tabFolder1 = new TabFolder (tabFolderGroup, style); >+ for (int i = 0; i < TabItems1.length; i++) { >+ TabItem item = new TabItem(tabFolder1, SWT.NONE); >+ item.setText(TabItems1[i]); >+ item.setToolTipText(ControlExample.getResourceString("Tooltip", new String [] {TabItems1[i]})); >+ Text content = new Text(tabFolder1, SWT.WRAP | SWT.MULTI); >+ content.setText(ControlExample.getResourceString("TabItem_content") + ": " + i); >+ item.setControl(content); >+ } >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ topButton = new Button (styleGroup, SWT.RADIO); >+ topButton.setText ("SWT.TOP"); >+ topButton.setSelection(true); >+ bottomButton = new Button (styleGroup, SWT.RADIO); >+ bottomButton.setText ("SWT.BOTTOM"); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ } >+ >+ /** >+ * Gets the "Example" widget children's items, if any. >+ * >+ * @return an array containing the example widget children's items >+ */ >+ Item [] getExampleWidgetItems () { >+ return tabFolder1.getItems(); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {tabFolder1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Selection", "SelectionIndex", "ToolTipText"}; >+ } >+ >+ String setMethodName(String methodRoot) { >+ /* Override to handle special case of int getSelectionIndex()/setSelection(int) */ >+ return (methodRoot.equals("SelectionIndex")) ? "setSelection" : "set" + methodRoot; >+ } >+ >+ Object[] parameterForType(String typeName, String value, Widget widget) { >+ if (value.equals("")) return new Object[] {new TabItem[0]}; >+ if (typeName.equals("org.eclipse.swt.widgets.TabItem")) { >+ TabItem item = findItem(value, ((TabFolder) widget).getItems()); >+ if (item != null) return new Object[] {item}; >+ } >+ if (typeName.equals("[Lorg.eclipse.swt.widgets.TabItem;")) { >+ String[] values = split(value, ','); >+ TabItem[] items = new TabItem[values.length]; >+ for (int i = 0; i < values.length; i++) { >+ items[i] = findItem(values[i], ((TabFolder) widget).getItems()); >+ } >+ return new Object[] {items}; >+ } >+ return super.parameterForType(typeName, value, widget); >+ } >+ >+ TabItem findItem(String value, TabItem[] items) { >+ for (int i = 0; i < items.length; i++) { >+ TabItem item = items[i]; >+ if (item.getText().equals(value)) return item; >+ } >+ return null; >+ } >+ >+ /** >+ * Gets the short text for the tab folder item. >+ */ >+ String getShortTabText() { >+ return "TF"; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "TabFolder"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ topButton.setSelection ((tabFolder1.getStyle () & SWT.TOP) != 0); >+ bottomButton.setSelection ((tabFolder1.getStyle () & SWT.BOTTOM) != 0); >+ borderButton.setSelection ((tabFolder1.getStyle () & SWT.BORDER) != 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/TableTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/TableTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/TableTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/TableTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,685 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+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; >+ >+ /* Size widgets added to the "Size" group */ >+ Button packColumnsButton; >+ >+ /* Style widgets added to the "Style" group */ >+ Button noScrollButton, checkButton, fullSelectionButton, hideSelectionButton; >+ >+ /* Other widgets added to the "Other" group */ >+ Button multipleColumns, moveableColumns, resizableColumns, headerVisibleButton, sortIndicatorButton, headerImagesButton, linesVisibleButton, subImagesButton; >+ >+ /* Controls and resources added to the "Colors and Fonts" group */ >+ static final int ITEM_FOREGROUND_COLOR = 3; >+ static final int ITEM_BACKGROUND_COLOR = 4; >+ static final int ITEM_FONT = 5; >+ static final int CELL_FOREGROUND_COLOR = 6; >+ static final int CELL_BACKGROUND_COLOR = 7; >+ static final int CELL_FONT = 8; >+ Color itemForegroundColor, itemBackgroundColor, cellForegroundColor, cellBackgroundColor; >+ Font itemFont, cellFont; >+ >+ static String [] columnTitles = {ControlExample.getResourceString("TableTitle_0"), >+ ControlExample.getResourceString("TableTitle_1"), >+ ControlExample.getResourceString("TableTitle_2"), >+ ControlExample.getResourceString("TableTitle_3")}; >+ >+ static String[][] tableData = { >+ { ControlExample.getResourceString("TableLine0_0"), >+ ControlExample.getResourceString("TableLine0_1"), >+ ControlExample.getResourceString("TableLine0_2"), >+ ControlExample.getResourceString("TableLine0_3") }, >+ { ControlExample.getResourceString("TableLine1_0"), >+ ControlExample.getResourceString("TableLine1_1"), >+ ControlExample.getResourceString("TableLine1_2"), >+ ControlExample.getResourceString("TableLine1_3") }, >+ { ControlExample.getResourceString("TableLine2_0"), >+ ControlExample.getResourceString("TableLine2_1"), >+ ControlExample.getResourceString("TableLine2_2"), >+ ControlExample.getResourceString("TableLine2_3") } }; >+ >+ Point menuMouseCoords; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ TableTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Colors and Fonts" group. >+ */ >+ void createColorAndFontGroup () { >+ super.createColorAndFontGroup(); >+ >+ TableItem item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Item_Foreground_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Item_Background_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Item_Font")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Cell_Foreground_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Cell_Background_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Cell_Font")); >+ >+ shell.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent event) { >+ if (itemBackgroundColor != null) itemBackgroundColor.dispose(); >+ if (itemForegroundColor != null) itemForegroundColor.dispose(); >+ if (itemFont != null) itemFont.dispose(); >+ if (cellBackgroundColor != null) cellBackgroundColor.dispose(); >+ if (cellForegroundColor != null) cellForegroundColor.dispose(); >+ if (cellFont != null) cellFont.dispose(); >+ itemBackgroundColor = null; >+ itemForegroundColor = null; >+ itemFont = null; >+ cellBackgroundColor = null; >+ cellForegroundColor = null; >+ cellFont = null; >+ } >+ }); >+ } >+ >+ void changeFontOrColor(int index) { >+ switch (index) { >+ case ITEM_FOREGROUND_COLOR: { >+ Color oldColor = itemForegroundColor; >+ if (oldColor == null) oldColor = table1.getItem (0).getForeground (); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = itemForegroundColor; >+ itemForegroundColor = new Color (display, rgb); >+ setItemForeground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case ITEM_BACKGROUND_COLOR: { >+ Color oldColor = itemBackgroundColor; >+ if (oldColor == null) oldColor = table1.getItem (0).getBackground (); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = itemBackgroundColor; >+ itemBackgroundColor = new Color (display, rgb); >+ setItemBackground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case ITEM_FONT: { >+ Font oldFont = itemFont; >+ if (oldFont == null) oldFont = table1.getItem (0).getFont (); >+ fontDialog.setFontList(oldFont.getFontData()); >+ FontData fontData = fontDialog.open (); >+ if (fontData == null) return; >+ oldFont = itemFont; >+ itemFont = new Font (display, fontData); >+ setItemFont (); >+ setExampleWidgetSize (); >+ if (oldFont != null) oldFont.dispose (); >+ } >+ break; >+ case CELL_FOREGROUND_COLOR: { >+ Color oldColor = cellForegroundColor; >+ if (oldColor == null) oldColor = table1.getItem (0).getForeground (1); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = cellForegroundColor; >+ cellForegroundColor = new Color (display, rgb); >+ setCellForeground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case CELL_BACKGROUND_COLOR: { >+ Color oldColor = cellBackgroundColor; >+ if (oldColor == null) oldColor = table1.getItem (0).getBackground (1); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = cellBackgroundColor; >+ cellBackgroundColor = new Color (display, rgb); >+ setCellBackground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case CELL_FONT: { >+ Font oldFont = cellFont; >+ if (oldFont == null) oldFont = table1.getItem (0).getFont (1); >+ fontDialog.setFontList(oldFont.getFontData()); >+ FontData fontData = fontDialog.open (); >+ if (fontData == null) return; >+ oldFont = cellFont; >+ cellFont = new Font (display, fontData); >+ setCellFont (); >+ setExampleWidgetSize (); >+ if (oldFont != null) oldFont.dispose (); >+ } >+ break; >+ default: >+ super.changeFontOrColor(index); >+ } >+ } >+ >+ /** >+ * Creates the "Other" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ >+ /* Create display controls specific to this example */ >+ linesVisibleButton = new Button (otherGroup, SWT.CHECK); >+ linesVisibleButton.setText (ControlExample.getResourceString("Lines_Visible")); >+ multipleColumns = new Button (otherGroup, SWT.CHECK); >+ multipleColumns.setText (ControlExample.getResourceString("Multiple_Columns")); >+ multipleColumns.setSelection(true); >+ headerVisibleButton = new Button (otherGroup, SWT.CHECK); >+ headerVisibleButton.setText (ControlExample.getResourceString("Header_Visible")); >+ sortIndicatorButton = new Button (otherGroup, SWT.CHECK); >+ sortIndicatorButton.setText (ControlExample.getResourceString("Sort_Indicator")); >+ moveableColumns = new Button (otherGroup, SWT.CHECK); >+ moveableColumns.setText (ControlExample.getResourceString("Moveable_Columns")); >+ resizableColumns = new Button (otherGroup, SWT.CHECK); >+ resizableColumns.setText (ControlExample.getResourceString("Resizable_Columns")); >+ headerImagesButton = new Button (otherGroup, SWT.CHECK); >+ headerImagesButton.setText (ControlExample.getResourceString("Header_Images")); >+ subImagesButton = new Button (otherGroup, SWT.CHECK); >+ subImagesButton.setText (ControlExample.getResourceString("Sub_Images")); >+ >+ /* Add the listeners */ >+ linesVisibleButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetLinesVisible (); >+ } >+ }); >+ multipleColumns.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ recreateExampleWidgets (); >+ } >+ }); >+ headerVisibleButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetHeaderVisible (); >+ } >+ }); >+ sortIndicatorButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetSortIndicator (); >+ } >+ }); >+ moveableColumns.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setColumnsMoveable (); >+ } >+ }); >+ resizableColumns.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setColumnsResizable (); >+ } >+ }); >+ headerImagesButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ recreateExampleWidgets (); >+ } >+ }); >+ subImagesButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ recreateExampleWidgets (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the table */ >+ tableGroup = new Group (exampleGroup, SWT.NONE); >+ tableGroup.setLayout (new GridLayout ()); >+ tableGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ tableGroup.setText ("Table"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (singleButton.getSelection ()) style |= SWT.SINGLE; >+ if (multiButton.getSelection ()) style |= SWT.MULTI; >+ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL; >+ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL; >+ if (noScrollButton.getSelection ()) style |= SWT.NO_SCROLL; >+ if (checkButton.getSelection ()) style |= SWT.CHECK; >+ if (fullSelectionButton.getSelection ()) style |= SWT.FULL_SELECTION; >+ if (hideSelectionButton.getSelection ()) style |= SWT.HIDE_SELECTION; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ >+ /* Create the table widget */ >+ table1 = new Table (tableGroup, style); >+ >+ /* Fill the table with data */ >+ boolean multiColumn = multipleColumns.getSelection(); >+ if (multiColumn) { >+ for (int i = 0; i < columnTitles.length; i++) { >+ TableColumn tableColumn = new TableColumn(table1, SWT.NONE); >+ tableColumn.setText(columnTitles[i]); >+ tableColumn.setToolTipText(ControlExample.getResourceString("Tooltip", new String [] {columnTitles[i]})); >+ if (headerImagesButton.getSelection()) tableColumn.setImage(instance.images [i % 3]); >+ } >+ table1.setSortColumn(table1.getColumn(0)); >+ } >+ for (int i=0; i<16; i++) { >+ TableItem item = new TableItem (table1, SWT.NONE); >+ if (multiColumn && subImagesButton.getSelection()) { >+ for (int j = 0; j < columnTitles.length; j++) { >+ item.setImage(j, instance.images [i % 3]); >+ } >+ } else { >+ item.setImage(instance.images [i % 3]); >+ } >+ setItemText (item, i, ControlExample.getResourceString("Index") + i); >+ } >+ packColumns(); >+ } >+ >+ void setItemText(TableItem item, int i, String node) { >+ int index = i % 3; >+ if (multipleColumns.getSelection()) { >+ tableData [index][0] = node; >+ item.setText (tableData [index]); >+ } else { >+ item.setText (node); >+ } >+ } >+ >+ /** >+ * Creates the "Size" group. The "Size" group contains >+ * controls that allow the user to change the size of >+ * the example widgets. >+ */ >+ void createSizeGroup () { >+ super.createSizeGroup(); >+ >+ packColumnsButton = new Button (sizeGroup, SWT.PUSH); >+ packColumnsButton.setText (ControlExample.getResourceString("Pack_Columns")); >+ packColumnsButton.addSelectionListener(new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ packColumns (); >+ setExampleWidgetSize (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup () { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ noScrollButton = new Button (styleGroup, SWT.CHECK); >+ noScrollButton.setText ("SWT.NO_SCROLL"); >+ noScrollButton.moveAbove(borderButton); >+ checkButton = new Button (styleGroup, SWT.CHECK); >+ checkButton.setText ("SWT.CHECK"); >+ fullSelectionButton = new Button (styleGroup, SWT.CHECK); >+ fullSelectionButton.setText ("SWT.FULL_SELECTION"); >+ hideSelectionButton = new Button (styleGroup, SWT.CHECK); >+ hideSelectionButton.setText ("SWT.HIDE_SELECTION"); >+ } >+ >+ /** >+ * Gets the "Example" widget children's items, if any. >+ * >+ * @return an array containing the example widget children's items >+ */ >+ Item [] getExampleWidgetItems () { >+ Item [] columns = table1.getColumns(); >+ Item [] items = table1.getItems(); >+ Item [] allItems = new Item [columns.length + items.length]; >+ System.arraycopy(columns, 0, allItems, 0, columns.length); >+ System.arraycopy(items, 0, allItems, columns.length, items.length); >+ return allItems; >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {table1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"ColumnOrder", "ItemCount", "Selection", "SelectionIndex", "ToolTipText", "TopIndex"}; >+ } >+ >+ String setMethodName(String methodRoot) { >+ /* Override to handle special case of int getSelectionIndex()/setSelection(int) */ >+ return (methodRoot.equals("SelectionIndex")) ? "setSelection" : "set" + methodRoot; >+ } >+ >+ void packColumns () { >+ int columnCount = table1.getColumnCount(); >+ for (int i = 0; i < columnCount; i++) { >+ TableColumn tableColumn = table1.getColumn(i); >+ tableColumn.pack(); >+ } >+ } >+ >+ Object[] parameterForType(String typeName, String value, Widget widget) { >+ if (value.equals("")) return new Object[] {new TableItem[0]}; // bug in Table? >+ if (typeName.equals("org.eclipse.swt.widgets.TableItem")) { >+ TableItem item = findItem(value, ((Table) widget).getItems()); >+ if (item != null) return new Object[] {item}; >+ } >+ if (typeName.equals("[Lorg.eclipse.swt.widgets.TableItem;")) { >+ String[] values = split(value, ','); >+ TableItem[] items = new TableItem[values.length]; >+ for (int i = 0; i < values.length; i++) { >+ items[i] = findItem(values[i], ((Table) widget).getItems()); >+ } >+ return new Object[] {items}; >+ } >+ return super.parameterForType(typeName, value, widget); >+ } >+ >+ TableItem findItem(String value, TableItem[] items) { >+ for (int i = 0; i < items.length; i++) { >+ TableItem item = items[i]; >+ if (item.getText().equals(value)) return item; >+ } >+ return null; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Table"; >+ } >+ >+ /** >+ * Sets the foreground color, background color, and font >+ * of the "Example" widgets to their default settings. >+ * Also sets foreground and background color of TableItem [0] >+ * to default settings. >+ */ >+ void resetColorsAndFonts () { >+ super.resetColorsAndFonts (); >+ Color oldColor = itemForegroundColor; >+ itemForegroundColor = null; >+ setItemForeground (); >+ if (oldColor != null) oldColor.dispose(); >+ oldColor = itemBackgroundColor; >+ itemBackgroundColor = null; >+ setItemBackground (); >+ if (oldColor != null) oldColor.dispose(); >+ Font oldFont = font; >+ itemFont = null; >+ setItemFont (); >+ if (oldFont != null) oldFont.dispose(); >+ oldColor = cellForegroundColor; >+ cellForegroundColor = null; >+ setCellForeground (); >+ if (oldColor != null) oldColor.dispose(); >+ oldColor = cellBackgroundColor; >+ cellBackgroundColor = null; >+ setCellBackground (); >+ if (oldColor != null) oldColor.dispose(); >+ oldFont = font; >+ cellFont = null; >+ setCellFont (); >+ if (oldFont != null) oldFont.dispose(); >+ } >+ >+ /** >+ * Sets the background color of the Row 0 TableItem in column 1. >+ */ >+ void setCellBackground () { >+ if (!instance.startup) { >+ table1.getItem (0).setBackground (1, cellBackgroundColor); >+ } >+ /* Set the background color item's image to match the background color of the cell. */ >+ Color color = cellBackgroundColor; >+ if (color == null) color = table1.getItem (0).getBackground (1); >+ TableItem item = colorAndFontTable.getItem(CELL_BACKGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the foreground color of the Row 0 TableItem in column 1. >+ */ >+ void setCellForeground () { >+ if (!instance.startup) { >+ table1.getItem (0).setForeground (1, cellForegroundColor); >+ } >+ /* Set the foreground color item's image to match the foreground color of the cell. */ >+ Color color = cellForegroundColor; >+ if (color == null) color = table1.getItem (0).getForeground (1); >+ TableItem item = colorAndFontTable.getItem(CELL_FOREGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the font of the Row 0 TableItem in column 1. >+ */ >+ void setCellFont () { >+ if (!instance.startup) { >+ table1.getItem (0).setFont (1, cellFont); >+ } >+ /* Set the font item's image to match the font of the item. */ >+ Font ft = cellFont; >+ if (ft == null) ft = table1.getItem (0).getFont (1); >+ TableItem item = colorAndFontTable.getItem(CELL_FONT); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (fontImage(ft)); >+ item.setFont(ft); >+ colorAndFontTable.layout (); >+ } >+ >+ /** >+ * Sets the background color of TableItem [0]. >+ */ >+ void setItemBackground () { >+ if (!instance.startup) { >+ table1.getItem (0).setBackground (itemBackgroundColor); >+ } >+ /* Set the background color item's image to match the background color of the item. */ >+ Color color = itemBackgroundColor; >+ if (color == null) color = table1.getItem (0).getBackground (); >+ TableItem item = colorAndFontTable.getItem(ITEM_BACKGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the foreground color of TableItem [0]. >+ */ >+ void setItemForeground () { >+ if (!instance.startup) { >+ table1.getItem (0).setForeground (itemForegroundColor); >+ } >+ /* Set the foreground color item's image to match the foreground color of the item. */ >+ Color color = itemForegroundColor; >+ if (color == null) color = table1.getItem (0).getForeground (); >+ TableItem item = colorAndFontTable.getItem(ITEM_FOREGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the font of TableItem 0. >+ */ >+ void setItemFont () { >+ if (!instance.startup) { >+ table1.getItem (0).setFont (itemFont); >+ } >+ /* Set the font item's image to match the font of the item. */ >+ Font ft = itemFont; >+ if (ft == null) ft = table1.getItem (0).getFont (); >+ TableItem item = colorAndFontTable.getItem(ITEM_FONT); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (fontImage(ft)); >+ item.setFont(ft); >+ colorAndFontTable.layout (); >+ } >+ >+ /** >+ * Sets the moveable columns state of the "Example" widgets. >+ */ >+ void setColumnsMoveable () { >+ boolean selection = moveableColumns.getSelection(); >+ TableColumn[] columns = table1.getColumns(); >+ for (int i = 0; i < columns.length; i++) { >+ columns[i].setMoveable(selection); >+ } >+ } >+ >+ /** >+ * Sets the resizable columns state of the "Example" widgets. >+ */ >+ void setColumnsResizable () { >+ boolean selection = resizableColumns.getSelection(); >+ TableColumn[] columns = table1.getColumns(); >+ for (int i = 0; i < columns.length; i++) { >+ columns[i].setResizable(selection); >+ } >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ setItemBackground (); >+ setItemForeground (); >+ setItemFont (); >+ setCellBackground (); >+ setCellForeground (); >+ setCellFont (); >+ if (!instance.startup) { >+ setColumnsMoveable (); >+ setColumnsResizable (); >+ setWidgetHeaderVisible (); >+ setWidgetSortIndicator (); >+ setWidgetLinesVisible (); >+ } >+ super.setExampleWidgetState (); >+ noScrollButton.setSelection ((table1.getStyle () & SWT.NO_SCROLL) != 0); >+ checkButton.setSelection ((table1.getStyle () & SWT.CHECK) != 0); >+ fullSelectionButton.setSelection ((table1.getStyle () & SWT.FULL_SELECTION) != 0); >+ hideSelectionButton.setSelection ((table1.getStyle () & SWT.HIDE_SELECTION) != 0); >+ try { >+ TableColumn column = table1.getColumn(0); >+ moveableColumns.setSelection (column.getMoveable()); >+ resizableColumns.setSelection (column.getResizable()); >+ } catch (IllegalArgumentException ex) {} >+ headerVisibleButton.setSelection (table1.getHeaderVisible()); >+ linesVisibleButton.setSelection (table1.getLinesVisible()); >+ } >+ >+ /** >+ * Sets the header visible state of the "Example" widgets. >+ */ >+ void setWidgetHeaderVisible () { >+ table1.setHeaderVisible (headerVisibleButton.getSelection ()); >+ } >+ >+ /** >+ * Sets the sort indicator state of the "Example" widgets. >+ */ >+ void setWidgetSortIndicator () { >+ TableColumn [] columns = table1.getColumns(); >+ if (sortIndicatorButton.getSelection ()) { >+ /* Reset to known state: 'down' on column 0. */ >+ table1.setSortDirection (SWT.DOWN); >+ for (int i = 0; i < columns.length; i++) { >+ TableColumn column = columns[i]; >+ if (i == 0) table1.setSortColumn(column); >+ SelectionListener listener = new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ int sortDirection = SWT.DOWN; >+ if (e.widget == table1.getSortColumn()) { >+ /* If the sort column hasn't changed, cycle down -> up -> none. */ >+ switch (table1.getSortDirection ()) { >+ case SWT.DOWN: sortDirection = SWT.UP; break; >+ case SWT.UP: sortDirection = SWT.NONE; break; >+ } >+ } else { >+ table1.setSortColumn((TableColumn)e.widget); >+ } >+ table1.setSortDirection (sortDirection); >+ } >+ }; >+ column.addSelectionListener(listener); >+ column.setData("SortListener", listener); //$NON-NLS-1$ >+ } >+ } else { >+ table1.setSortDirection (SWT.NONE); >+ for (int j = 0; j < columns.length; j++) { >+ SelectionListener listener = (SelectionListener)columns[j].getData("SortListener"); //$NON-NLS-1$ >+ if (listener != null) columns[j].removeSelectionListener(listener); >+ } >+ } >+ } >+ >+ /** >+ * Sets the lines visible state of the "Example" widgets. >+ */ >+ void setWidgetLinesVisible () { >+ table1.setLinesVisible (linesVisibleButton.getSelection ()); >+ } >+ >+ protected void specialPopupMenuItems(Menu menu, Event event) { >+ MenuItem item = new MenuItem(menu, SWT.PUSH); >+ item.setText("getItem(Point) on mouse coordinates"); >+ menuMouseCoords = table1.toControl(new Point(event.x, event.y)); >+ item.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + table1.getItem(menuMouseCoords)); >+ eventConsole.append ("\n"); >+ } >+ }); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/TextTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/TextTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/TextTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/TextTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,190 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.*; >+ >+class TextTab extends ScrollableTab { >+ /* Example widgets and groups that contain them */ >+ Text text; >+ Group textGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button wrapButton, readOnlyButton, passwordButton, searchButton, iconCancelButton, iconSearchButton; >+ Button leftButton, centerButton, rightButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ TextTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the text widget */ >+ textGroup = new Group (exampleGroup, SWT.NONE); >+ textGroup.setLayout (new GridLayout ()); >+ textGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ textGroup.setText ("Text"); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ 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 (wrapButton.getSelection ()) style |= SWT.WRAP; >+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; >+ if (passwordButton.getSelection ()) style |= SWT.PASSWORD; >+ if (searchButton.getSelection ()) style |= SWT.SEARCH; >+ if (iconCancelButton.getSelection ()) style |= SWT.ICON_CANCEL; >+ if (iconSearchButton.getSelection ()) style |= SWT.ICON_SEARCH; >+ if (borderButton.getSelection ()) style |= SWT.BORDER; >+ if (leftButton.getSelection ()) style |= SWT.LEFT; >+ if (centerButton.getSelection ()) style |= SWT.CENTER; >+ if (rightButton.getSelection ()) style |= SWT.RIGHT; >+ >+ /* Create the example widgets */ >+ text = new Text (textGroup, style); >+ text.setText (ControlExample.getResourceString("Example_string") + Text.DELIMITER + ControlExample.getResourceString("One_Two_Three")); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup(); >+ >+ /* Create the extra widgets */ >+ wrapButton = new Button (styleGroup, SWT.CHECK); >+ wrapButton.setText ("SWT.WRAP"); >+ readOnlyButton = new Button (styleGroup, SWT.CHECK); >+ readOnlyButton.setText ("SWT.READ_ONLY"); >+ passwordButton = new Button (styleGroup, SWT.CHECK); >+ passwordButton.setText ("SWT.PASSWORD"); >+ searchButton = new Button (styleGroup, SWT.CHECK); >+ searchButton.setText ("SWT.SEARCH"); >+ iconCancelButton = new Button (styleGroup, SWT.CHECK); >+ iconCancelButton.setText ("SWT.ICON_CANCEL"); >+ iconSearchButton = new Button (styleGroup, SWT.CHECK); >+ iconSearchButton.setText ("SWT.ICON_SEARCH"); >+ >+ Composite alignmentGroup = new Composite (styleGroup, SWT.NONE); >+ GridLayout layout = new GridLayout (); >+ layout.marginWidth = layout.marginHeight = 0; >+ alignmentGroup.setLayout (layout); >+ alignmentGroup.setLayoutData (new GridData (GridData.FILL_BOTH)); >+ leftButton = new Button (alignmentGroup, SWT.RADIO); >+ leftButton.setText ("SWT.LEFT"); >+ centerButton = new Button (alignmentGroup, SWT.RADIO); >+ centerButton.setText ("SWT.CENTER"); >+ rightButton = new Button (alignmentGroup, SWT.RADIO); >+ rightButton.setText ("SWT.RIGHT"); >+ } >+ >+ /** >+ * Creates the tab folder page. >+ * >+ * @param tabFolder org.eclipse.swt.widgets.TabFolder >+ * @return the new page for the tab folder >+ */ >+ Composite createTabFolderPage (TabFolder tabFolder) { >+ super.createTabFolderPage (tabFolder); >+ >+ /* >+ * Add a resize listener to the tabFolderPage so that >+ * if the user types into the example widget to change >+ * its preferred size, and then resizes the shell, we >+ * recalculate the preferred size correctly. >+ */ >+ tabFolderPage.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) { >+ setExampleWidgetSize (); >+ } >+ }); >+ >+ return tabFolderPage; >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {text}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"DoubleClickEnabled", "EchoChar", "Editable", "Message", "Orientation", "Selection", "Tabs", "Text", "TextLimit", "ToolTipText", "TopIndex"}; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Text"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ wrapButton.setSelection ((text.getStyle () & SWT.WRAP) != 0); >+ readOnlyButton.setSelection ((text.getStyle () & SWT.READ_ONLY) != 0); >+ passwordButton.setSelection ((text.getStyle () & SWT.PASSWORD) != 0); >+ searchButton.setSelection ((text.getStyle () & SWT.SEARCH) != 0); >+ leftButton.setSelection ((text.getStyle () & SWT.LEFT) != 0); >+ centerButton.setSelection ((text.getStyle () & SWT.CENTER) != 0); >+ rightButton.setSelection ((text.getStyle () & SWT.RIGHT) != 0); >+ >+ /* Special case: ICON_CANCEL and H_SCROLL have the same value, >+ * and ICON_SEARCH and V_SCROLL have the same value, >+ * so to avoid confusion, only set CANCEL if SEARCH is set. */ >+ if ((text.getStyle () & SWT.SEARCH) != 0) { >+ iconCancelButton.setSelection ((text.getStyle () & SWT.ICON_CANCEL) != 0); >+ iconSearchButton.setSelection ((text.getStyle () & SWT.ICON_SEARCH) != 0); >+ horizontalButton.setSelection (false); >+ verticalButton.setSelection (false); >+ } else { >+ iconCancelButton.setSelection (false); >+ iconSearchButton.setSelection (false); >+ horizontalButton.setSelection ((text.getStyle () & SWT.H_SCROLL) != 0); >+ verticalButton.setSelection ((text.getStyle () & SWT.V_SCROLL) != 0); >+ } >+ >+ passwordButton.setEnabled ((text.getStyle () & SWT.SINGLE) != 0); >+ searchButton.setEnabled ((text.getStyle () & SWT.SINGLE) != 0); >+ iconCancelButton.setEnabled ((text.getStyle () & SWT.SEARCH) != 0); >+ iconSearchButton.setEnabled ((text.getStyle () & SWT.SEARCH) != 0); >+ wrapButton.setEnabled ((text.getStyle () & SWT.MULTI) != 0); >+ horizontalButton.setEnabled ((text.getStyle () & SWT.MULTI) != 0); >+ verticalButton.setEnabled ((text.getStyle () & SWT.MULTI) != 0); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ToolBarTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ToolBarTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ToolBarTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ToolBarTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,364 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+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, imageTextToolBar; >+ Group imageToolBarGroup, textToolBarGroup, imageTextToolBarGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button horizontalButton, verticalButton, flatButton, shadowOutButton, wrapButton, rightButton; >+ >+ /* Other widgets added to the "Other" group */ >+ Button comboChildButton; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ToolBarTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the image tool bar */ >+ imageToolBarGroup = new Group (exampleGroup, SWT.NONE); >+ imageToolBarGroup.setLayout (new GridLayout ()); >+ imageToolBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ imageToolBarGroup.setText (ControlExample.getResourceString("Image_ToolBar")); >+ >+ /* Create a group for the text tool bar */ >+ textToolBarGroup = new Group (exampleGroup, SWT.NONE); >+ textToolBarGroup.setLayout (new GridLayout ()); >+ textToolBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ textToolBarGroup.setText (ControlExample.getResourceString("Text_ToolBar")); >+ >+ /* Create a group for the image and text tool bar */ >+ imageTextToolBarGroup = new Group (exampleGroup, SWT.NONE); >+ imageTextToolBarGroup.setLayout (new GridLayout ()); >+ imageTextToolBarGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ imageTextToolBarGroup.setText (ControlExample.getResourceString("ImageText_ToolBar")); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (horizontalButton.getSelection()) style |= SWT.HORIZONTAL; >+ if (verticalButton.getSelection()) style |= SWT.VERTICAL; >+ if (flatButton.getSelection()) style |= SWT.FLAT; >+ if (wrapButton.getSelection()) style |= SWT.WRAP; >+ if (borderButton.getSelection()) style |= SWT.BORDER; >+ if (shadowOutButton.getSelection()) style |= SWT.SHADOW_OUT; >+ if (rightButton.getSelection()) style |= SWT.RIGHT; >+ >+ /* >+ * 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 (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText("SWT.PUSH"); >+ item = new ToolItem (imageToolBar, SWT.PUSH); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.PUSH"); >+ item = new ToolItem (imageToolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ item = new ToolItem (imageToolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciOpenFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ item = new ToolItem (imageToolBar, SWT.CHECK); >+ item.setImage (instance.images[ControlExample.ciTarget]); >+ item.setToolTipText ("SWT.CHECK"); >+ item = new ToolItem (imageToolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ item = new ToolItem (imageToolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setToolTipText ("SWT.RADIO"); >+ item = new ToolItem (imageToolBar, SWT.SEPARATOR); >+ item.setToolTipText("SWT.SEPARATOR"); >+ if (comboChildButton.getSelection ()) { >+ Combo combo = new Combo (imageToolBar, SWT.NONE); >+ combo.setItems (new String [] {"250", "500", "750"}); >+ combo.setText (combo.getItem (0)); >+ combo.pack (); >+ item.setWidth (combo.getSize ().x); >+ item.setControl (combo); >+ } >+ item = new ToolItem (imageToolBar, SWT.DROP_DOWN); >+ item.setImage (instance.images[ControlExample.ciTarget]); >+ item.setToolTipText ("SWT.DROP_DOWN"); >+ item.addSelectionListener(new DropDownSelectionListener()); >+ >+ /* Create the text tool bar */ >+ textToolBar = new ToolBar (textToolBarGroup, style); >+ item = new ToolItem (textToolBar, SWT.PUSH); >+ item.setText (ControlExample.getResourceString("Push")); >+ item.setToolTipText("SWT.PUSH"); >+ item = new ToolItem (textToolBar, SWT.PUSH); >+ item.setText (ControlExample.getResourceString("Push")); >+ item.setToolTipText("SWT.PUSH"); >+ item = new ToolItem (textToolBar, SWT.RADIO); >+ item.setText (ControlExample.getResourceString("Radio")); >+ item.setToolTipText("SWT.RADIO"); >+ item = new ToolItem (textToolBar, SWT.RADIO); >+ item.setText (ControlExample.getResourceString("Radio")); >+ item.setToolTipText("SWT.RADIO"); >+ item = new ToolItem (textToolBar, SWT.CHECK); >+ item.setText (ControlExample.getResourceString("Check")); >+ item.setToolTipText("SWT.CHECK"); >+ item = new ToolItem (textToolBar, SWT.RADIO); >+ item.setText (ControlExample.getResourceString("Radio")); >+ item.setToolTipText("SWT.RADIO"); >+ item = new ToolItem (textToolBar, SWT.RADIO); >+ item.setText (ControlExample.getResourceString("Radio")); >+ item.setToolTipText("SWT.RADIO"); >+ item = new ToolItem (textToolBar, SWT.SEPARATOR); >+ item.setToolTipText("SWT.SEPARATOR"); >+ if (comboChildButton.getSelection ()) { >+ Combo combo = new Combo (textToolBar, SWT.NONE); >+ combo.setItems (new String [] {"250", "500", "750"}); >+ combo.setText (combo.getItem (0)); >+ combo.pack (); >+ item.setWidth (combo.getSize ().x); >+ item.setControl (combo); >+ } >+ item = new ToolItem (textToolBar, SWT.DROP_DOWN); >+ item.setText (ControlExample.getResourceString("Drop_Down")); >+ item.setToolTipText("SWT.DROP_DOWN"); >+ item.addSelectionListener(new DropDownSelectionListener()); >+ >+ /* Create the image and text tool bar */ >+ imageTextToolBar = new ToolBar (imageTextToolBarGroup, style); >+ item = new ToolItem (imageTextToolBar, SWT.PUSH); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setText (ControlExample.getResourceString("Push")); >+ item.setToolTipText("SWT.PUSH"); >+ item = new ToolItem (imageTextToolBar, SWT.PUSH); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setText (ControlExample.getResourceString("Push")); >+ item.setToolTipText("SWT.PUSH"); >+ item = new ToolItem (imageTextToolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciOpenFolder]); >+ item.setText (ControlExample.getResourceString("Radio")); >+ item.setToolTipText("SWT.RADIO"); >+ item = new ToolItem (imageTextToolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciOpenFolder]); >+ item.setText (ControlExample.getResourceString("Radio")); >+ item.setToolTipText("SWT.RADIO"); >+ item = new ToolItem (imageTextToolBar, SWT.CHECK); >+ item.setImage (instance.images[ControlExample.ciTarget]); >+ item.setText (ControlExample.getResourceString("Check")); >+ item.setToolTipText("SWT.CHECK"); >+ item = new ToolItem (imageTextToolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setText (ControlExample.getResourceString("Radio")); >+ item.setToolTipText("SWT.RADIO"); >+ item = new ToolItem (imageTextToolBar, SWT.RADIO); >+ item.setImage (instance.images[ControlExample.ciClosedFolder]); >+ item.setText (ControlExample.getResourceString("Radio")); >+ item.setToolTipText("SWT.RADIO"); >+ item = new ToolItem (imageTextToolBar, SWT.SEPARATOR); >+ item.setToolTipText("SWT.SEPARATOR"); >+ if (comboChildButton.getSelection ()) { >+ Combo combo = new Combo (imageTextToolBar, SWT.NONE); >+ combo.setItems (new String [] {"250", "500", "750"}); >+ combo.setText (combo.getItem (0)); >+ combo.pack (); >+ item.setWidth (combo.getSize ().x); >+ item.setControl (combo); >+ } >+ item = new ToolItem (imageTextToolBar, SWT.DROP_DOWN); >+ item.setImage (instance.images[ControlExample.ciTarget]); >+ item.setText (ControlExample.getResourceString("Drop_Down")); >+ item.setToolTipText("SWT.DROP_DOWN"); >+ item.addSelectionListener(new DropDownSelectionListener()); >+ >+ /* >+ * 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 "Other" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ >+ /* Create display controls specific to this example */ >+ comboChildButton = new Button (otherGroup, SWT.CHECK); >+ comboChildButton.setText (ControlExample.getResourceString("Combo_child")); >+ >+ /* Add the listeners */ >+ comboChildButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ recreateExampleWidgets (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup(); >+ >+ /* Create the extra widgets */ >+ horizontalButton = new Button (styleGroup, SWT.RADIO); >+ horizontalButton.setText ("SWT.HORIZONTAL"); >+ verticalButton = new Button (styleGroup, SWT.RADIO); >+ verticalButton.setText ("SWT.VERTICAL"); >+ flatButton = new Button (styleGroup, SWT.CHECK); >+ flatButton.setText ("SWT.FLAT"); >+ shadowOutButton = new Button (styleGroup, SWT.CHECK); >+ shadowOutButton.setText ("SWT.SHADOW_OUT"); >+ wrapButton = new Button (styleGroup, SWT.CHECK); >+ wrapButton.setText ("SWT.WRAP"); >+ rightButton = new Button (styleGroup, SWT.CHECK); >+ rightButton.setText ("SWT.RIGHT"); >+ borderButton = new Button (styleGroup, SWT.CHECK); >+ borderButton.setText ("SWT.BORDER"); >+ } >+ >+ void disposeExampleWidgets () { >+ super.disposeExampleWidgets (); >+ } >+ >+ /** >+ * Gets the "Example" widget children's items, if any. >+ * >+ * @return an array containing the example widget children's items >+ */ >+ Item [] getExampleWidgetItems () { >+ Item [] imageToolBarItems = imageToolBar.getItems(); >+ Item [] textToolBarItems = textToolBar.getItems(); >+ Item [] imageTextToolBarItems = imageTextToolBar.getItems(); >+ Item [] allItems = new Item [imageToolBarItems.length + textToolBarItems.length + imageTextToolBarItems.length]; >+ System.arraycopy(imageToolBarItems, 0, allItems, 0, imageToolBarItems.length); >+ System.arraycopy(textToolBarItems, 0, allItems, imageToolBarItems.length, textToolBarItems.length); >+ System.arraycopy(imageTextToolBarItems, 0, allItems, imageToolBarItems.length + textToolBarItems.length, imageTextToolBarItems.length); >+ return allItems; >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {imageToolBar, textToolBar, imageTextToolBar}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"ToolTipText"}; >+ } >+ >+ /** >+ * Gets the short text for the tab folder item. >+ */ >+ String getShortTabText() { >+ return "TB"; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "ToolBar"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ super.setExampleWidgetState (); >+ horizontalButton.setSelection ((imageToolBar.getStyle () & SWT.HORIZONTAL) != 0); >+ verticalButton.setSelection ((imageToolBar.getStyle () & SWT.VERTICAL) != 0); >+ flatButton.setSelection ((imageToolBar.getStyle () & SWT.FLAT) != 0); >+ wrapButton.setSelection ((imageToolBar.getStyle () & SWT.WRAP) != 0); >+ shadowOutButton.setSelection ((imageToolBar.getStyle () & SWT.SHADOW_OUT) != 0); >+ borderButton.setSelection ((imageToolBar.getStyle () & SWT.BORDER) != 0); >+ rightButton.setSelection ((imageToolBar.getStyle () & SWT.RIGHT) != 0); >+ } >+ >+ /** >+ * Listens to widgetSelected() events on SWT.DROP_DOWN type ToolItems >+ * and opens/closes a menu when appropriate. >+ */ >+ class DropDownSelectionListener extends SelectionAdapter { >+ private Menu menu = null; >+ >+ public void widgetSelected(SelectionEvent event) { >+ // Create the menu if it has not already been created >+ if (menu == null) { >+ // Lazy create the menu. >+ ToolBar toolbar = ((ToolItem) event.widget).getParent(); >+ int style = toolbar.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT); >+ menu = new Menu(shell, style | SWT.POP_UP); >+ for (int i = 0; i < 9; ++i) { >+ final String text = ControlExample.getResourceString("DropDownData_" + i); >+ if (text.length() != 0) { >+ MenuItem menuItem = new MenuItem(menu, SWT.NONE); >+ menuItem.setText(text); >+ } else { >+ new MenuItem(menu, SWT.SEPARATOR); >+ } >+ } >+ } >+ >+ /** >+ * 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 menu below and vertically aligned with the the drop down tool button. >+ final ToolItem toolItem = (ToolItem) event.widget; >+ final ToolBar toolBar = toolItem.getParent(); >+ >+ Point point = toolBar.toDisplay(new Point(event.x, event.y)); >+ menu.setLocation(point.x, point.y); >+ menu.setVisible(true); >+ } >+ } >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/ToolTipTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/ToolTipTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/ToolTipTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/ToolTipTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,260 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.*; >+ >+class ToolTipTab extends Tab { >+ >+ /* Example widgets and groups that contain them */ >+ ToolTip toolTip1; >+ Group toolTipGroup; >+ >+ /* Style widgets added to the "Style" group */ >+ Button balloonButton, iconErrorButton, iconInformationButton, iconWarningButton, noIconButton; >+ >+ /* Other widgets added to the "Other" group */ >+ Button autoHideButton, showInTrayButton; >+ >+ Tray tray; >+ TrayItem trayItem; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ ToolTipTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the tooltip visibility check box */ >+ toolTipGroup = new Group (exampleGroup, SWT.NONE); >+ toolTipGroup.setLayout (new GridLayout ()); >+ toolTipGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ toolTipGroup.setText ("ToolTip"); >+ visibleButton = new Button(toolTipGroup, SWT.CHECK); >+ visibleButton.setText(ControlExample.getResourceString("Visible")); >+ visibleButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleWidgetVisibility (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ if (balloonButton.getSelection ()) style |= SWT.BALLOON; >+ if (iconErrorButton.getSelection ()) style |= SWT.ICON_ERROR; >+ if (iconInformationButton.getSelection ()) style |= SWT.ICON_INFORMATION; >+ if (iconWarningButton.getSelection ()) style |= SWT.ICON_WARNING; >+ >+ /* Create the example widgets */ >+ toolTip1 = new ToolTip (shell, style); >+ toolTip1.setText(ControlExample.getResourceString("ToolTip_Title")); >+ toolTip1.setMessage(ControlExample.getResourceString("Example_string")); >+ } >+ >+ /** >+ * Creates the tab folder page. >+ * >+ * @param tabFolder org.eclipse.swt.widgets.TabFolder >+ * @return the new page for the tab folder >+ */ >+ Composite createTabFolderPage (TabFolder tabFolder) { >+ super.createTabFolderPage (tabFolder); >+ >+ /* >+ * Add a resize listener to the tabFolderPage so that >+ * if the user types into the example widget to change >+ * its preferred size, and then resizes the shell, we >+ * recalculate the preferred size correctly. >+ */ >+ tabFolderPage.addControlListener(new ControlAdapter() { >+ public void controlResized(ControlEvent e) { >+ setExampleWidgetSize (); >+ } >+ }); >+ >+ return tabFolderPage; >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup () { >+ super.createStyleGroup (); >+ >+ /* Create the extra widgets */ >+ balloonButton = new Button (styleGroup, SWT.CHECK); >+ balloonButton.setText ("SWT.BALLOON"); >+ iconErrorButton = new Button (styleGroup, SWT.RADIO); >+ iconErrorButton.setText("SWT.ICON_ERROR"); >+ iconInformationButton = new Button (styleGroup, SWT.RADIO); >+ iconInformationButton.setText("SWT.ICON_INFORMATION"); >+ iconWarningButton = new Button (styleGroup, SWT.RADIO); >+ iconWarningButton.setText("SWT.ICON_WARNING"); >+ noIconButton = new Button (styleGroup, SWT.RADIO); >+ noIconButton.setText(ControlExample.getResourceString("No_Icon")); >+ } >+ >+ void createColorAndFontGroup () { >+ // ToolTip does not need a color and font group. >+ } >+ >+ void createOtherGroup () { >+ /* Create the group */ >+ otherGroup = new Group (controlGroup, SWT.NONE); >+ otherGroup.setLayout (new GridLayout ()); >+ otherGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); >+ otherGroup.setText (ControlExample.getResourceString("Other")); >+ >+ /* Create the controls */ >+ autoHideButton = new Button(otherGroup, SWT.CHECK); >+ autoHideButton.setText(ControlExample.getResourceString("AutoHide")); >+ showInTrayButton = new Button(otherGroup, SWT.CHECK); >+ showInTrayButton.setText(ControlExample.getResourceString("Show_In_Tray")); >+ tray = display.getSystemTray(); >+ showInTrayButton.setEnabled(tray != null); >+ >+ /* Add the listeners */ >+ autoHideButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setExampleWidgetAutoHide (); >+ } >+ }); >+ showInTrayButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ showExampleWidgetInTray (); >+ } >+ }); >+ shell.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent event) { >+ disposeTrayItem(); >+ } >+ }); >+ >+ /* Set the default state */ >+ autoHideButton.setSelection(true); >+ } >+ >+ void createSizeGroup () { >+ // ToolTip does not need a size group. >+ } >+ >+ void createBackgroundModeGroup () { >+ // ToolTip does not need a background mode group. >+ } >+ >+ /** >+ * Disposes the "Example" widgets. >+ */ >+ void disposeExampleWidgets () { >+ disposeTrayItem(); >+ super.disposeExampleWidgets(); >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ // Tab uses this for many things - widgets would only get set/get, listeners, and dispose. >+ Widget[] getExampleWidgets () { >+ return new Widget [] {toolTip1}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"Message", "Text"}; >+ } >+ >+ /** >+ * Gets the short text for the tab folder item. >+ */ >+ String getShortTabText() { >+ return "TT"; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "ToolTip"; >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ showExampleWidgetInTray (); >+ setExampleWidgetAutoHide (); >+ super.setExampleWidgetState (); >+ balloonButton.setSelection ((toolTip1.getStyle () & SWT.BALLOON) != 0); >+ iconErrorButton.setSelection ((toolTip1.getStyle () & SWT.ICON_ERROR) != 0); >+ iconInformationButton.setSelection ((toolTip1.getStyle () & SWT.ICON_INFORMATION) != 0); >+ iconWarningButton.setSelection ((toolTip1.getStyle () & SWT.ICON_WARNING) != 0); >+ noIconButton.setSelection ((toolTip1.getStyle () & (SWT.ICON_ERROR | SWT.ICON_INFORMATION | SWT.ICON_WARNING)) == 0); >+ autoHideButton.setSelection(toolTip1.getAutoHide()); >+ } >+ >+ /** >+ * Sets the visibility of the "Example" widgets. >+ */ >+ void setExampleWidgetVisibility () { >+ toolTip1.setVisible (visibleButton.getSelection ()); >+ } >+ >+ /** >+ * Sets the autoHide state of the "Example" widgets. >+ */ >+ void setExampleWidgetAutoHide () { >+ toolTip1.setAutoHide(autoHideButton.getSelection ()); >+ } >+ >+ void showExampleWidgetInTray () { >+ if (showInTrayButton.getSelection ()) { >+ createTrayItem(); >+ trayItem.setToolTip(toolTip1); >+ } else { >+ disposeTrayItem(); >+ } >+ } >+ >+ void createTrayItem() { >+ if (trayItem == null) { >+ trayItem = new TrayItem(tray, SWT.NONE); >+ trayItem.setImage(instance.images[ControlExample.ciTarget]); >+ } >+ } >+ >+ void disposeTrayItem() { >+ if (trayItem != null) { >+ trayItem.setToolTip(null); >+ trayItem.dispose(); >+ trayItem = null; >+ } >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/TreeTab.java >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/TreeTab.java >diff -N src/org/eclipse/swt/examples/mirroringTest/TreeTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/TreeTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,783 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.examples.mirroringTest; >+ >+ >+import org.eclipse.swt.*; >+import org.eclipse.swt.layout.*; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.events.*; >+ >+class TreeTab extends ScrollableTab { >+ /* Example widgets and groups that contain them */ >+ Tree tree1, tree2; >+ TreeItem textNode1, imageNode1; >+ Group treeGroup, imageTreeGroup, itemGroup; >+ >+ /* Size widgets added to the "Size" group */ >+ Button packColumnsButton; >+ >+ /* Style widgets added to the "Style" group */ >+ Button noScrollButton, checkButton, fullSelectionButton; >+ >+ /* Other widgets added to the "Other" group */ >+ Button multipleColumns, moveableColumns, resizableColumns, headerVisibleButton, sortIndicatorButton, headerImagesButton, subImagesButton, linesVisibleButton; >+ >+ /* Controls and resources added to the "Colors and Fonts" group */ >+ static final int ITEM_FOREGROUND_COLOR = 3; >+ static final int ITEM_BACKGROUND_COLOR = 4; >+ static final int ITEM_FONT = 5; >+ static final int CELL_FOREGROUND_COLOR = 6; >+ static final int CELL_BACKGROUND_COLOR = 7; >+ static final int CELL_FONT = 8; >+ Color itemForegroundColor, itemBackgroundColor, cellForegroundColor, cellBackgroundColor; >+ Font itemFont, cellFont; >+ >+ static String [] columnTitles = {ControlExample.getResourceString("TableTitle_0"), >+ ControlExample.getResourceString("TableTitle_1"), >+ ControlExample.getResourceString("TableTitle_2"), >+ ControlExample.getResourceString("TableTitle_3")}; >+ >+ static String[][] tableData = { >+ { ControlExample.getResourceString("TableLine0_0"), >+ ControlExample.getResourceString("TableLine0_1"), >+ ControlExample.getResourceString("TableLine0_2"), >+ ControlExample.getResourceString("TableLine0_3") }, >+ { ControlExample.getResourceString("TableLine1_0"), >+ ControlExample.getResourceString("TableLine1_1"), >+ ControlExample.getResourceString("TableLine1_2"), >+ ControlExample.getResourceString("TableLine1_3") }, >+ { ControlExample.getResourceString("TableLine2_0"), >+ ControlExample.getResourceString("TableLine2_1"), >+ ControlExample.getResourceString("TableLine2_2"), >+ ControlExample.getResourceString("TableLine2_3") } }; >+ >+ Point menuMouseCoords; >+ >+ /** >+ * Creates the Tab within a given instance of ControlExample. >+ */ >+ TreeTab(ControlExample instance) { >+ super(instance); >+ } >+ >+ /** >+ * Creates the "Colors and Fonts" group. >+ */ >+ void createColorAndFontGroup () { >+ super.createColorAndFontGroup(); >+ >+ TableItem item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Item_Foreground_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Item_Background_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Item_Font")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Cell_Foreground_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Cell_Background_Color")); >+ item = new TableItem(colorAndFontTable, SWT.None); >+ item.setText(ControlExample.getResourceString ("Cell_Font")); >+ >+ shell.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent event) { >+ if (itemBackgroundColor != null) itemBackgroundColor.dispose(); >+ if (itemForegroundColor != null) itemForegroundColor.dispose(); >+ if (itemFont != null) itemFont.dispose(); >+ if (cellBackgroundColor != null) cellBackgroundColor.dispose(); >+ if (cellForegroundColor != null) cellForegroundColor.dispose(); >+ if (cellFont != null) cellFont.dispose(); >+ itemBackgroundColor = null; >+ itemForegroundColor = null; >+ itemFont = null; >+ cellBackgroundColor = null; >+ cellForegroundColor = null; >+ cellFont = null; >+ } >+ }); >+ } >+ >+ void changeFontOrColor(int index) { >+ switch (index) { >+ case ITEM_FOREGROUND_COLOR: { >+ Color oldColor = itemForegroundColor; >+ if (oldColor == null) oldColor = textNode1.getForeground (); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = itemForegroundColor; >+ itemForegroundColor = new Color (display, rgb); >+ setItemForeground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case ITEM_BACKGROUND_COLOR: { >+ Color oldColor = itemBackgroundColor; >+ if (oldColor == null) oldColor = textNode1.getBackground (); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = itemBackgroundColor; >+ itemBackgroundColor = new Color (display, rgb); >+ setItemBackground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case ITEM_FONT: { >+ Font oldFont = itemFont; >+ if (oldFont == null) oldFont = textNode1.getFont (); >+ fontDialog.setFontList(oldFont.getFontData()); >+ FontData fontData = fontDialog.open (); >+ if (fontData == null) return; >+ oldFont = itemFont; >+ itemFont = new Font (display, fontData); >+ setItemFont (); >+ setExampleWidgetSize (); >+ if (oldFont != null) oldFont.dispose (); >+ } >+ break; >+ case CELL_FOREGROUND_COLOR: { >+ Color oldColor = cellForegroundColor; >+ if (oldColor == null) oldColor = textNode1.getForeground (1); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = cellForegroundColor; >+ cellForegroundColor = new Color (display, rgb); >+ setCellForeground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case CELL_BACKGROUND_COLOR: { >+ Color oldColor = cellBackgroundColor; >+ if (oldColor == null) oldColor = textNode1.getBackground (1); >+ colorDialog.setRGB(oldColor.getRGB()); >+ RGB rgb = colorDialog.open(); >+ if (rgb == null) return; >+ oldColor = cellBackgroundColor; >+ cellBackgroundColor = new Color (display, rgb); >+ setCellBackground (); >+ if (oldColor != null) oldColor.dispose (); >+ } >+ break; >+ case CELL_FONT: { >+ Font oldFont = cellFont; >+ if (oldFont == null) oldFont = textNode1.getFont (1); >+ fontDialog.setFontList(oldFont.getFontData()); >+ FontData fontData = fontDialog.open (); >+ if (fontData == null) return; >+ oldFont = cellFont; >+ cellFont = new Font (display, fontData); >+ setCellFont (); >+ setExampleWidgetSize (); >+ if (oldFont != null) oldFont.dispose (); >+ } >+ break; >+ default: >+ super.changeFontOrColor(index); >+ } >+ } >+ >+ /** >+ * Creates the "Other" group. >+ */ >+ void createOtherGroup () { >+ super.createOtherGroup (); >+ >+ /* Create display controls specific to this example */ >+ linesVisibleButton = new Button (otherGroup, SWT.CHECK); >+ linesVisibleButton.setText (ControlExample.getResourceString("Lines_Visible")); >+ multipleColumns = new Button (otherGroup, SWT.CHECK); >+ multipleColumns.setText (ControlExample.getResourceString("Multiple_Columns")); >+ headerVisibleButton = new Button (otherGroup, SWT.CHECK); >+ headerVisibleButton.setText (ControlExample.getResourceString("Header_Visible")); >+ sortIndicatorButton = new Button (otherGroup, SWT.CHECK); >+ sortIndicatorButton.setText (ControlExample.getResourceString("Sort_Indicator")); >+ moveableColumns = new Button (otherGroup, SWT.CHECK); >+ moveableColumns.setText (ControlExample.getResourceString("Moveable_Columns")); >+ resizableColumns = new Button (otherGroup, SWT.CHECK); >+ resizableColumns.setText (ControlExample.getResourceString("Resizable_Columns")); >+ headerImagesButton = new Button (otherGroup, SWT.CHECK); >+ headerImagesButton.setText (ControlExample.getResourceString("Header_Images")); >+ subImagesButton = new Button (otherGroup, SWT.CHECK); >+ subImagesButton.setText (ControlExample.getResourceString("Sub_Images")); >+ >+ /* Add the listeners */ >+ linesVisibleButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetLinesVisible (); >+ } >+ }); >+ multipleColumns.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ recreateExampleWidgets (); >+ } >+ }); >+ headerVisibleButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetHeaderVisible (); >+ } >+ }); >+ sortIndicatorButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setWidgetSortIndicator (); >+ } >+ }); >+ moveableColumns.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setColumnsMoveable (); >+ } >+ }); >+ resizableColumns.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ setColumnsResizable (); >+ } >+ }); >+ headerImagesButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ recreateExampleWidgets (); >+ } >+ }); >+ subImagesButton.addSelectionListener (new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ recreateExampleWidgets (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Example" group. >+ */ >+ void createExampleGroup () { >+ super.createExampleGroup (); >+ >+ /* Create a group for the text tree */ >+ treeGroup = new Group (exampleGroup, SWT.NONE); >+ treeGroup.setLayout (new GridLayout ()); >+ treeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ treeGroup.setText ("Tree"); >+ >+ /* Create a group for the image tree */ >+ imageTreeGroup = new Group (exampleGroup, SWT.NONE); >+ imageTreeGroup.setLayout (new GridLayout ()); >+ imageTreeGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); >+ imageTreeGroup.setText (ControlExample.getResourceString("Tree_With_Images")); >+ } >+ >+ /** >+ * Creates the "Example" widgets. >+ */ >+ void createExampleWidgets () { >+ /* Compute the widget style */ >+ int style = getDefaultStyle(); >+ 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 (noScrollButton.getSelection()) style |= SWT.NO_SCROLL; >+ if (checkButton.getSelection()) style |= SWT.CHECK; >+ if (fullSelectionButton.getSelection ()) style |= SWT.FULL_SELECTION; >+ if (borderButton.getSelection()) style |= SWT.BORDER; >+ >+ /* Create the text tree */ >+ tree1 = new Tree (treeGroup, style); >+ boolean multiColumn = multipleColumns.getSelection(); >+ if (multiColumn) { >+ for (int i = 0; i < columnTitles.length; i++) { >+ TreeColumn treeColumn = new TreeColumn(tree1, SWT.NONE); >+ treeColumn.setText(columnTitles[i]); >+ treeColumn.setToolTipText(ControlExample.getResourceString("Tooltip", new String [] {columnTitles[i]})); >+ } >+ tree1.setSortColumn(tree1.getColumn(0)); >+ } >+ for (int i = 0; i < 4; i++) { >+ TreeItem item = new TreeItem (tree1, SWT.NONE); >+ setItemText(item, i, ControlExample.getResourceString("Node_" + (i + 1))); >+ if (i < 3) { >+ TreeItem subitem = new TreeItem (item, SWT.NONE); >+ setItemText(subitem, i, ControlExample.getResourceString("Node_" + (i + 1) + "_1")); >+ } >+ } >+ TreeItem treeRoots[] = tree1.getItems (); >+ TreeItem item = new TreeItem (treeRoots[1], SWT.NONE); >+ setItemText(item, 1, ControlExample.getResourceString("Node_2_2")); >+ item = new TreeItem (item, SWT.NONE); >+ setItemText(item, 1, ControlExample.getResourceString("Node_2_2_1")); >+ textNode1 = treeRoots[0]; >+ packColumns(tree1); >+ try { >+ TreeColumn column = tree1.getColumn(0); >+ resizableColumns.setSelection (column.getResizable()); >+ } catch (IllegalArgumentException ex) {} >+ >+ /* Create the image tree */ >+ tree2 = new Tree (imageTreeGroup, style); >+ Image image = instance.images[ControlExample.ciClosedFolder]; >+ if (multiColumn) { >+ for (int i = 0; i < columnTitles.length; i++) { >+ TreeColumn treeColumn = new TreeColumn(tree2, SWT.NONE); >+ treeColumn.setText(columnTitles[i]); >+ treeColumn.setToolTipText(ControlExample.getResourceString("Tooltip", new String [] {columnTitles[i]})); >+ if (headerImagesButton.getSelection()) treeColumn.setImage(instance.images [i % 3]); >+ } >+ } >+ for (int i = 0; i < 4; i++) { >+ item = new TreeItem (tree2, SWT.NONE); >+ setItemText(item, i, ControlExample.getResourceString("Node_" + (i + 1))); >+ if (multiColumn && subImagesButton.getSelection()) { >+ for (int j = 0; j < columnTitles.length; j++) { >+ item.setImage(j, image); >+ } >+ } else { >+ item.setImage(image); >+ } >+ if (i < 3) { >+ TreeItem subitem = new TreeItem (item, SWT.NONE); >+ setItemText(subitem, i, ControlExample.getResourceString("Node_" + (i + 1) + "_1")); >+ if (multiColumn && subImagesButton.getSelection()) { >+ for (int j = 0; j < columnTitles.length; j++) { >+ subitem.setImage(j, image); >+ } >+ } else { >+ subitem.setImage(image); >+ } >+ } >+ } >+ treeRoots = tree2.getItems (); >+ item = new TreeItem (treeRoots[1], SWT.NONE); >+ setItemText(item, 1, ControlExample.getResourceString("Node_2_2")); >+ if (multiColumn && subImagesButton.getSelection()) { >+ for (int j = 0; j < columnTitles.length; j++) { >+ item.setImage(j, image); >+ } >+ } else { >+ item.setImage(image); >+ } >+ item = new TreeItem (item, SWT.NONE); >+ setItemText(item, 1, ControlExample.getResourceString("Node_2_2_1")); >+ if (multiColumn && subImagesButton.getSelection()) { >+ for (int j = 0; j < columnTitles.length; j++) { >+ item.setImage(j, image); >+ } >+ } else { >+ item.setImage(image); >+ } >+ imageNode1 = treeRoots[0]; >+ packColumns(tree2); >+ } >+ >+ void setItemText(TreeItem item, int i, String node) { >+ int index = i % 3; >+ if (multipleColumns.getSelection()) { >+ tableData [index][0] = node; >+ item.setText (tableData [index]); >+ } else { >+ item.setText (node); >+ } >+ } >+ >+ /** >+ * Creates the "Size" group. The "Size" group contains >+ * controls that allow the user to change the size of >+ * the example widgets. >+ */ >+ void createSizeGroup () { >+ super.createSizeGroup(); >+ >+ packColumnsButton = new Button (sizeGroup, SWT.PUSH); >+ packColumnsButton.setText (ControlExample.getResourceString("Pack_Columns")); >+ packColumnsButton.addSelectionListener(new SelectionAdapter () { >+ public void widgetSelected (SelectionEvent event) { >+ packColumns (tree1); >+ packColumns (tree2); >+ setExampleWidgetSize (); >+ } >+ }); >+ } >+ >+ /** >+ * Creates the "Style" group. >+ */ >+ void createStyleGroup() { >+ super.createStyleGroup(); >+ >+ /* Create the extra widgets */ >+ noScrollButton = new Button (styleGroup, SWT.CHECK); >+ noScrollButton.setText ("SWT.NO_SCROLL"); >+ noScrollButton.moveAbove(borderButton); >+ checkButton = new Button (styleGroup, SWT.CHECK); >+ checkButton.setText ("SWT.CHECK"); >+ fullSelectionButton = new Button (styleGroup, SWT.CHECK); >+ fullSelectionButton.setText ("SWT.FULL_SELECTION"); >+ } >+ >+ /** >+ * Gets the "Example" widget children's items, if any. >+ * >+ * @return an array containing the example widget children's items >+ */ >+ Item [] getExampleWidgetItems () { >+ /* Note: We do not bother collecting the tree items >+ * because tree items don't have any events. If events >+ * are ever added to TreeItem, then this needs to change. >+ */ >+ Item [] columns1 = tree1.getColumns(); >+ Item [] columns2 = tree2.getColumns(); >+ Item [] allItems = new Item [columns1.length + columns2.length]; >+ System.arraycopy(columns1, 0, allItems, 0, columns1.length); >+ System.arraycopy(columns2, 0, allItems, columns1.length, columns2.length); >+ return allItems; >+ } >+ >+ /** >+ * Gets the "Example" widget children. >+ */ >+ Widget [] getExampleWidgets () { >+ return new Widget [] {tree1, tree2}; >+ } >+ >+ /** >+ * Returns a list of set/get API method names (without the set/get prefix) >+ * that can be used to set/get values in the example control(s). >+ */ >+ String[] getMethodNames() { >+ return new String[] {"ColumnOrder", "Selection", "ToolTipText", "TopItem"}; >+ } >+ >+ Object[] parameterForType(String typeName, String value, Widget widget) { >+ if (typeName.equals("org.eclipse.swt.widgets.TreeItem")) { >+ TreeItem item = findItem(value, ((Tree) widget).getItems()); >+ if (item != null) return new Object[] {item}; >+ } >+ if (typeName.equals("[Lorg.eclipse.swt.widgets.TreeItem;")) { >+ String[] values = split(value, ','); >+ TreeItem[] items = new TreeItem[values.length]; >+ for (int i = 0; i < values.length; i++) { >+ TreeItem item = findItem(values[i], ((Tree) widget).getItems()); >+ if (item == null) break; >+ items[i] = item; >+ } >+ return new Object[] {items}; >+ } >+ return super.parameterForType(typeName, value, widget); >+ } >+ >+ TreeItem findItem(String value, TreeItem[] items) { >+ for (int i = 0; i < items.length; i++) { >+ TreeItem item = items[i]; >+ if (item.getText().equals(value)) return item; >+ item = findItem(value, item.getItems()); >+ if (item != null) return item; >+ } >+ return null; >+ } >+ >+ /** >+ * Gets the text for the tab folder item. >+ */ >+ String getTabText () { >+ return "Tree"; >+ } >+ >+ void packColumns (Tree tree) { >+ if (multipleColumns.getSelection()) { >+ int columnCount = tree.getColumnCount(); >+ for (int i = 0; i < columnCount; i++) { >+ TreeColumn treeColumn = tree.getColumn(i); >+ treeColumn.pack(); >+ } >+ } >+ } >+ >+ /** >+ * Sets the moveable columns state of the "Example" widgets. >+ */ >+ void setColumnsMoveable () { >+ boolean selection = moveableColumns.getSelection(); >+ TreeColumn[] columns1 = tree1.getColumns(); >+ for (int i = 0; i < columns1.length; i++) { >+ columns1[i].setMoveable(selection); >+ } >+ TreeColumn[] columns2 = tree2.getColumns(); >+ for (int i = 0; i < columns2.length; i++) { >+ columns2[i].setMoveable(selection); >+ } >+ } >+ >+ /** >+ * Sets the resizable columns state of the "Example" widgets. >+ */ >+ void setColumnsResizable () { >+ boolean selection = resizableColumns.getSelection(); >+ TreeColumn[] columns1 = tree1.getColumns(); >+ for (int i = 0; i < columns1.length; i++) { >+ columns1[i].setResizable(selection); >+ } >+ TreeColumn[] columns2 = tree2.getColumns(); >+ for (int i = 0; i < columns2.length; i++) { >+ columns2[i].setResizable(selection); >+ } >+ } >+ >+ /** >+ * Sets the foreground color, background color, and font >+ * of the "Example" widgets to their default settings. >+ * Also sets foreground and background color of the Node 1 >+ * TreeItems to default settings. >+ */ >+ void resetColorsAndFonts () { >+ super.resetColorsAndFonts (); >+ Color oldColor = itemForegroundColor; >+ itemForegroundColor = null; >+ setItemForeground (); >+ if (oldColor != null) oldColor.dispose(); >+ oldColor = itemBackgroundColor; >+ itemBackgroundColor = null; >+ setItemBackground (); >+ if (oldColor != null) oldColor.dispose(); >+ Font oldFont = font; >+ itemFont = null; >+ setItemFont (); >+ if (oldFont != null) oldFont.dispose(); >+ oldColor = cellForegroundColor; >+ cellForegroundColor = null; >+ setCellForeground (); >+ if (oldColor != null) oldColor.dispose(); >+ oldColor = cellBackgroundColor; >+ cellBackgroundColor = null; >+ setCellBackground (); >+ if (oldColor != null) oldColor.dispose(); >+ oldFont = font; >+ cellFont = null; >+ setCellFont (); >+ if (oldFont != null) oldFont.dispose(); >+ } >+ >+ /** >+ * Sets the state of the "Example" widgets. >+ */ >+ void setExampleWidgetState () { >+ setItemBackground (); >+ setItemForeground (); >+ setItemFont (); >+ setCellBackground (); >+ setCellForeground (); >+ setCellFont (); >+ if (!instance.startup) { >+ setColumnsMoveable (); >+ setColumnsResizable (); >+ setWidgetHeaderVisible (); >+ setWidgetSortIndicator (); >+ setWidgetLinesVisible (); >+ } >+ super.setExampleWidgetState (); >+ noScrollButton.setSelection ((tree1.getStyle () & SWT.NO_SCROLL) != 0); >+ checkButton.setSelection ((tree1.getStyle () & SWT.CHECK) != 0); >+ fullSelectionButton.setSelection ((tree1.getStyle () & SWT.FULL_SELECTION) != 0); >+ try { >+ TreeColumn column = tree1.getColumn(0); >+ moveableColumns.setSelection (column.getMoveable()); >+ resizableColumns.setSelection (column.getResizable()); >+ } catch (IllegalArgumentException ex) {} >+ headerVisibleButton.setSelection (tree1.getHeaderVisible()); >+ linesVisibleButton.setSelection (tree1.getLinesVisible()); >+ } >+ >+ /** >+ * Sets the background color of the Node 1 TreeItems in column 1. >+ */ >+ void setCellBackground () { >+ if (!instance.startup) { >+ textNode1.setBackground (1, cellBackgroundColor); >+ imageNode1.setBackground (1, cellBackgroundColor); >+ } >+ /* Set the background color item's image to match the background color of the cell. */ >+ Color color = cellBackgroundColor; >+ if (color == null) color = textNode1.getBackground (1); >+ TableItem item = colorAndFontTable.getItem(CELL_BACKGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the foreground color of the Node 1 TreeItems in column 1. >+ */ >+ void setCellForeground () { >+ if (!instance.startup) { >+ textNode1.setForeground (1, cellForegroundColor); >+ imageNode1.setForeground (1, cellForegroundColor); >+ } >+ /* Set the foreground color item's image to match the foreground color of the cell. */ >+ Color color = cellForegroundColor; >+ if (color == null) color = textNode1.getForeground (1); >+ TableItem item = colorAndFontTable.getItem(CELL_FOREGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the font of the Node 1 TreeItems in column 1. >+ */ >+ void setCellFont () { >+ if (!instance.startup) { >+ textNode1.setFont (1, cellFont); >+ imageNode1.setFont (1, cellFont); >+ } >+ /* Set the font item's image to match the font of the item. */ >+ Font ft = cellFont; >+ if (ft == null) ft = textNode1.getFont (1); >+ TableItem item = colorAndFontTable.getItem(CELL_FONT); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (fontImage(ft)); >+ item.setFont(ft); >+ colorAndFontTable.layout (); >+ } >+ >+ /** >+ * Sets the background color of the Node 1 TreeItems. >+ */ >+ void setItemBackground () { >+ if (!instance.startup) { >+ textNode1.setBackground (itemBackgroundColor); >+ imageNode1.setBackground (itemBackgroundColor); >+ } >+ /* Set the background button's color to match the background color of the item. */ >+ Color color = itemBackgroundColor; >+ if (color == null) color = textNode1.getBackground (); >+ TableItem item = colorAndFontTable.getItem(ITEM_BACKGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the foreground color of the Node 1 TreeItems. >+ */ >+ void setItemForeground () { >+ if (!instance.startup) { >+ textNode1.setForeground (itemForegroundColor); >+ imageNode1.setForeground (itemForegroundColor); >+ } >+ /* Set the foreground button's color to match the foreground color of the item. */ >+ Color color = itemForegroundColor; >+ if (color == null) color = textNode1.getForeground (); >+ TableItem item = colorAndFontTable.getItem(ITEM_FOREGROUND_COLOR); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (colorImage(color)); >+ } >+ >+ /** >+ * Sets the font of the Node 1 TreeItems. >+ */ >+ void setItemFont () { >+ if (!instance.startup) { >+ textNode1.setFont (itemFont); >+ imageNode1.setFont (itemFont); >+ } >+ /* Set the font item's image to match the font of the item. */ >+ Font ft = itemFont; >+ if (ft == null) ft = textNode1.getFont (); >+ TableItem item = colorAndFontTable.getItem(ITEM_FONT); >+ Image oldImage = item.getImage(); >+ if (oldImage != null) oldImage.dispose(); >+ item.setImage (fontImage(ft)); >+ item.setFont(ft); >+ colorAndFontTable.layout (); >+ } >+ >+ /** >+ * Sets the header visible state of the "Example" widgets. >+ */ >+ void setWidgetHeaderVisible () { >+ tree1.setHeaderVisible (headerVisibleButton.getSelection ()); >+ tree2.setHeaderVisible (headerVisibleButton.getSelection ()); >+ } >+ >+ /** >+ * Sets the sort indicator state of the "Example" widgets. >+ */ >+ void setWidgetSortIndicator () { >+ if (sortIndicatorButton.getSelection ()) { >+ initializeSortState (tree1); >+ initializeSortState (tree2); >+ } else { >+ resetSortState (tree1); >+ resetSortState (tree2); >+ } >+ } >+ >+ /** >+ * Sets the initial sort indicator state and adds a listener >+ * to cycle through sort states and columns. >+ */ >+ void initializeSortState (final Tree tree) { >+ /* Reset to known state: 'down' on column 0. */ >+ tree.setSortDirection (SWT.DOWN); >+ TreeColumn [] columns = tree.getColumns(); >+ for (int i = 0; i < columns.length; i++) { >+ TreeColumn column = columns[i]; >+ if (i == 0) tree.setSortColumn(column); >+ SelectionListener listener = new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ int sortDirection = SWT.DOWN; >+ if (e.widget == tree.getSortColumn()) { >+ /* If the sort column hasn't changed, cycle down -> up -> none. */ >+ switch (tree.getSortDirection ()) { >+ case SWT.DOWN: sortDirection = SWT.UP; break; >+ case SWT.UP: sortDirection = SWT.NONE; break; >+ } >+ } else { >+ tree.setSortColumn((TreeColumn)e.widget); >+ } >+ tree.setSortDirection (sortDirection); >+ } >+ }; >+ column.addSelectionListener(listener); >+ column.setData("SortListener", listener); //$NON-NLS-1$ >+ } >+ } >+ >+ void resetSortState (final Tree tree) { >+ tree.setSortDirection (SWT.NONE); >+ TreeColumn [] columns = tree.getColumns(); >+ for (int i = 0; i < columns.length; i++) { >+ SelectionListener listener = (SelectionListener)columns[i].getData("SortListener"); //$NON-NLS-1$ >+ if (listener != null) columns[i].removeSelectionListener(listener); >+ } >+ } >+ >+ /** >+ * Sets the lines visible state of the "Example" widgets. >+ */ >+ void setWidgetLinesVisible () { >+ tree1.setLinesVisible (linesVisibleButton.getSelection ()); >+ tree2.setLinesVisible (linesVisibleButton.getSelection ()); >+ } >+ >+ protected void specialPopupMenuItems(Menu menu, Event event) { >+ MenuItem item = new MenuItem(menu, SWT.PUSH); >+ item.setText("getItem(Point) on mouse coordinates"); >+ final Tree t = (Tree) event.widget; >+ menuMouseCoords = t.toControl(new Point(event.x, event.y)); >+ item.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + t.getItem(menuMouseCoords)); >+ eventConsole.append ("\n"); >+ } >+ }); >+ } >+} >Index: src/org/eclipse/swt/examples/mirroringTest/browser-content.html >=================================================================== >RCS file: src/org/eclipse/swt/examples/mirroringTest/browser-content.html >diff -N src/org/eclipse/swt/examples/mirroringTest/browser-content.html >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/examples/mirroringTest/browser-content.html 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+<html> >+<head> >+<title>SWT Browser</title> >+</head> >+ >+<h3>About SWT Browser</h3> >+<p>You are looking at HTML content in a <b>Browser</b> widget. >+<ul> >+<li>For a definition of the Browser widget, see: >+<a href="http://www.eclipse.org/swt/faq.php#whatisbrowser">http://www.eclipse.org/swt/faq.php#whatisbrowser</a></li> >+<li>For a list of the platforms that Browser supports, see: >+<a href="http://www.eclipse.org/swt/faq.php#browserplatforms">http://www.eclipse.org/swt/faq.php#browserplatforms</a></li> >+<li>For more information on the SWT.WEBKIT Browser style, see: >+<a href="http://www.eclipse.org/swt/faq.php#howusewebkit">http://www.eclipse.org/swt/faq.php#howusewebkit</a></li> >+<li>For more information on the SWT.MOZILLA Browser style, see: >+<a href="http://www.eclipse.org/swt/faq.php#howusemozilla">http://www.eclipse.org/swt/faq.php#howusemozilla</a></li> >+<li>For more examples that use a Browser widget, see BrowserExample, BrowserDemo, and WebBrowser: >+<a href="http://www.eclipse.org/swt/examples.php">http://www.eclipse.org/swt/examples.php</a></li> >+</ul></p> >+ >+<h3>About SWT</h3> >+<p>For more information on SWT, including the Widget Gallery, Snippets, Examples, FAQ, Tools, Documentation >+and more, check out <a href="http://www.eclipse.org/swt/">http://www.eclipse.org/swt</a>.</p> >+ >+<h3>Eclipse Downloads Page</h3> >+<p>To download the latest Integration Build of eclipse, go to: >+<a href="http://download.eclipse.org/eclipse/downloads/">http://download.eclipse.org/eclipse/downloads</a>.</p> >+ >+<h3>Bug Reports and Feature Requests</h3> >+<p>To report an SWT bug or request an SWT feature, go to: >+<a href="https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform">https://bugs.eclipse.org/bugs</a> >+and select <b>Component: SWT</b>.</p> >+ >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 344460
: 194489 |
194490
|
194576
|
194697
|
194809
|
194948