From d9d7cb5c02e472fc143665fca0f992e5a73de282 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Fri, 4 Feb 2011 14:15:17 +0000 Subject: [PATCH] [334295] SystemViewForm dialogs don't display cancellable progress in the dialog --- .../ui/view/SystemViewFilterAdapter.java | 14 ++- .../rse/internal/ui/view/SystemViewForm.java | 6 +- ...SystemViewFormLabelAndContentProvider.java | 92 +++++++++++++++++++ 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFormLabelAndContentProvider.java diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java index 611c12d14a6..2813f253c27 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread * David Dykstal (IBM) - [224671] [api] org.eclipse.rse.core API leaks non-API types * David Dykstal (IBM) - [226761] fix NPE in team view when expanding items + * David McKnight (IBM) - [334295] SystemViewForm dialogs don't display cancellable progress in the dialog *******************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -195,6 +196,17 @@ public class SystemViewFilterAdapter extends AbstractSystemViewAdapter return filter.getParentFilterContainer(); } + /** + * Overriding because it's possible for a filter to be promptable while not being a ISystemPromptableObject + */ + public boolean isPromptable(Object element){ + ISystemFilter filter = getFilter(element); + if (filter != null && filter.isPromptable()){ + return true; + } + return super.isPromptable(element); + } + /** * Return the children of this filter. * This is a combination of nested filters and resolved filter objects. diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewForm.java index 9c8cfbb40d0..a7a9adc9b77 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewForm.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewForm.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,7 @@ * David McKnight (IBM) - [187711] select SystemView APIs exposed by the ISystemTree interface * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types * David McKnight (IBM) - [257721] Doubleclick doing special handling and expanding + * David McKnight (IBM) - [334295] SystemViewForm dialogs don't display cancellable progress in the dialog *******************************************************************************/ package org.eclipse.rse.internal.ui.view; import java.util.List; @@ -441,6 +442,9 @@ public class SystemViewForm extends Composite implements ISystemTree // for bug 257721, when using system view from a dialog, by default, we don't let adapter handle double-click tree.allowAdapterToHandleDoubleClick(false); + + // add custom content provider + tree.setContentProvider(new SystemViewFormLabelAndContentProvider()); } protected void addOurMouseListener() diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFormLabelAndContentProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFormLabelAndContentProvider.java new file mode 100644 index 00000000000..c3bd0ac7151 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFormLabelAndContentProvider.java @@ -0,0 +1,92 @@ +/******************************************************************************** + * Copyright (c) 2011 IBM Corporation and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight. + * + * Contributors: + * David McKnight (IBM) - [334295] SystemViewForm dialogs don't display cancellable progress in the dialog + ********************************************************************************/ + +package org.eclipse.rse.internal.ui.view; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.operation.IRunnableContext; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.osgi.util.NLS; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemBasePlugin; +import org.eclipse.rse.ui.view.IContextObject; +import org.eclipse.rse.ui.view.ISystemViewElementAdapter; +import org.eclipse.ui.internal.progress.ProgressMessages; + +public class SystemViewFormLabelAndContentProvider extends + SystemViewLabelAndContentProvider { + + // override to deal with progress monitor + public Object[] getChildren(Object object) + { + Object element = object; + if (object instanceof IContextObject) + { + element = ((IContextObject)object).getModelObject(); + } + ISystemViewElementAdapter adapter = getViewAdapter(element); + if (supportsDeferredQueries() && !adapter.isPromptable(element)) + { + IRunnableContext irc = RSEUIPlugin.getTheSystemRegistryUI().getRunnableContext(); + if (irc == null){ + irc = SystemBasePlugin.getActiveWorkbenchWindow(); + } + if (irc == null){ // no window - defer to the base behaviour + return super.getChildren(object); + } + final Object fparent = object; + final Object felement = element; + final ISystemViewElementAdapter fadapter = adapter; + class MyRunnable implements IRunnableWithProgress + { + private Object[] _children = null; + public void run(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException { + + String taskName = NLS.bind(ProgressMessages.DeferredTreeContentManager_FetchingName, fadapter.getAbsoluteName(felement)); + monitor.beginTask(taskName, IProgressMonitor.UNKNOWN); + if (fparent instanceof IContextObject){ + _children = fadapter.getChildren((IContextObject)fparent, monitor); + } + else { + _children = fadapter.getChildren((IAdaptable)fparent, monitor); + } + monitor.done(); + } + + public Object[] getChildren(){ + return _children; + } + }; + + MyRunnable runnable = new MyRunnable(); + try { + irc.run(true, true, runnable); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return runnable.getChildren(); + } + else { + return super.getChildren(object); + } + } +}