mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 13:05:22 +02:00
[251026] Work Offline requires being selected twice to turn on Offline Mode
This commit is contained in:
parent
c8e49716f3
commit
74e2b33a72
1 changed files with 43 additions and 3 deletions
|
@ -16,19 +16,26 @@
|
||||||
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
|
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
|
||||||
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
||||||
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
|
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
|
||||||
|
* David McKnight (IBM) - [251026] Work Offline requires being selected twice to turn on Offline Mode
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.ui.actions;
|
package org.eclipse.rse.internal.ui.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.rse.core.RSECorePlugin;
|
import org.eclipse.rse.core.RSECorePlugin;
|
||||||
|
import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
|
||||||
|
import org.eclipse.rse.core.events.ISystemResourceChangeListener;
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
|
import org.eclipse.rse.core.subsystems.SubSystem;
|
||||||
import org.eclipse.rse.internal.ui.SystemResources;
|
import org.eclipse.rse.internal.ui.SystemResources;
|
||||||
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
||||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
|
@ -89,17 +96,40 @@ public class SystemWorkOfflineAction extends SystemBaseAction
|
||||||
// to collapse
|
// to collapse
|
||||||
sr.setHostOffline(conn, true);
|
sr.setHostOffline(conn, true);
|
||||||
setChecked(true);
|
setChecked(true);
|
||||||
|
|
||||||
// online going offline, disconnect all subsystems
|
// online going offline, disconnect all subsystems
|
||||||
ISubSystem[] subsystems = sr.getSubSystems(conn);
|
final ISubSystem[] subsystems = sr.getSubSystems(conn);
|
||||||
|
final List subsystemsDisconnected = new ArrayList();
|
||||||
|
|
||||||
if (subsystems != null)
|
if (subsystems != null)
|
||||||
{
|
{
|
||||||
|
ISystemResourceChangeListener listener = new ISystemResourceChangeListener()
|
||||||
|
{
|
||||||
|
public void systemResourceChanged(
|
||||||
|
ISystemResourceChangeEvent event) {
|
||||||
|
Object src = event.getSource();
|
||||||
|
if (src instanceof SubSystem){
|
||||||
|
if (!((SubSystem)src).isConnected()){
|
||||||
|
if (!subsystemsDisconnected.contains(src))
|
||||||
|
subsystemsDisconnected.add(src);
|
||||||
|
if (subsystemsDisconnected.size() == subsystems.length){
|
||||||
|
sr.removeSystemResourceChangeListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sr.addSystemResourceChangeListener(listener);
|
||||||
|
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
for (int i = 0; i < subsystems.length && !cancelled; i++)
|
for (int i = 0; i < subsystems.length && !cancelled; i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// disconnect launches a job but doesn't wait for completion
|
||||||
subsystems[i].disconnect(false);
|
subsystems[i].disconnect(false);
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// user cancelled disconnect
|
// user cancelled disconnect
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
|
@ -109,9 +139,18 @@ public class SystemWorkOfflineAction extends SystemBaseAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Job job = new Job("Ensure Disconnected")
|
Job job = new Job("Ensure Disconnected") //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
public IStatus run(IProgressMonitor monitor){
|
public IStatus run(IProgressMonitor monitor){
|
||||||
|
// while
|
||||||
|
while (subsystemsDisconnected.size() < subsystems.length){
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check that everything was disconnedted okay and this is not the local connection
|
// check that everything was disconnedted okay and this is not the local connection
|
||||||
if(sr.isAnySubSystemConnected(conn) && !conn.getSystemType().isLocal())
|
if(sr.isAnySubSystemConnected(conn) && !conn.getSystemType().isLocal())
|
||||||
{
|
{
|
||||||
|
@ -122,6 +161,7 @@ public class SystemWorkOfflineAction extends SystemBaseAction
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
job.setSystem(true);
|
||||||
job.schedule();
|
job.schedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue