use of org.eclipse.debug.core.ILaunchesListener2 in project webtools.servertools by eclipse.
the class ServerPropertiesEditorSection method init.
public void init(final IEditorSite site, IEditorInput input) {
super.init(site, input);
if (server != null) {
fServer = (GenericServer) server.loadAdapter(GenericServer.class, new NullProgressMonitor());
}
fPropertyChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(GenericServerRuntime.SERVER_INSTANCE_PROPERTIES)) {
if (!fUpdating) {
fUpdating = true;
updateControls();
fUpdating = false;
}
}
}
};
server.addPropertyChangeListener(fPropertyChangeListener);
fLaunchListener = new ILaunchesListener2() {
public void launchesRemoved(ILaunch[] launches) {
// Nothing to do
}
private ILaunchConfiguration getServerLaunchConfig(ILaunch[] launches) {
for (int i = 0; i < launches.length; i++) {
ILaunchConfiguration launchConfig = launches[i].getLaunchConfiguration();
if (launchConfig != null) {
String serverId;
try {
serverId = launchConfig.getAttribute(GenericServerBehaviour.ATTR_SERVER_ID, (String) null);
if (fServer.getServer().getId().equals(serverId)) {
return launchConfig;
}
} catch (CoreException e) {
// Ignore
}
}
}
return null;
}
public void launchesChanged(ILaunch[] launches) {
// Nothing to do
}
public void launchesAdded(ILaunch[] launches) {
ILaunchConfiguration lc = getServerLaunchConfig(launches);
try {
if (lc != null) {
if ("true".equals(lc.getAttribute(GenericServerBehaviour.ATTR_STOP, "false"))) {
// $NON-NLS-1$ //$NON-NLS-2$
site.getWorkbenchWindow().getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
IManagedForm managedForm = getManagedForm();
managedForm.getMessageManager().removeMessage(MESSAGE_ID_SERVER_RUNNING);
managedForm.getMessageManager().update();
}
});
} else {
site.getWorkbenchWindow().getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
getManagedForm().getMessageManager().addMessage(MESSAGE_ID_SERVER_RUNNING, GenericServerUIMessages.serverRunningCanNotSave, null, IMessageProvider.WARNING);
}
});
}
}
} catch (CoreException e) {
GenericUiPlugin.getDefault().getLog().log(e.getStatus());
}
}
public void launchesTerminated(ILaunch[] launches) {
if (getServerLaunchConfig(launches) != null) {
site.getWorkbenchWindow().getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
getManagedForm().getMessageManager().removeMessage(MESSAGE_ID_SERVER_RUNNING);
}
});
}
}
};
getLaunchManager().addLaunchListener(fLaunchListener);
}
Aggregations