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 41926 Details for
Bug 142582
[OLE] "widget is disposed" after reparenting OleControlSite
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.
TestCase that fails.
ReParentOleBrowser.java (text/plain), 7.17 KB, created by
Bob Pleva
on 2006-05-18 15:06:25 EDT
(
hide
)
Description:
TestCase that fails.
Filename:
MIME Type:
Creator:
Bob Pleva
Created:
2006-05-18 15:06:25 EDT
Size:
7.17 KB
patch
obsolete
>import org.eclipse.swt.SWT; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.events.SelectionListener; >import org.eclipse.swt.graphics.Color; >import org.eclipse.swt.graphics.DeviceData; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.ole.win32.OLE; >import org.eclipse.swt.ole.win32.OleAutomation; >import org.eclipse.swt.ole.win32.OleControlSite; >import org.eclipse.swt.ole.win32.OleEvent; >import org.eclipse.swt.ole.win32.OleFrame; >import org.eclipse.swt.ole.win32.OleListener; >import org.eclipse.swt.ole.win32.Variant; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.swt.widgets.Control; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Shell; > >import org.eclipse.swt.widgets.Listener; > >/* > * Created on Apr 25, 2006 > * > * To change the template for this generated file go to > * Window>Preferences>Java>Code Generation>Code and Comments > */ > >/** > * @author Repleva > * > * To change the template for this generated type comment go to > * Window>Preferences>Java>Code Generation>Code and Comments > */ >public class ReParentOleBrowser { > > > > Display display; > Shell shell; > OleAutomation oleAutomation; > OleControlSite oleControlSite; > Composite holdingComposite; > int counter = 0; > > public static void main(String[] args) { > > ReParentOleBrowser instance = new ReParentOleBrowser(); > instance.run(); > } > > public ReParentOleBrowser() { > > } > > private void build() { > > > > GridLayout gridLayout = new GridLayout(); > gridLayout.numColumns = 2; > gridLayout.makeColumnsEqualWidth = false; > shell.setLayout(gridLayout); > > Composite buttonComposite = new Composite(shell,SWT.NONE); > buttonComposite.setSize(50,600); > buildButtonComposite(buttonComposite); > > Composite browserComposite = new Composite(shell,SWT.CENTER); > buildBrowserComposite(browserComposite); > > } > > private void buildButtonComposite(Composite comp) { > > GridLayout layout = new GridLayout(); > > GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, > GridData.VERTICAL_ALIGN_BEGINNING, > true, > true); > > layout.numColumns = 1; > > comp.setLayout(layout); > comp.setLayoutData(gd); > > gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); > Button button1 = new Button(comp,SWT.PUSH); > button1.setLayoutData(gd); > button1.setText("Open Browser"); > > // The "close" button is not necessary.. If you click open with the browser is already open, > // we'll dispose the browser before openning another one. > > gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); > Button button2 = new Button(comp,SWT.PUSH); > button2.setLayoutData(gd); > button2.setText("Close Browser"); > > > > > button1.addSelectionListener(new SelectionListener() { > > public void widgetSelected(SelectionEvent arg0) { > > addBrowser(); > > } > > public void widgetDefaultSelected(SelectionEvent arg0) { > // TODO Auto-generated method stub > > } > > }); > > > button2.addSelectionListener(new SelectionListener() { > > public void widgetSelected(SelectionEvent arg0) { > destroyBrowser(); > > } > > public void widgetDefaultSelected(SelectionEvent arg0) { > // TODO Auto-generated method stub > > } > > }); > > > > > > > > } > > > private void buildBrowserComposite(Composite comp) { > > > comp.setLayout(new GridLayout(1,false)); > GridData gd = new GridData(GridData.FILL_BOTH); > gd.grabExcessHorizontalSpace = true; > gd.widthHint = 700; > comp.setLayoutData(gd); > > > > > } > > private void run() { > > > DeviceData data = new DeviceData(); > data.tracking = true; > display = new Display(data); > Sleak sleak = new Sleak(); > sleak.open(); > shell = new Shell(display); > shell.setSize(800,600); > build(); > shell.open(); > > holdingComposite = new Composite(shell,SWT.NONE); > holdingComposite.setVisible(false); > > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) { > display.sleep(); > } > } > display.dispose(); > > } > > private void addBrowser() { > > // this gets rid of OleFrame > destroyBrowser(); > > System.out.println("Total browser opens: " + ++counter); > > Composite browserComposite = (Composite)shell.getChildren()[1]; > > > OleFrame oleFrame = new OleFrame(browserComposite,SWT.RESIZE); > oleFrame.setVisible(true); > oleFrame.setSize(700,600); > > if (oleControlSite == null) { > oleControlSite = new OleControlSite(oleFrame,SWT.CENTER,"Shell.Explorer"); > } > > else { > oleControlSite.setParent(oleFrame); > } > > > GridData gd = new GridData(GridData.FILL_BOTH); > gd.grabExcessHorizontalSpace = true; > oleFrame.setLayoutData(gd); > > oleControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); > oleAutomation = new OleAutomation(oleControlSite); > > > oleControlSite.setSize(650,600); > > > getButton1().setEnabled(false); > OleListener downloadListener = new OleListener() { > > public void handleEvent(OleEvent arg0) { > > OleControlSite oleControlSite = (OleControlSite)arg0.widget; > OleFrame oleFrame = (OleFrame)oleControlSite.getParent(); > Composite browserComposite = (Composite)oleFrame.getParent(); > > > > getButton1().setEnabled(true); > oleControlSite.removeEventListener(104,this); > }}; > > oleControlSite.addEventListener(104,downloadListener); > > > > > // navigate(oleAutomation,"about:blank"); > navigate(oleAutomation,"http://www.hewitt.com"); > // navigate(oleAutomation,"file:///c:/CSPro/HandleLeak/guide.html"); > > > > > } > > private void destroyBrowser() { > > // this should destroy the oleFrame but not OleControlSite. > > // first child is the button composite. 2nd one is the browserComposite. > // if it has a child, it's OleFrame. > if (((Composite)shell.getChildren()[1]).getChildren().length > 0) { > Composite browserComposite = (Composite)shell.getChildren()[1]; > OleFrame oleFrame = (OleFrame)browserComposite.getChildren()[0]; > > oleAutomation.dispose(); > oleAutomation = null; > > oleControlSite.setParent(holdingComposite); > oleFrame.dispose(); > > System.out.println("Browser and OleFrame Disposed"); > } > > } > > > > private void navigate(OleAutomation oleAutomation,String dest) { > > int rgdispid[] = oleAutomation.getIDsOfNames(new String[] > { > "Navigate", "URL", > }); > Variant[] address = new Variant[1]; > address[0] = new Variant(dest); > > > Variant pVarResult = oleAutomation.invoke(rgdispid[0], address, > new int[] {rgdispid[1]}); > > > > if ((pVarResult == null) || (pVarResult.getType() != OLE.S_OK)) > { > System.out.println("Navigate to url failed"); > } > pVarResult.dispose(); > for (int i=0;i<address.length;i++){ > address[i].dispose(); > } > > > } > > private Composite getButtonComposite() { > return (Composite)shell.getChildren()[0]; > } > > > private Button getButton1() { > return (Button)getButtonComposite().getChildren()[0]; > } > > >} > >
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 Raw
Actions:
View
Attachments on
bug 142582
:
41925
| 41926