# HG changeset patch # User dadubrow # Date 1267558309 21600 # Node ID ceac11190019b2969234cc4cbbdda4fa87d8243a # Parent f6b590f7721986ea9c2c56621d9546bbe00ad3a1 bug 10815 - connection dialog listen to service status change and update status diff -r f6b590f77219 -r ceac11190019 debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchSettingsDialog.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchSettingsDialog.java Tue Mar 02 08:22:58 2010 -0600 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchSettingsDialog.java Tue Mar 02 13:31:49 2010 -0600 @@ -28,6 +28,7 @@ import org.eclipse.swt.SWT; 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 com.nokia.carbide.cpp.ui.CarbideUIPlugin; @@ -114,16 +115,20 @@ okButton.setEnabled(enabled); } - protected void updateStatus(IStatus status) { - setTitle(title); + protected void updateStatus(final IStatus status) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + setTitle(title); - if (status.isOK()) { - setMessage("", IMessageProvider.NONE); //$NON-NLS-1$ - } else { - setMessage(status.getMessage(), severityToMsgType(status.getSeverity())); - } - - setOkEnabled(!status.matches(IStatus.ERROR)); + if (status.isOK()) { + setMessage("", IMessageProvider.NONE); //$NON-NLS-1$ + } else { + setMessage(status.getMessage(), severityToMsgType(status.getSeverity())); + } + + setOkEnabled(!status.matches(IStatus.ERROR)); + } + }); } } \ No newline at end of file diff -r f6b590f77219 -r ceac11190019 debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java Tue Mar 02 08:22:58 2010 -0600 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java Tue Mar 02 13:31:49 2010 -0600 @@ -61,6 +61,7 @@ import com.nokia.carbide.remoteconnections.interfaces.IConnectionType; import com.nokia.carbide.remoteconnections.interfaces.IConnectionTypeProvider; import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager; +import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener; import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener; import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard; @@ -68,7 +69,7 @@ * This dialog allows in-depth configuration of the connection settings. */ @SuppressWarnings("restriction") -public class ConnectToDeviceDialog extends AbstractLaunchSettingsDialog implements IConnectionListener { +public class ConnectToDeviceDialog extends AbstractLaunchSettingsDialog implements IConnectionListener, IStatusChangedListener { private IConnectionsManager manager; private IConnectionTypeProvider typeProvider; private FontMetrics fm; @@ -76,6 +77,7 @@ private Button editButton; private Label descriptionLabel; private Button newButton; + private IConnectedService currentServiceListener; protected ConnectToDeviceDialog(Shell shell, LaunchWizardData data) { super(shell, data); @@ -191,13 +193,7 @@ if (status.isOK()) { IConnection connection = data.getConnection(); if (connection != null) { - IConnectedService connectedService = null; - Collection services = manager.getConnectedServices(connection); - for (IConnectedService service : services) { - if (service != null && service.getService().getIdentifier().equals(data.getService().getIdentifier())) { - connectedService = service; - } - } + IConnectedService connectedService = findConnectedServiceFromConnection(connection); if (connectedService == null) { status = error(MessageFormat.format( @@ -209,8 +205,9 @@ connectedService.getStatus(); if (!serviceStatus.getEStatus().equals( com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus.UP)) { + String description = serviceStatus.getLongDescription(); status = warning(Messages.getString("ConnectToDeviceDialog.ServiceNotAvailWarning"), //$NON-NLS-1$ - serviceStatus.getLongDescription()); + description == null ? "" : description); //$NON-NLS-1$ } } } @@ -218,6 +215,16 @@ updateStatus(status); } + private IConnectedService findConnectedServiceFromConnection(IConnection connection) { + Collection services = manager.getConnectedServices(connection); + for (IConnectedService connectedService : services) { + if (connectedService != null && connectedService.getService().getIdentifier().equals(data.getService().getIdentifier())) { + return connectedService; + } + } + return null; + } + /** * Update for a change in the connection. We will attempt to connect to the * device (once) to detect what TRK it is running. @@ -230,10 +237,14 @@ } else { descriptionLabel.setText(Messages.getString("ConnectToDeviceDialog.NoConnectionsText") + standardPNPMessage); //$NON-NLS-1$ } - + if (currentServiceListener != null) + currentServiceListener.removeStatusChangedListener(this); + currentServiceListener = findConnectedServiceFromConnection(connection); + if (currentServiceListener != null) + currentServiceListener.addStatusChangedListener(this); } - public void connectionSelected(IConnection connection) { + protected void connectionSelected(IConnection connection) { updateConnection(connection); validate(); } @@ -247,9 +258,13 @@ } public void currentConnectionSet(IConnection connection) { - refreshUI(connection); +// refreshUI(connection); } + public void statusChanged(com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus status) { + validate(); + } + private Set getCompatibleConnectionTypes() { HashSet types = new HashSet(); Collection compatibleTypeIds = @@ -314,5 +329,6 @@ manager.addConnectionListener(this); return super.close(); } + }