How to start launch configuration after finishing another launch programmatically? (Eclipse) - eclipse

So I need to start an launch config. depending on output from another launch configuration.
Launch launch = (Launch) configurations[0].launch(ILaunchManager.RUN_MODE,
console);
do {
if(launch.isTerminated()){
configurations[1].launch(ILaunchManager.RUN_MODE,
new NullProgressMonitor());
break;
}
} while (!launch.isTerminated());
Something like this, but even this is not working. It executes only first launch. And how can I acces the output(from console) of first launch?

You get notified about the process associated with a launch terminating by using an IDebugEventSetListener listener.
Add the listener with:
DebugPlugin.getDefault().addDebugEventListener(listener);
When the process associated with the launch (if there is one) terminate a DebugEvent will be passed to the listener's handleDebugEvents method.
The event getKind() method will return DebugEvent.TERMINATE for a terminated process. The event getSource() returns the IProcess which terminated.

Related

Issue with setting AutomationElement value

I have an issue with setting value of AutomationElement by using method ValuePattern.SetValue().
Everything works just fine until some dialog appears. When the dialog appears the code execution got stuck. No exception is thrown. After the dialog is confirmed, the code exection continues. Bellow is a sample of the code:
BasePattern basePattern = null;
ValuePattern valuePattern = null;
AutomationElement elementA = Window.GetElement(SearchCriteria.ByText(propertyName));
object patternObjectA = null;
elementA.TryGetCurrentPattern(ValuePattern.Pattern, out patternObjectA);
basePattern = (BasePattern)patternObjectA;
valuePattern = (ValuePattern)patternObjectA;
valuePattern.SetValue(optionToSet);
// Window.GetElement() is a method from TestStack.White framework
// The code execution got stuck on the last line until the dialog is confirmed
Is there any other way to set AutomationElement value?
Is somehow possible to avoid of getting stuck by dialog?
I'll by grateful for any help.
Thanks advance.
It could be that this dialog is not supporting UI Automation correctly or that you simply target the wrong element.
To verify that you may use Inspect.exe from Microsoft or similiar tools.
If it works, check if you really target the correct component with your code again.
If it does not work and:
if you are able to change the application
you can change the so called AutomationPeer of the UI component - here is a link for more infos
Or simply use another UI component that supports UI Automation correctly.
if you are not able to change the application, and also do not need to run in background, parallel, etc.. you might just focus the component (call setFocus() onto the AutomationElement, or expand it (via IsExpandCollapsePatternAvailable or simulated MouseClick onto the components coordinates)) and then use the SendKeys.SendWait("test") method.
EDIT: There is one more thing you should have a look at, and I wonder why I didn't mentioned it in the first place: Register to UI Automation Events
For example you could register a callback for the Structure change event type, and check if the dialog you talk about appeared.
If so --> click the confirmed button of the dialog.
Probably you will have to synchronize your execution, so that every further action in the UI Automation script waits until the registered callback got executed and the confirmed button got clicked.

Closing SWT application when focus goes to another application

I want that when the focus of the application moves to another application the application will be closed, for example, if the user clicks somewhere on the desktop the application should be closed.
I tried to use focus listener but it does not work. What's the solution to this?
In addition to the focus listener, you need to add an SWT.Deactivate listener to the shell and exit the application if this event occurs.
For example:
Shell shell = ...
shell.addListener( SWT.Deactivate, event -> shell.close() );
...
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() )
display.sleep();
}
The example assumes that shell is the only shell, thus causing the program to end.

xCode - App stop on a not existing breakpoint

My app always stop running on this line, even there is no breakpoint and stopping on breakpoint is disabled.
When I click continue it's stop again on the same place to infinite. Basically I'm not able to debug this app anyhow, it started when I've added this func in class.
Any ideas?
before assign value to MCCVsISDCode kindly init it first.
This is not a user-created breakpoint, but Xcode's way of handling null-referenced crashes. In your case, force-unwrapped value of MCCVsISDCode returns nil.

How do I destroy a Unity Networking Match when app is shutting down?

I've got a ResetNetworkManager method that's called when the server or client needs to clean up its state. One of these situations is when the server is shut down. This either happens when the Stop Server button is clicked, and when the method returns the start scene is loaded. In this situation the MatchInfo of the server's match is also passed in, and the NetworkMatch.DestroyMatch is called.
In the situation where the Stop Server button is clicked, everything works fine. The match is immediately removed from the match making service, and clients don't see it when they list matches.
However, when the server's app is shut down, the same method is called from another GameObject's OnDestroy method. However, in this situation the call doesn't seem to work, possibly because the NetworkMatch.DestroyMatch method actually starts a Coroutine, and this coroutine doesn't get far enough in its execution before it's killed with it's GameObject.
This is a problem as the server would normally run in batchmode, so the only way they get shut down is by killing them, rather than by clicking the button (only used when testing the server in ui mode.
Does anyone know how to make sure the match is destroyed when the app is suddenly shut down? I know you can't make OnDestroy a Coroutine, which would otherwise have been a nice solution...
Here is the code of the ResetNetworkManager method:
public void ResetNetworkManager(MatchInfo matchToDestroy)
{
if (matchToDestroy != null)
{
matchMaker.DestroyMatch(matchToDestroy.networkId, 0, MatchDestroyed);
}
StopServer();
StopClient();
StopHost();
StopMatchMaker();
if (_gameStateManager != null)
{
NetworkServer.Destroy(_gameStateManager.gameObject);
_gameStateManager = null;
}
Destroy(gameObject);
NetworkServer.Reset();
}

How to activate my eclipse plugin when a specific editors opens

My plugin needs to listen to changes (selection and content) of xtext based editors provided by another third-party plugin.
Edit1
The issue is not how to listen to the specific events in general.
Instead the issue is how to trigger the listener registration, since there's no code of my plugin executed (lazy loading) unless it is used by the user through a command for instance.
Edit2
Using org.eclipse.ui.IStartup extension point the issue is that in IStartup.earlyStartup() PlatformUI.getWorkbench().getActiveWorkbenchWindow(); is returning null. It looks like this is too early in the startup phase to register the listeners.
You can use an org.eclipse.ui.IPartListener2 listener to be told about all parts opening, closing, being activated ....
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IPartService partService = window.getPartService();
partService.addPartListener(your listener);
The
public void partOpened(IWorkbenchPartReference partRef)
method of the listener will be called when a part (editor or view) is opened. The partRef.getId() method will give you the id of the part.
Use the org.eclipse.ui.startup extension point to declare that your plugin needs to be started early. This lets you declare a class implementing org.eclipse.ui.IStartup that is called during Eclipse startup.
Note that the startup runs quite early so not everything is set up. Use Display.asyncExec to schedule code to run later:
Display.getDefault().asyncExec(runnable);