mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
[186773] split SystemRegistryUI from SystemRegistry implementation, in preparation of UI/Non-UI splitting. This is not an API change.
This commit is contained in:
parent
7edc93c3d8
commit
af76788da1
12 changed files with 702 additions and 546 deletions
|
@ -33,6 +33,7 @@ import org.eclipse.rse.core.model.ISystemRegistry;
|
|||
import org.eclipse.rse.core.subsystems.IConnectorService;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||
import org.eclipse.rse.ui.actions.SystemRefreshAllAction;
|
||||
import org.eclipse.tm.discovery.model.Pair;
|
||||
import org.eclipse.tm.discovery.model.Service;
|
||||
|
@ -187,7 +188,7 @@ public class ServiceDiscoveryWizard extends Wizard {
|
|||
}
|
||||
}
|
||||
|
||||
RSECorePlugin.getTheSystemRegistry().expandHost(conn);
|
||||
RSEUIPlugin.getTheSystemRegistryUI().expandHost(conn);
|
||||
}
|
||||
|
||||
systemRefreshAllAction.run();
|
||||
|
|
|
@ -57,24 +57,6 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable {
|
|||
|
||||
public ISystemFilterStartHere getSystemFilterStartHere();
|
||||
|
||||
// ----------------------------------
|
||||
// UI METHODS...
|
||||
// ----------------------------------
|
||||
/**
|
||||
* Show the RSE perspective if it is not already showing
|
||||
*/
|
||||
public void showRSEPerspective();
|
||||
|
||||
/**
|
||||
* Expand the given connection in the RSE, if the RSE is the active perspective.
|
||||
*/
|
||||
public void expandHost(IHost conn);
|
||||
|
||||
/**
|
||||
* Expand the given subsystem in the RSE, if the RSE is the active perspective.
|
||||
*/
|
||||
public void expandSubSystem(ISubSystem subsystem);
|
||||
|
||||
// ----------------------------
|
||||
// SUBSYSTEM FACTORY METHODS...
|
||||
// ----------------------------
|
||||
|
@ -137,19 +119,20 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable {
|
|||
|
||||
/**
|
||||
* This method is called by the connection adapter when the user expands
|
||||
* a connection.
|
||||
* This method must return the child objects to show for that connection.
|
||||
* a connection. This method must return the child objects to show for that
|
||||
* connection.
|
||||
* @param selectedConnection the connection undergoing expansion
|
||||
* @return the list of objects under the connection
|
||||
*/
|
||||
public Object[] getConnectionChildren(IHost selectedConnection);
|
||||
|
||||
/**
|
||||
* This method is called by the connection adapter when deciding
|
||||
* to show a plus-sign or not beside a connection.
|
||||
*
|
||||
* This method is called by the connection adapter when deciding to show a plus-sign
|
||||
* or not beside a connection.
|
||||
* @param selectedConnection the connection being shown in the viewer
|
||||
* @return true if this connection has children to be shown.
|
||||
*/
|
||||
public boolean hasConnectionChildren(IHost selectedConnection);
|
||||
|
||||
|
||||
// ----------------------------
|
||||
// USER PREFERENCE METHODS...
|
||||
|
|
|
@ -12,12 +12,13 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
|
||||
* Martin Oberhuber (Wind River) - [186773] split SystemRegistryUI from SystemRegistry implementation
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.ui.view.scratchpad;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.ui.internal.model.SystemRegistry;
|
||||
import org.eclipse.rse.ui.internal.model.SystemRegistryUI;
|
||||
import org.eclipse.rse.ui.internal.model.SystemScratchpad;
|
||||
|
||||
|
||||
|
@ -32,7 +33,7 @@ class BrowseAction extends Action
|
|||
_view = view;
|
||||
setImageDescriptor(des);
|
||||
setToolTipText(label);
|
||||
_scratchPad = SystemRegistry.getInstance().getSystemScratchPad();
|
||||
_scratchPad = SystemRegistryUI.getInstance().getSystemScratchPad();
|
||||
}
|
||||
|
||||
public void checkEnabledState()
|
||||
|
|
|
@ -77,7 +77,7 @@ import org.eclipse.rse.ui.SystemBasePlugin;
|
|||
import org.eclipse.rse.ui.SystemMenuManager;
|
||||
import org.eclipse.rse.ui.actions.ISystemAction;
|
||||
import org.eclipse.rse.ui.actions.SystemRefreshAction;
|
||||
import org.eclipse.rse.ui.internal.model.SystemRegistry;
|
||||
import org.eclipse.rse.ui.internal.model.SystemRegistryUI;
|
||||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.model.ISystemShellProvider;
|
||||
|
@ -380,7 +380,7 @@ public class SystemScratchpadView
|
|||
if (w != null)
|
||||
{
|
||||
remove(child);
|
||||
SystemRegistry.getInstance().getSystemScratchPad().removeChild(child);
|
||||
SystemRegistryUI.getInstance().getSystemScratchPad().removeChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.eclipse.rse.ui.SystemWidgetHelpers;
|
|||
import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction;
|
||||
import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction;
|
||||
import org.eclipse.rse.ui.actions.SystemRefreshAction;
|
||||
import org.eclipse.rse.ui.internal.model.SystemRegistry;
|
||||
import org.eclipse.rse.ui.internal.model.SystemRegistryUI;
|
||||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||
import org.eclipse.rse.ui.model.ISystemShellProvider;
|
||||
import org.eclipse.rse.ui.view.IRSEViewPart;
|
||||
|
@ -148,7 +148,7 @@ public class SystemScratchpadViewPart extends ViewPart
|
|||
|
||||
SystemWidgetHelpers.setHelp(_viewer.getControl(), RSEUIPlugin.HELPPREFIX + "scrp0000"); //$NON-NLS-1$
|
||||
|
||||
setInput(SystemRegistry.getInstance().getSystemScratchPad());
|
||||
setInput(SystemRegistryUI.getInstance().getSystemScratchPad());
|
||||
|
||||
getSite().registerContextMenu(_viewer.getContextMenuManager(), _viewer);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.eclipse.rse.services.clientserver.messages.ISystemMessageProvider;
|
|||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
|
||||
import org.eclipse.rse.ui.internal.model.SystemRegistry;
|
||||
import org.eclipse.rse.ui.internal.model.SystemRegistryUI;
|
||||
import org.eclipse.rse.ui.model.ISystemRegistryUI;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
|
@ -81,7 +82,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
|
|||
public IStatus run(IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
ISystemRegistry registry = getSystemRegistryUIInternal();
|
||||
ISystemRegistry registry = getSystemRegistryInternal();
|
||||
|
||||
|
||||
SystemResourceManager.getRemoteSystemsProject(); // create core folder tree
|
||||
|
@ -132,7 +133,8 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
|
|||
private static SystemMessageFile defaultMessageFile = null;
|
||||
|
||||
// private SystemType[] allSystemTypes = null;
|
||||
private SystemRegistry _systemRegistry = null;
|
||||
private SystemRegistryUI _systemRegistryUI = null;
|
||||
private SystemRegistry _systemRegistry = null;
|
||||
|
||||
private Vector viewSuppliers = new Vector();
|
||||
private SystemViewAdapterFactory svaf; // for fastpath access
|
||||
|
@ -442,20 +444,16 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
|
|||
*/
|
||||
public void start(BundleContext context) throws Exception
|
||||
{
|
||||
|
||||
// call super first
|
||||
super.start(context);
|
||||
|
||||
messageFile = getMessageFile("systemmessages.xml"); //$NON-NLS-1$
|
||||
defaultMessageFile = getDefaultMessageFile("systemmessages.xml"); //$NON-NLS-1$
|
||||
|
||||
|
||||
ISystemRegistry registry = getSystemRegistryUIInternal();
|
||||
ISystemRegistry registry = getSystemRegistryInternal();
|
||||
RSECorePlugin.getDefault().setSystemRegistry(registry);
|
||||
|
||||
IAdapterManager manager = Platform.getAdapterManager();
|
||||
|
||||
|
||||
// DKM
|
||||
// for subsystem factories
|
||||
SubSystemConfigurationAdapterFactory ssfaf = new SubSystemConfigurationAdapterFactory();
|
||||
|
@ -503,7 +501,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
|
|||
closeViews();
|
||||
|
||||
// clear in-memory settings for all filter pools and subsystems
|
||||
ISubSystemConfigurationProxy[] proxies = getSystemRegistryUIInternal().getSubSystemConfigurationProxies();
|
||||
ISubSystemConfigurationProxy[] proxies = getSystemRegistryInternal().getSubSystemConfigurationProxies();
|
||||
if (proxies != null)
|
||||
for (int idx=0; idx < proxies.length; idx++)
|
||||
proxies[idx].reset();
|
||||
|
@ -589,7 +587,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
|
|||
{
|
||||
if (isSystemRegistryActive())
|
||||
{
|
||||
ISubSystemConfigurationProxy[] proxies = getSystemRegistryUIInternal().getSubSystemConfigurationProxies();
|
||||
ISubSystemConfigurationProxy[] proxies = getSystemRegistryInternal().getSubSystemConfigurationProxies();
|
||||
if (proxies != null)
|
||||
{
|
||||
for (int idx=0; idx < proxies.length; idx++)
|
||||
|
@ -645,7 +643,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
|
|||
* Return the SystemRegistry singleton.
|
||||
* Clients should use static @{link getTheSystemRegistry()} instead.
|
||||
*/
|
||||
private SystemRegistry getSystemRegistryUIInternal()
|
||||
private SystemRegistry getSystemRegistryInternal()
|
||||
{
|
||||
if (_systemRegistry == null)
|
||||
{
|
||||
|
@ -663,6 +661,20 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
|
|||
return _systemRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the SystemRegistryUI singleton.
|
||||
* Clients should use static @{link getTheSystemRegistry()} instead.
|
||||
*/
|
||||
private SystemRegistryUI getSystemRegistryUIInternal()
|
||||
{
|
||||
if (_systemRegistryUI == null)
|
||||
{
|
||||
String logfilePath = getStateLocation().toOSString();
|
||||
_systemRegistryUI = SystemRegistryUI.getInstance(logfilePath);
|
||||
}
|
||||
return _systemRegistryUI;
|
||||
}
|
||||
|
||||
/**
|
||||
* A static version for convenience
|
||||
* Returns the master registry singleton.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2002, 2007 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
|
||||
|
@ -11,7 +11,7 @@
|
|||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* Martin Oberhuber (Wind River) - [186773] split SystemRegistryUI from SystemRegistry implementation
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.ui.view;
|
||||
|
@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
public interface ISystemViewInputProvider extends IAdaptable {
|
||||
|
||||
/**
|
||||
* @return the children objects to consistute the root elements in the system view tree
|
||||
* @return the children objects to constitute the root elements in the system view tree
|
||||
*/
|
||||
public Object[] getSystemViewRoots();
|
||||
|
||||
|
@ -87,6 +87,7 @@ public interface ISystemViewInputProvider extends IAdaptable {
|
|||
public void setViewer(Viewer viewer);
|
||||
|
||||
/**
|
||||
* Return the viewer we are currently associated with
|
||||
* @return the viewer we are currently associated with
|
||||
*/
|
||||
// TODO should possibly be deprecated or removed
|
||||
|
|
|
@ -340,11 +340,11 @@ public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizar
|
|||
if (systemType.getId().equals(IRSESystemType.SYSTEMTYPE_ISERIES_ID)) {
|
||||
ISubSystem[] objSubSystems = sr.getSubSystemsBySubSystemConfigurationCategory("nativefiles", conn); //$NON-NLS-1$
|
||||
if ((objSubSystems != null) && (objSubSystems.length > 0))// might be in product that doesn't have iSeries plugins
|
||||
sr.expandSubSystem(objSubSystems[0]);
|
||||
RSEUIPlugin.getTheSystemRegistryUI().expandSubSystem(objSubSystems[0]);
|
||||
else
|
||||
sr.expandHost(conn);
|
||||
RSEUIPlugin.getTheSystemRegistryUI().expandHost(conn);
|
||||
} else
|
||||
sr.expandHost(conn);
|
||||
RSEUIPlugin.getTheSystemRegistryUI().expandHost(conn);
|
||||
}
|
||||
|
||||
lastProfile = form.getProfileName();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
|
||||
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
||||
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
|
||||
* Martin Oberhuber (Wind River) - [186773] split SystemRegistryUI from SystemRegistry implementation
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.ui.internal.model;
|
||||
|
@ -35,13 +36,9 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.rse.core.IRSESystemType;
|
||||
import org.eclipse.rse.core.IRSEUserIdConstants;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
|
@ -85,38 +82,22 @@ import org.eclipse.rse.internal.core.model.SystemModelChangeEventManager;
|
|||
import org.eclipse.rse.internal.core.model.SystemPreferenceChangeManager;
|
||||
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
||||
import org.eclipse.rse.internal.core.model.SystemRemoteChangeEventManager;
|
||||
import org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable;
|
||||
import org.eclipse.rse.internal.ui.view.SystemPerspectiveHelpers;
|
||||
import org.eclipse.rse.internal.ui.view.SystemView;
|
||||
import org.eclipse.rse.internal.ui.view.SystemViewDataDropAdapter;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.RSESystemTypeAdapter;
|
||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||
import org.eclipse.rse.ui.SystemBasePlugin;
|
||||
import org.eclipse.rse.ui.SystemPreferencesManager;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.model.ISystemRegistryUI;
|
||||
import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.rse.ui.view.ISystemViewInputProvider;
|
||||
import org.eclipse.rse.ui.view.SystemAdapterHelpers;
|
||||
import org.eclipse.swt.dnd.Clipboard;
|
||||
import org.eclipse.swt.dnd.FileTransfer;
|
||||
import org.eclipse.swt.dnd.TextTransfer;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.part.PluginTransfer;
|
||||
import org.eclipse.ui.part.PluginTransferData;
|
||||
import org.eclipse.ui.part.ResourceTransfer;
|
||||
|
||||
/**
|
||||
* Registry for all connections.
|
||||
*/
|
||||
public class SystemRegistry implements ISystemRegistry, ISystemRegistryUI, ISystemViewInputProvider
|
||||
public class SystemRegistry implements ISystemRegistry
|
||||
{
|
||||
private static Exception lastException = null;
|
||||
private static SystemRegistry registry = null;
|
||||
|
@ -133,15 +114,6 @@ public class SystemRegistry implements ISystemRegistry, ISystemRegistryUI, ISyst
|
|||
|
||||
private ISubSystemConfigurationProxy[] subsystemFactoryProxies = null;
|
||||
private boolean errorLoadingFactory = false;
|
||||
private Viewer viewer = null;
|
||||
// progress monitor support
|
||||
private IRunnableContext currentRunnableContext;
|
||||
private Shell currentRunnableContextShell;
|
||||
private Vector previousRunnableContexts = new Vector();
|
||||
private Vector previousRunnableContextShells = new Vector();
|
||||
|
||||
private Clipboard clipboard = null;
|
||||
private SystemScratchpad scratchpad = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -209,83 +181,6 @@ public class SystemRegistry implements ISystemRegistry, ISystemRegistryUI, ISyst
|
|||
// return path;
|
||||
// }
|
||||
|
||||
// ----------------------------------
|
||||
// UI METHODS...
|
||||
// ----------------------------------
|
||||
/**
|
||||
* Show the RSE perspective if it is not already showing
|
||||
*/
|
||||
public void showRSEPerspective()
|
||||
{
|
||||
SystemPerspectiveHelpers.openRSEPerspective();
|
||||
}
|
||||
/**
|
||||
* Expand the given connection in the RSE, if the RSE is the active perspective.
|
||||
*/
|
||||
public void expandHost(IHost conn)
|
||||
{
|
||||
if (SystemPerspectiveHelpers.isRSEPerspectiveActive())
|
||||
{
|
||||
// find the RSE tree view
|
||||
SystemView rseView = SystemPerspectiveHelpers.findRSEView();
|
||||
if (rseView != null)
|
||||
{
|
||||
// find and expand the given connection
|
||||
rseView.setExpandedState(conn, true); // expand this connection
|
||||
rseView.setSelection(new StructuredSelection(conn));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Expand the given subsystem in the RSE, if the RSE is the active perspective.
|
||||
*/
|
||||
public void expandSubSystem(ISubSystem subsystem)
|
||||
{
|
||||
if (SystemPerspectiveHelpers.isRSEPerspectiveActive())
|
||||
{
|
||||
// find the RSE tree view
|
||||
SystemView rseView = SystemPerspectiveHelpers.findRSEView();
|
||||
if (rseView != null)
|
||||
{
|
||||
// find and expand the given subsystem's connection, and then subsystem
|
||||
rseView.setExpandedState(subsystem.getHost(), true); // expand this connection
|
||||
rseView.setExpandedState(subsystem, true);
|
||||
rseView.setSelection(new StructuredSelection(subsystem));
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----------------------------------
|
||||
// SYSTEMVIEWINPUTPROVIDER METHODS...
|
||||
// ----------------------------------
|
||||
/**
|
||||
* Return the children objects to consistute the root elements in the system view tree.
|
||||
* We return all connections for all active profiles.
|
||||
*/
|
||||
public Object[] getSystemViewRoots()
|
||||
{
|
||||
//DKM - only return enabled connections now
|
||||
IHost[] connections = getHosts();
|
||||
List result = new ArrayList();
|
||||
for (int i = 0; i < connections.length; i++) {
|
||||
IHost con = connections[i];
|
||||
IRSESystemType sysType = con.getSystemType();
|
||||
if (sysType != null) { // sysType can be null if workspace contains a host that is no longer defined by the workbench
|
||||
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(RSESystemTypeAdapter.class));
|
||||
// Note: System types without registered subsystems get disabled by the adapter itself!
|
||||
// There is no need to re-check this here again.
|
||||
if (adapter.isEnabled(sysType)) result.add(con);
|
||||
}
|
||||
}
|
||||
return result.toArray();
|
||||
}
|
||||
/**
|
||||
* Return true if {@link #getSystemViewRoots()} will return a non-empty list
|
||||
* We return true if there are any connections for any active profile.
|
||||
*/
|
||||
public boolean hasSystemViewRoots()
|
||||
{
|
||||
return (getHostCount() > 0);
|
||||
}
|
||||
/**
|
||||
* This method is called by the connection adapter when the user expands
|
||||
* a connection. This method must return the child objects to show for that
|
||||
|
@ -330,184 +225,15 @@ public class SystemRegistry implements ISystemRegistry, ISystemRegistryUI, ISyst
|
|||
return hasSubsystems;
|
||||
*/
|
||||
}
|
||||
/**
|
||||
* This is the method required by the IAdaptable interface.
|
||||
* Given an adapter class type, return an object castable to the type, or
|
||||
* null if this is not possible.
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter(Class adapterType)
|
||||
{
|
||||
return Platform.getAdapterManager().getAdapter(this, adapterType);
|
||||
}
|
||||
/**
|
||||
* Set the shell in case it is needed for anything.
|
||||
* The label and content provider will call this.
|
||||
*/
|
||||
public void setShell(Shell shell)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the shell of the current viewer
|
||||
*/
|
||||
|
||||
// thread safe shell
|
||||
public Shell getShell()
|
||||
{
|
||||
IWorkbench workbench = RSEUIPlugin.getDefault().getWorkbench();
|
||||
if (workbench != null)
|
||||
{
|
||||
// first try to get the active workbench window
|
||||
IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow();
|
||||
if (ww == null) // no active window so just get the first one
|
||||
ww = workbench.getWorkbenchWindows()[0];
|
||||
if (ww != null)
|
||||
{
|
||||
Shell shell = ww.getShell();
|
||||
if (!shell.isDisposed())
|
||||
{
|
||||
return shell;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true to show the action bar (ie, toolbar) above the viewer.
|
||||
* The action bar contains connection actions, predominantly.
|
||||
*/
|
||||
public boolean showActionBar()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Return true to show the button bar above the viewer.
|
||||
* The tool bar contains "Get List" and "Refresh" buttons and is typicall
|
||||
* shown in dialogs that list only remote system objects.
|
||||
*/
|
||||
public boolean showButtonBar()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Return true to show right-click popup actions on objects in the tree.
|
||||
*/
|
||||
public boolean showActions()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Set the viewer in case it is needed for anything.
|
||||
* The label and content provider will call this.
|
||||
*/
|
||||
public void setViewer(Viewer viewer)
|
||||
{
|
||||
this.viewer = viewer;
|
||||
}
|
||||
/**
|
||||
* Return the viewer we are currently associated with
|
||||
*/
|
||||
public Viewer getViewer()
|
||||
{
|
||||
return viewer;
|
||||
}
|
||||
/**
|
||||
* Return true if we are listing connections or not, so we know whether we are interested in
|
||||
* connection-add events
|
||||
*/
|
||||
public boolean showingConnections()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// ACTIVE PROGRESS MONITOR METHODS...
|
||||
// ----------------------------------
|
||||
/**
|
||||
* Set the current active runnable context to be used for a progress monitor
|
||||
* by the subsystem methods that go to the host. Called by wizards and dialogs
|
||||
* that have a built-in progress monitor and hence removes the need to popup
|
||||
* an intrusive pm dialog.
|
||||
* <p><b>You must call clearRunnableContext when your dialog/wizard is disposed!</b>
|
||||
* @param shell The shell of the wizard/dialog. This is recorded so it can be tested if
|
||||
* it is disposed before attempting to use the context
|
||||
* @param context The dialog/wizard/view that implements IRunnableContext
|
||||
*/
|
||||
public void setRunnableContext(Shell shell, IRunnableContext context)
|
||||
{
|
||||
//this.currentRunnableContext = context;
|
||||
//this.currentRunnableContextShell = shell;
|
||||
pushRunnableContext(shell, context);
|
||||
}
|
||||
/**
|
||||
* Clear the current active runnable context to be used for a progress monitor.
|
||||
* Be sure to call this from you dispose method.
|
||||
*/
|
||||
public void clearRunnableContext()
|
||||
{
|
||||
//this.currentRunnableContext = null;
|
||||
//this.currentRunnableContextShell = null;
|
||||
popRunnableContext();
|
||||
}
|
||||
/**
|
||||
* Return the current registered runnable context, or null if none registered. Use this
|
||||
* for long running operations instead of an intrusive progress monitor dialog as it is
|
||||
* more user friendly. Many dialogs/wizards have these built in so it behooves us to use it.
|
||||
*/
|
||||
public IRunnableContext getRunnableContext()
|
||||
{
|
||||
if ((currentRunnableContextShell != null) && currentRunnableContextShell.isDisposed())
|
||||
clearRunnableContext();
|
||||
if (currentRunnableContext != null)
|
||||
return currentRunnableContext;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private IRunnableContext popRunnableContext()
|
||||
{
|
||||
Shell shell = null;
|
||||
boolean found = false;
|
||||
Vector disposedShells = new Vector();
|
||||
Vector disposedContexts = new Vector();
|
||||
for (int idx = previousRunnableContextShells.size() - 1; !found && (idx >= 0); idx--)
|
||||
{
|
||||
shell = (Shell) previousRunnableContextShells.elementAt(idx);
|
||||
if ((shell == currentRunnableContextShell) || shell.isDisposed())
|
||||
{
|
||||
disposedShells.add(shell);
|
||||
disposedContexts.add(previousRunnableContexts.elementAt(idx));
|
||||
}
|
||||
else
|
||||
{
|
||||
found = true;
|
||||
currentRunnableContextShell = shell;
|
||||
currentRunnableContext = (IRunnableContext) previousRunnableContexts.elementAt(idx);
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
currentRunnableContextShell = null;
|
||||
currentRunnableContext = null;
|
||||
}
|
||||
for (int idx = 0; idx < disposedShells.size(); idx++)
|
||||
{
|
||||
previousRunnableContextShells.remove(disposedShells.elementAt(idx));
|
||||
previousRunnableContexts.remove(disposedContexts.elementAt(idx));
|
||||
}
|
||||
|
||||
return currentRunnableContext;
|
||||
}
|
||||
|
||||
private IRunnableContext pushRunnableContext(Shell shell, IRunnableContext context)
|
||||
{
|
||||
previousRunnableContexts.addElement(context);
|
||||
previousRunnableContextShells.addElement(shell);
|
||||
currentRunnableContextShell = shell;
|
||||
currentRunnableContext = context;
|
||||
return currentRunnableContext;
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
// SUBSYSTEM FACTORY METHODS...
|
||||
|
@ -1951,183 +1677,6 @@ public class SystemRegistry implements ISystemRegistry, ISystemRegistryUI, ISyst
|
|||
return (String[])v.toArray(new String[v.size()]);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#getSystemClipboard()
|
||||
*/
|
||||
public Clipboard getSystemClipboard()
|
||||
{
|
||||
if (clipboard == null)
|
||||
{
|
||||
Display display = null;
|
||||
Shell shell = getShell();
|
||||
if (shell == null)
|
||||
{
|
||||
display = Display.getDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
display = shell.getDisplay();
|
||||
}
|
||||
clipboard = new Clipboard(display);
|
||||
}
|
||||
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for decoding an source object ID to the actual source object.
|
||||
* We determine the profile, connection and subsystem, and then
|
||||
* we use the SubSystem.getObjectWithKey() method to get at the
|
||||
* object.
|
||||
*
|
||||
*/
|
||||
private Object getObjectFor(String str)
|
||||
{
|
||||
// first extract subsystem id
|
||||
int connectionDelim = str.indexOf(":"); //$NON-NLS-1$
|
||||
if (connectionDelim == -1) // not subsystem, therefore likely to be a connection
|
||||
{
|
||||
int profileDelim = str.indexOf("."); //$NON-NLS-1$
|
||||
if (profileDelim != -1)
|
||||
{
|
||||
String profileId = str.substring(0, profileDelim);
|
||||
String connectionId = str.substring(profileDelim + 1, str.length());
|
||||
ISystemProfile profile = registry.getSystemProfile(profileId);
|
||||
return registry.getHost(profile, connectionId);
|
||||
}
|
||||
}
|
||||
|
||||
int subsystemDelim = str.indexOf(":", connectionDelim + 1); //$NON-NLS-1$
|
||||
|
||||
String subSystemId = str.substring(0, subsystemDelim);
|
||||
String srcKey = str.substring(subsystemDelim + 1, str.length());
|
||||
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
ISubSystem subSystem = registry.getSubSystem(subSystemId);
|
||||
if (subSystem != null)
|
||||
{
|
||||
Object result = null;
|
||||
try
|
||||
{
|
||||
result = subSystem.getObjectWithAbsoluteName(srcKey);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
return e.getSystemMessage();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_FILE_NOTFOUND);
|
||||
msg.makeSubstitution(srcKey, subSystem.getHostAliasName());
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_CONNECTION_NOTFOUND);
|
||||
msg.makeSubstitution(subSystemId);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.ISystemRegistry#getSystemClipboardObjects(int)
|
||||
*/
|
||||
public List getSystemClipboardObjects(int srcType)
|
||||
{
|
||||
Clipboard clipboard = getSystemClipboard();
|
||||
ArrayList srcObjects = new ArrayList();
|
||||
Object object = null;
|
||||
|
||||
if (srcType == SystemDNDTransferRunnable.SRC_TYPE_RSE_RESOURCE)
|
||||
{
|
||||
|
||||
// determine the source objects
|
||||
object = clipboard.getContents(PluginTransfer.getInstance());
|
||||
|
||||
if (object instanceof PluginTransferData)
|
||||
{
|
||||
// RSE transfer
|
||||
PluginTransferData data = (PluginTransferData) object;
|
||||
byte[] result = data.getData();
|
||||
|
||||
//StringTokenizer tokenizer = new StringTokenizer(new String(result), SystemViewDataDropAdapter.RESOURCE_SEPARATOR);
|
||||
String[] tokens = (new String(result)).split("\\"+SystemViewDataDropAdapter.RESOURCE_SEPARATOR); //$NON-NLS-1$
|
||||
|
||||
for (int i = 0;i < tokens.length; i++)
|
||||
{
|
||||
String srcStr = tokens[i];
|
||||
|
||||
Object srcObject = getObjectFor(srcStr);
|
||||
srcObjects.add(srcObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (srcType == SystemDNDTransferRunnable.SRC_TYPE_ECLIPSE_RESOURCE)
|
||||
{
|
||||
// Resource transfer
|
||||
ResourceTransfer resTransfer = ResourceTransfer.getInstance();
|
||||
object = clipboard.getContents(resTransfer);
|
||||
if (object != null)
|
||||
{
|
||||
IResource[] resourceData = (IResource[]) object;
|
||||
for (int i = 0; i < resourceData.length; i++)
|
||||
{
|
||||
srcObjects.add(resourceData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (srcType == SystemDNDTransferRunnable.SRC_TYPE_OS_RESOURCE)
|
||||
{
|
||||
// Local File transfer
|
||||
FileTransfer fileTransfer = FileTransfer.getInstance();
|
||||
object = clipboard.getContents(fileTransfer);
|
||||
if (object != null)
|
||||
{
|
||||
String[] fileData = (String[]) object;
|
||||
{
|
||||
for (int i = 0; i < fileData.length; i++)
|
||||
{
|
||||
srcObjects.add(fileData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (srcType == SystemDNDTransferRunnable.SRC_TYPE_TEXT)
|
||||
{
|
||||
TextTransfer textTransfer = TextTransfer.getInstance();
|
||||
object = clipboard.getContents(textTransfer);
|
||||
if (object != null)
|
||||
{
|
||||
String textData = (String) object;
|
||||
srcObjects.add(textData);
|
||||
}
|
||||
}
|
||||
return srcObjects;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the remote systems scratchpad root
|
||||
*/
|
||||
public SystemScratchpad getSystemScratchPad()
|
||||
{
|
||||
if (scratchpad == null)
|
||||
{
|
||||
scratchpad = new SystemScratchpad();
|
||||
}
|
||||
return scratchpad;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.ISystemRegistry#createLocalHost(org.eclipse.rse.core.model.ISystemProfile, java.lang.String, java.lang.String)
|
||||
|
@ -2912,28 +2461,6 @@ public class SystemRegistry implements ISystemRegistry, ISystemRegistryUI, ISyst
|
|||
{
|
||||
l.systemResourceChanged(event);
|
||||
}
|
||||
/**
|
||||
* Notify all listeners of a change to a system resource such as a connection.
|
||||
* You would not normally call this as the methods in this class call it when appropriate.
|
||||
* <p>
|
||||
* This version calls fireEvent at the next reasonable opportunity, leveraging SWT's
|
||||
* Display.asyncExec() method.
|
||||
*/
|
||||
public void postEvent(ISystemResourceChangeEvent event)
|
||||
{
|
||||
listenerManager.postNotify(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify a specific listener of a change to a system resource such as a connection.
|
||||
* <p>
|
||||
* This version calls fireEvent at the next reasonable opportunity, leveraging SWT's
|
||||
* Display.asyncExec() method.
|
||||
*/
|
||||
public void postEvent(ISystemResourceChangeListener listener, ISystemResourceChangeEvent event)
|
||||
{
|
||||
new SystemPostableEventNotifier(listener, event); // create and run the notifier
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
// MODEL RESOURCE EVENT METHODS...
|
||||
|
|
|
@ -0,0 +1,601 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186773] split SystemRegistryUI from SystemRegistry implementation
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.ui.internal.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.rse.core.IRSESystemType;
|
||||
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.ISystemProfile;
|
||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable;
|
||||
import org.eclipse.rse.internal.ui.view.SystemPerspectiveHelpers;
|
||||
import org.eclipse.rse.internal.ui.view.SystemView;
|
||||
import org.eclipse.rse.internal.ui.view.SystemViewDataDropAdapter;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.RSESystemTypeAdapter;
|
||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||
import org.eclipse.rse.ui.model.ISystemRegistryUI;
|
||||
import org.eclipse.rse.ui.view.ISystemViewInputProvider;
|
||||
import org.eclipse.swt.dnd.Clipboard;
|
||||
import org.eclipse.swt.dnd.FileTransfer;
|
||||
import org.eclipse.swt.dnd.TextTransfer;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.part.PluginTransfer;
|
||||
import org.eclipse.ui.part.PluginTransferData;
|
||||
import org.eclipse.ui.part.ResourceTransfer;
|
||||
|
||||
/**
|
||||
* Registry and control center for RSE UI related operations.
|
||||
*
|
||||
* This class is not intended to be subclassed by clients.
|
||||
*/
|
||||
public class SystemRegistryUI implements ISystemRegistryUI, ISystemViewInputProvider {
|
||||
|
||||
private static SystemRegistryUI _instance = null;
|
||||
private ISystemRegistry registry = null;
|
||||
|
||||
private SystemResourceChangeManager listenerManager = null;
|
||||
private Viewer viewer = null;
|
||||
|
||||
// progress monitor support
|
||||
private IRunnableContext currentRunnableContext;
|
||||
private Shell currentRunnableContextShell;
|
||||
private Vector previousRunnableContexts = new Vector();
|
||||
private Vector previousRunnableContextShells = new Vector();
|
||||
|
||||
private Clipboard clipboard = null;
|
||||
private SystemScratchpad scratchpad = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* This is protected as the singleton instance should be retrieved by
|
||||
* calling @link{#getInstance()}.
|
||||
* @param logfilePath Root folder. Where to place the log file.
|
||||
*/
|
||||
protected SystemRegistryUI(String logfilePath)
|
||||
{
|
||||
super();
|
||||
registry = RSECorePlugin.getTheSystemRegistry();
|
||||
listenerManager = new SystemResourceChangeManager();
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
// PUBLIC STATIC METHODS...
|
||||
// ----------------------------
|
||||
|
||||
/**
|
||||
* Return singleton instance. Must be used on first instantiate.
|
||||
* @param logfilePath Root folder. Where to place the log file.
|
||||
* @return the singleton SystemRegistryUI instance.
|
||||
*/
|
||||
public static SystemRegistryUI getInstance(String logfilePath)
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new SystemRegistryUI(logfilePath);
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return singleton instance assuming it already exists.
|
||||
* @return the singleton SystemRegistryUI instance.
|
||||
*/
|
||||
public static SystemRegistryUI getInstance()
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// UI METHODS...
|
||||
// ----------------------------------
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#showRSEPerspective()
|
||||
*/
|
||||
public void showRSEPerspective()
|
||||
{
|
||||
SystemPerspectiveHelpers.openRSEPerspective();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#expandHost(org.eclipse.rse.core.model.IHost)
|
||||
*/
|
||||
public void expandHost(IHost conn)
|
||||
{
|
||||
if (SystemPerspectiveHelpers.isRSEPerspectiveActive())
|
||||
{
|
||||
// find the RSE tree view
|
||||
SystemView rseView = SystemPerspectiveHelpers.findRSEView();
|
||||
if (rseView != null)
|
||||
{
|
||||
// find and expand the given connection
|
||||
rseView.setExpandedState(conn, true); // expand this connection
|
||||
rseView.setSelection(new StructuredSelection(conn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#expandSubSystem(org.eclipse.rse.core.subsystems.ISubSystem)
|
||||
*/
|
||||
public void expandSubSystem(ISubSystem subsystem)
|
||||
{
|
||||
if (SystemPerspectiveHelpers.isRSEPerspectiveActive())
|
||||
{
|
||||
// find the RSE tree view
|
||||
SystemView rseView = SystemPerspectiveHelpers.findRSEView();
|
||||
if (rseView != null)
|
||||
{
|
||||
// find and expand the given subsystem's connection, and then subsystem
|
||||
rseView.setExpandedState(subsystem.getHost(), true); // expand this connection
|
||||
rseView.setExpandedState(subsystem, true);
|
||||
rseView.setSelection(new StructuredSelection(subsystem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// SYSTEMVIEWINPUTPROVIDER METHODS...
|
||||
// ----------------------------------
|
||||
|
||||
/**
|
||||
* Return the children objects to constitute the root elements in the system view tree.
|
||||
* We return all connections for all active profiles.
|
||||
*/
|
||||
public Object[] getSystemViewRoots()
|
||||
{
|
||||
//DKM - only return enabled connections now
|
||||
IHost[] connections = registry.getHosts();
|
||||
List result = new ArrayList();
|
||||
for (int i = 0; i < connections.length; i++) {
|
||||
IHost con = connections[i];
|
||||
IRSESystemType sysType = con.getSystemType();
|
||||
if (sysType != null) { // sysType can be null if workspace contains a host that is no longer defined by the workbench
|
||||
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(RSESystemTypeAdapter.class));
|
||||
// Note: System types without registered subsystems get disabled by the adapter itself!
|
||||
// There is no need to re-check this here again.
|
||||
if (adapter.isEnabled(sysType)) result.add(con);
|
||||
}
|
||||
}
|
||||
return result.toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if {@link #getSystemViewRoots()} will return a non-empty list
|
||||
* We return true if there are any connections for any active profile.
|
||||
*/
|
||||
public boolean hasSystemViewRoots()
|
||||
{
|
||||
return (registry.getHostCount() > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.view.ISystemViewInputProvider#getConnectionChildren(org.eclipse.rse.core.model.IHost)
|
||||
*/
|
||||
public Object[] getConnectionChildren(IHost selectedConnection)
|
||||
{
|
||||
return registry.getConnectionChildren(selectedConnection);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.view.ISystemViewInputProvider#hasConnectionChildren(org.eclipse.rse.core.model.IHost)
|
||||
*/
|
||||
public boolean hasConnectionChildren(IHost selectedConnection)
|
||||
{
|
||||
return registry.hasConnectionChildren(selectedConnection);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter(Class adapterType)
|
||||
{
|
||||
return Platform.getAdapterManager().getAdapter(this, adapterType);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.view.ISystemViewInputProvider#setShell(org.eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
public void setShell(Shell shell)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemShellProvider#getShell()
|
||||
*/
|
||||
public Shell getShell()
|
||||
{
|
||||
// thread safe shell
|
||||
IWorkbench workbench = RSEUIPlugin.getDefault().getWorkbench();
|
||||
if (workbench != null)
|
||||
{
|
||||
// first try to get the active workbench window
|
||||
IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow();
|
||||
if (ww == null) // no active window so just get the first one
|
||||
ww = workbench.getWorkbenchWindows()[0];
|
||||
if (ww != null)
|
||||
{
|
||||
Shell shell = ww.getShell();
|
||||
if (!shell.isDisposed())
|
||||
{
|
||||
return shell;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true to show the action bar (i.e., toolbar) above the viewer.
|
||||
* The action bar contains connection actions, predominantly.
|
||||
*/
|
||||
public boolean showActionBar()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true to show the button bar above the viewer.
|
||||
* The tool bar contains "Get List" and "Refresh" buttons and is typically
|
||||
* shown in dialogs that list only remote system objects.
|
||||
*/
|
||||
public boolean showButtonBar()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true to show right-click popup actions on objects in the tree.
|
||||
*/
|
||||
public boolean showActions()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.view.ISystemViewInputProvider#setViewer(org.eclipse.jface.viewers.Viewer)
|
||||
*/
|
||||
public void setViewer(Viewer viewer)
|
||||
{
|
||||
this.viewer = viewer;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.view.ISystemViewInputProvider#getViewer()
|
||||
*/
|
||||
public Viewer getViewer()
|
||||
{
|
||||
return viewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if we are listing connections or not, so we know whether
|
||||
* we are interested in connection-add events
|
||||
*/
|
||||
public boolean showingConnections()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// ACTIVE PROGRESS MONITOR METHODS...
|
||||
// ----------------------------------
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#setRunnableContext(org.eclipse.swt.widgets.Shell, org.eclipse.jface.operation.IRunnableContext)
|
||||
*/
|
||||
public void setRunnableContext(Shell shell, IRunnableContext context)
|
||||
{
|
||||
//this.currentRunnableContext = context;
|
||||
//this.currentRunnableContextShell = shell;
|
||||
pushRunnableContext(shell, context);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#clearRunnableContext()
|
||||
*/
|
||||
public void clearRunnableContext()
|
||||
{
|
||||
//this.currentRunnableContext = null;
|
||||
//this.currentRunnableContextShell = null;
|
||||
popRunnableContext();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#getRunnableContext()
|
||||
*/
|
||||
public IRunnableContext getRunnableContext()
|
||||
{
|
||||
if ((currentRunnableContextShell != null) && currentRunnableContextShell.isDisposed())
|
||||
clearRunnableContext();
|
||||
if (currentRunnableContext != null)
|
||||
return currentRunnableContext;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private IRunnableContext popRunnableContext()
|
||||
{
|
||||
Shell shell = null;
|
||||
boolean found = false;
|
||||
Vector disposedShells = new Vector();
|
||||
Vector disposedContexts = new Vector();
|
||||
for (int idx = previousRunnableContextShells.size() - 1; !found && (idx >= 0); idx--)
|
||||
{
|
||||
shell = (Shell) previousRunnableContextShells.elementAt(idx);
|
||||
if ((shell == currentRunnableContextShell) || shell.isDisposed())
|
||||
{
|
||||
disposedShells.add(shell);
|
||||
disposedContexts.add(previousRunnableContexts.elementAt(idx));
|
||||
}
|
||||
else
|
||||
{
|
||||
found = true;
|
||||
currentRunnableContextShell = shell;
|
||||
currentRunnableContext = (IRunnableContext) previousRunnableContexts.elementAt(idx);
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
currentRunnableContextShell = null;
|
||||
currentRunnableContext = null;
|
||||
}
|
||||
for (int idx = 0; idx < disposedShells.size(); idx++)
|
||||
{
|
||||
previousRunnableContextShells.remove(disposedShells.elementAt(idx));
|
||||
previousRunnableContexts.remove(disposedContexts.elementAt(idx));
|
||||
}
|
||||
|
||||
return currentRunnableContext;
|
||||
}
|
||||
|
||||
private IRunnableContext pushRunnableContext(Shell shell, IRunnableContext context)
|
||||
{
|
||||
previousRunnableContexts.addElement(context);
|
||||
previousRunnableContextShells.addElement(shell);
|
||||
currentRunnableContextShell = shell;
|
||||
currentRunnableContext = context;
|
||||
return currentRunnableContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#getSystemClipboard()
|
||||
*/
|
||||
public Clipboard getSystemClipboard()
|
||||
{
|
||||
if (clipboard == null)
|
||||
{
|
||||
Display display = null;
|
||||
Shell shell = getShell();
|
||||
if (shell == null)
|
||||
{
|
||||
display = Display.getDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
display = shell.getDisplay();
|
||||
}
|
||||
clipboard = new Clipboard(display);
|
||||
}
|
||||
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for decoding an source object ID to the actual source object.
|
||||
* We determine the profile, connection and subsystem, and then
|
||||
* we use the SubSystem.getObjectWithKey() method to get at the
|
||||
* object.
|
||||
*/
|
||||
private Object getObjectFor(String str)
|
||||
{
|
||||
// first extract subsystem id
|
||||
int connectionDelim = str.indexOf(":"); //$NON-NLS-1$
|
||||
if (connectionDelim == -1) // not subsystem, therefore likely to be a connection
|
||||
{
|
||||
int profileDelim = str.indexOf("."); //$NON-NLS-1$
|
||||
if (profileDelim != -1)
|
||||
{
|
||||
String profileId = str.substring(0, profileDelim);
|
||||
String connectionId = str.substring(profileDelim + 1, str.length());
|
||||
ISystemProfile profile = registry.getSystemProfile(profileId);
|
||||
return registry.getHost(profile, connectionId);
|
||||
}
|
||||
}
|
||||
|
||||
int subsystemDelim = str.indexOf(":", connectionDelim + 1); //$NON-NLS-1$
|
||||
|
||||
String subSystemId = str.substring(0, subsystemDelim);
|
||||
String srcKey = str.substring(subsystemDelim + 1, str.length());
|
||||
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
ISubSystem subSystem = registry.getSubSystem(subSystemId);
|
||||
if (subSystem != null)
|
||||
{
|
||||
Object result = null;
|
||||
try
|
||||
{
|
||||
result = subSystem.getObjectWithAbsoluteName(srcKey);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
return e.getSystemMessage();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_FILE_NOTFOUND);
|
||||
msg.makeSubstitution(srcKey, subSystem.getHostAliasName());
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_CONNECTION_NOTFOUND);
|
||||
msg.makeSubstitution(subSystemId);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.model.ISystemRegistry#getSystemClipboardObjects(int)
|
||||
*/
|
||||
public List getSystemClipboardObjects(int srcType)
|
||||
{
|
||||
Clipboard clipboard = getSystemClipboard();
|
||||
ArrayList srcObjects = new ArrayList();
|
||||
Object object = null;
|
||||
|
||||
if (srcType == SystemDNDTransferRunnable.SRC_TYPE_RSE_RESOURCE)
|
||||
{
|
||||
|
||||
// determine the source objects
|
||||
object = clipboard.getContents(PluginTransfer.getInstance());
|
||||
|
||||
if (object instanceof PluginTransferData)
|
||||
{
|
||||
// RSE transfer
|
||||
PluginTransferData data = (PluginTransferData) object;
|
||||
byte[] result = data.getData();
|
||||
|
||||
//StringTokenizer tokenizer = new StringTokenizer(new String(result), SystemViewDataDropAdapter.RESOURCE_SEPARATOR);
|
||||
String[] tokens = (new String(result)).split("\\"+SystemViewDataDropAdapter.RESOURCE_SEPARATOR); //$NON-NLS-1$
|
||||
|
||||
for (int i = 0;i < tokens.length; i++)
|
||||
{
|
||||
String srcStr = tokens[i];
|
||||
|
||||
Object srcObject = getObjectFor(srcStr);
|
||||
srcObjects.add(srcObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (srcType == SystemDNDTransferRunnable.SRC_TYPE_ECLIPSE_RESOURCE)
|
||||
{
|
||||
// Resource transfer
|
||||
ResourceTransfer resTransfer = ResourceTransfer.getInstance();
|
||||
object = clipboard.getContents(resTransfer);
|
||||
if (object != null)
|
||||
{
|
||||
IResource[] resourceData = (IResource[]) object;
|
||||
for (int i = 0; i < resourceData.length; i++)
|
||||
{
|
||||
srcObjects.add(resourceData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (srcType == SystemDNDTransferRunnable.SRC_TYPE_OS_RESOURCE)
|
||||
{
|
||||
// Local File transfer
|
||||
FileTransfer fileTransfer = FileTransfer.getInstance();
|
||||
object = clipboard.getContents(fileTransfer);
|
||||
if (object != null)
|
||||
{
|
||||
String[] fileData = (String[]) object;
|
||||
{
|
||||
for (int i = 0; i < fileData.length; i++)
|
||||
{
|
||||
srcObjects.add(fileData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (srcType == SystemDNDTransferRunnable.SRC_TYPE_TEXT)
|
||||
{
|
||||
TextTransfer textTransfer = TextTransfer.getInstance();
|
||||
object = clipboard.getContents(textTransfer);
|
||||
if (object != null)
|
||||
{
|
||||
String textData = (String) object;
|
||||
srcObjects.add(textData);
|
||||
}
|
||||
}
|
||||
return srcObjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remote systems scratchpad root
|
||||
*/
|
||||
public SystemScratchpad getSystemScratchPad()
|
||||
{
|
||||
if (scratchpad == null)
|
||||
{
|
||||
scratchpad = new SystemScratchpad();
|
||||
}
|
||||
return scratchpad;
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
// RESOURCE EVENT METHODS...
|
||||
// ----------------------------
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#postEvent(org.eclipse.rse.core.events.ISystemResourceChangeEvent)
|
||||
*/
|
||||
public void postEvent(ISystemResourceChangeEvent event)
|
||||
{
|
||||
listenerManager.postNotify(event);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.model.ISystemRegistryUI#postEvent(org.eclipse.rse.core.events.ISystemResourceChangeListener, org.eclipse.rse.core.events.ISystemResourceChangeEvent)
|
||||
*/
|
||||
public void postEvent(ISystemResourceChangeListener listener, ISystemResourceChangeEvent event)
|
||||
{
|
||||
new SystemPostableEventNotifier(listener, event); // create and run the notifier
|
||||
}
|
||||
|
||||
}
|
|
@ -21,16 +21,41 @@ import java.util.List;
|
|||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
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.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.ui.view.ISystemViewInputProvider;
|
||||
import org.eclipse.swt.dnd.Clipboard;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* Registry or front door for all remote system connections.
|
||||
* Registry and control center for RSE UI related operations.
|
||||
*
|
||||
* This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ISystemRegistryUI
|
||||
extends ISystemShellProvider, ISystemViewInputProvider {
|
||||
|
||||
// ----------------------------------
|
||||
// UI METHODS...
|
||||
// ----------------------------------
|
||||
|
||||
/**
|
||||
* Show the RSE perspective if it is not already showing
|
||||
*/
|
||||
public void showRSEPerspective();
|
||||
|
||||
/**
|
||||
* Select and expand the given connection in the RSE, if the RSE is the active perspective.
|
||||
* @param conn the host connection to expand
|
||||
*/
|
||||
public void expandHost(IHost conn);
|
||||
|
||||
/**
|
||||
* Select and expand the given subsystem in the RSE, if the RSE is the active perspective.
|
||||
* @param subsystem the subsystem to expand
|
||||
*/
|
||||
public void expandSubSystem(ISubSystem subsystem);
|
||||
|
||||
/**
|
||||
* Returns the clipboard used for copy actions
|
||||
*/
|
||||
|
@ -43,23 +68,6 @@ public interface ISystemRegistryUI
|
|||
*/
|
||||
public List getSystemClipboardObjects(int srcType);
|
||||
|
||||
/**
|
||||
* Notify all listeners of a change to a system resource such as a connection.
|
||||
* You would not normally call this as the methods in this class call it when appropriate.
|
||||
* <p>
|
||||
* This version calls fireEvent at the next reasonable opportunity, leveraging SWT's
|
||||
* Display.asyncExec() method.
|
||||
*/
|
||||
public void postEvent(ISystemResourceChangeEvent event);
|
||||
|
||||
/**
|
||||
* Notify a specific listener of a change to a system resource such as a connection.
|
||||
* <p>
|
||||
* This version calls fireEvent at the next reasonable opportunity, leveraging SWT's
|
||||
* Display.asyncExec() method.
|
||||
*/
|
||||
public void postEvent(ISystemResourceChangeListener listener, ISystemResourceChangeEvent event);
|
||||
|
||||
// ----------------------------------
|
||||
// ACTIVE PROGRESS MONITOR METHODS...
|
||||
// ----------------------------------
|
||||
|
@ -89,4 +97,25 @@ public interface ISystemRegistryUI
|
|||
*/
|
||||
public IRunnableContext getRunnableContext();
|
||||
|
||||
// ----------------------------
|
||||
// RESOURCE EVENT METHODS...
|
||||
// ----------------------------
|
||||
|
||||
/**
|
||||
* Notify all listeners of a change to a system resource such as a connection.
|
||||
* You would not normally call this as the methods in this class call it when appropriate.
|
||||
* <p>
|
||||
* This version calls fireEvent at the next reasonable opportunity, leveraging SWT's
|
||||
* Display.asyncExec() method.
|
||||
*/
|
||||
public void postEvent(ISystemResourceChangeEvent event);
|
||||
|
||||
/**
|
||||
* Notify a specific listener of a change to a system resource such as a connection.
|
||||
* <p>
|
||||
* This version calls fireEvent at the next reasonable opportunity, leveraging SWT's
|
||||
* Display.asyncExec() method.
|
||||
*/
|
||||
public void postEvent(ISystemResourceChangeListener listener, ISystemResourceChangeEvent event);
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.rse.tests.RSETestsPlugin;
|
|||
import org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil;
|
||||
import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties;
|
||||
import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
|
||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||
|
||||
/**
|
||||
* Test cases for FTP based remote host access.
|
||||
|
@ -82,7 +83,7 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase {
|
|||
connection = getConnectionManager().findOrCreateConnection(properties);
|
||||
assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$
|
||||
// expand the connection in the UI
|
||||
systemRegistry.expandHost(connection);
|
||||
RSEUIPlugin.getTheSystemRegistryUI().expandHost(connection);
|
||||
|
||||
Exception exception = null;
|
||||
String cause = null;
|
||||
|
@ -136,7 +137,7 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase {
|
|||
if (!subSystem.isConnected() || !ftpService.isConnected()) return;
|
||||
|
||||
// expand the subsystem
|
||||
systemRegistry.expandSubSystem(subSystem);
|
||||
RSEUIPlugin.getTheSystemRegistryUI().expandSubSystem(subSystem);
|
||||
|
||||
// now we have the service reference and can start reading things from the server
|
||||
IHostFile[] roots = ftpService.getRoots(new NullProgressMonitor());
|
||||
|
|
Loading…
Add table
Reference in a new issue