mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
error display when failed connect on deferred query
This commit is contained in:
parent
0c168cc659
commit
32b87089e1
3 changed files with 71 additions and 6 deletions
|
@ -20,16 +20,24 @@ import java.net.URL;
|
|||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.subsystems.SubSystem;
|
||||
import org.eclipse.rse.core.subsystems.SubSystem.DisplayErrorMessageJob;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.ui.GenericMessages;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -49,6 +57,7 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW
|
|||
private IRunnableContext context;
|
||||
protected ISystemViewElementAdapter _adapter;
|
||||
protected boolean _canRunAsJob;
|
||||
protected InvocationTargetException _exc;
|
||||
|
||||
public SystemFetchOperation(IWorkbenchPart part, IAdaptable remoteObject, ISystemViewElementAdapter adapter, IElementCollector collector)
|
||||
{
|
||||
|
@ -68,6 +77,11 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW
|
|||
_canRunAsJob = canRunAsJob;
|
||||
}
|
||||
|
||||
public void setException(InvocationTargetException exc)
|
||||
{
|
||||
_exc = exc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the part that is associated with this operation.
|
||||
*
|
||||
|
@ -162,8 +176,22 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW
|
|||
|
||||
Display dis = Display.getDefault();
|
||||
dis.syncExec(new PromptForPassword(ss));
|
||||
|
||||
ss.getConnectorService().connect(monitor);
|
||||
try
|
||||
{
|
||||
ss.getConnectorService().connect(monitor);
|
||||
if (_exc != null)
|
||||
{
|
||||
showOperationErrorMessage(null, _exc, ss);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException exc)
|
||||
{
|
||||
showOperationErrorMessage(null, exc, ss);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
showOperationErrorMessage(null, e, ss);
|
||||
}
|
||||
|
||||
dis.asyncExec(new UpdateRegistry(ss));
|
||||
|
||||
|
@ -173,6 +201,42 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW
|
|||
_collector.add(children, monitor);
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
protected void showOperationErrorMessage(Shell shell, Throwable exc, SubSystem ss)
|
||||
{
|
||||
SystemMessage sysMsg = null;
|
||||
if (exc instanceof SystemMessageException)
|
||||
{
|
||||
displayAsyncMsg(ss, (SystemMessageException)exc);
|
||||
//sysMsg = ((SystemMessageException)exc).getSystemMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
String excMsg = exc.getMessage();
|
||||
if ((excMsg == null) || (excMsg.length()==0))
|
||||
excMsg = "Exception " + exc.getClass().getName();
|
||||
sysMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_FAILED);
|
||||
sysMsg.makeSubstitution(excMsg);
|
||||
|
||||
|
||||
SystemMessageDialog msgDlg = new SystemMessageDialog(shell, sysMsg);
|
||||
msgDlg.setException(exc);
|
||||
msgDlg.open();
|
||||
//RSEUIPlugin.logError("Operation failed",exc); now done successfully in msgDlg.open()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display message on message thread
|
||||
*/
|
||||
protected void displayAsyncMsg(SubSystem ss, org.eclipse.rse.services.clientserver.messages.SystemMessageException msg)
|
||||
{
|
||||
DisplayErrorMessageJob job = ss.new DisplayErrorMessageJob(null, msg);
|
||||
job.setPriority(Job.INTERACTIVE);
|
||||
job.setSystem(true);
|
||||
job.schedule();
|
||||
}
|
||||
|
||||
protected String getTaskName()
|
||||
{
|
||||
|
|
|
@ -1758,16 +1758,17 @@ public abstract class AbstractSystemViewAdapter
|
|||
|
||||
public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor)
|
||||
{
|
||||
SystemFetchOperation operation = null;
|
||||
try
|
||||
{
|
||||
monitor = Policy.monitorFor(monitor);
|
||||
monitor.beginTask(Policy.bind("RemoteFolderElement.fetchingRemoteChildren", getLabel(o)), 100); //$NON-NLS-1$
|
||||
SystemFetchOperation operation = getSystemFetchOperation(o, collector);
|
||||
operation = getSystemFetchOperation(o, collector);
|
||||
operation.run(Policy.subMonitorFor(monitor, 100));
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
operation.setException(e);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
|
|
|
@ -982,7 +982,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
|
|||
* Inner class which extends WorkbenchJob to allow us to show an error message, which is a GUI operation,
|
||||
* from a non-GUI thread. This is done by creating an instance of this class and then scheduling it.
|
||||
*/
|
||||
protected class DisplayErrorMessageJob extends WorkbenchJob
|
||||
public class DisplayErrorMessageJob extends WorkbenchJob
|
||||
{
|
||||
private Shell shell;
|
||||
private org.eclipse.rse.services.clientserver.messages.SystemMessageException msgExc;
|
||||
|
@ -1344,7 +1344,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
|
|||
}
|
||||
catch(InvocationTargetException exc)
|
||||
{
|
||||
exc.printStackTrace();
|
||||
//exc.printStackTrace();
|
||||
monitor.done();
|
||||
String excMsg = exc.getTargetException().getMessage();
|
||||
if ((excMsg == null) || (excMsg.length()==0))
|
||||
|
|
Loading…
Add table
Reference in a new issue