Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to get the part object out of a cloned snippet
How to get the part object out of a cloned snippet [message #1814262] Fri, 06 September 2019 21:05 Go to next message
Ken Keefe is currently offline Ken KeefeFriend
Messages: 41
Registered: April 2012
Member
I am trying to show a dialog and then get a hold of the part contained in the new dialog so I can update it with data. Here is my code so far.

MUIElement dia = modelService.cloneSnippet(application, "edu.illinois.mobius.core.jobserver.dialog.nodeConnectionTest", null);
		SimpleConsolePart console = null;
		if(dia instanceof MDialog) {
			MDialog d = (MDialog)dia;
			Monitor mon = parentShell.getMonitor();
			Rectangle monitorRect = mon.getBounds();
			d.setX(monitorRect.x + (monitorRect.width - d.getWidth())/2);
			d.setY(monitorRect.y + (monitorRect.height - d.getHeight())/2);
			application.getChildren().add(d);
			d.setOnTop(true);
			
			PartImpl partI = (PartImpl) d.getChildren().get(0);
			console = (SimpleConsolePart)partI.getObject();
		}
		
		if(console != null) {
		// Update the console
		}


I am getting warnings about trying to access the PartImpl class because it is a discouraged access. Is there another way to get ahold of the part that the new dialog contains?
Re: How to get the part object out of a cloned snippet [message #1814838 is a reply to message #1814262] Thu, 19 September 2019 18:58 Go to previous message
Ken Keefe is currently offline Ken KeefeFriend
Messages: 41
Registered: April 2012
Member
Well, that was an obvious mistake. Sometimes you have to look at problems with fresh eyes, I guess.

Here is the way to get the part without getting the discouraged access warnings.

MUIElement dia = modelService.cloneSnippet(application, "edu.illinois.mobius.core.jobserver.dialog.nodeConnectionTest", null);
		SimpleConsolePart console = null;
		if(dia instanceof MDialog) {
			MDialog d = (MDialog)dia;
			Monitor mon = parentShell.getMonitor();
			Rectangle monitorRect = mon.getBounds();
			d.setX(monitorRect.x + (monitorRect.width - d.getWidth())/2);
			d.setY(monitorRect.y + (monitorRect.height - d.getHeight())/2);
			application.getChildren().add(d);
			d.setOnTop(true);
			
			MPart partI = (MPart) d.getChildren().get(0);
			console = (SimpleConsolePart)partI.getObject();
		}
		
		if(console != null) {
		// Update the console
		}
Previous Topic:Handler enable/disable not working
Next Topic:Failed to create the part's controls
Goto Forum:
  


Current Time: Fri Apr 26 17:57:41 GMT 2024

Powered by FUDForum. Page generated in 0.03499 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top