1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 20:45:22 +02:00

Fix copyright date

This commit is contained in:
Martin Oberhuber 2009-01-19 10:42:55 +00:00
parent 4687de711b
commit c13aba8b0b

View file

@ -1,15 +1,15 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2008 IBM Corporation. All rights reserved. * Copyright (c) 2009 IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the terms * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight. * component that contains this file: David McKnight.
* *
* Contributors: * Contributors:
* David McKnight (IBM) - [160105] [usability] Universal action needed to locate a resource in the Remote Systems View * David McKnight (IBM) - [160105] [usability] Universal action needed to locate a resource in the Remote Systems View
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.ui.actions; package org.eclipse.rse.internal.ui.actions;
@ -62,7 +62,7 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
private ISystemTree _systemTree; private ISystemTree _systemTree;
private IAdaptable _targetRemoteObj; private IAdaptable _targetRemoteObj;
private ISystemFilterReference _filterReference; private ISystemFilterReference _filterReference;
public ShowChildrenInTree(Object parentObject, Object[] children, ISystemFilterReference filterReference, ISystemTree systemTree, IAdaptable targetRemoteObj) public ShowChildrenInTree(Object parentObject, Object[] children, ISystemFilterReference filterReference, ISystemTree systemTree, IAdaptable targetRemoteObj)
{ {
_parentObject = parentObject; _parentObject = parentObject;
@ -71,14 +71,14 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
_targetRemoteObj = targetRemoteObj; _targetRemoteObj = targetRemoteObj;
_filterReference = filterReference; _filterReference = filterReference;
} }
private String getAbsolutePath(IAdaptable adaptable){ private String getAbsolutePath(IAdaptable adaptable){
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class); ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class);
return adapter.getAbsoluteName(adaptable); return adapter.getAbsoluteName(adaptable);
} }
public void run() public void run()
{ {
if (_filterReference != null){ if (_filterReference != null){
// make sure the filter is expanded // make sure the filter is expanded
_systemTree.revealAndExpand(_filterReference.getSubSystem(), _filterReference.getReferencedFilter()); _systemTree.revealAndExpand(_filterReference.getSubSystem(), _filterReference.getReferencedFilter());
@ -92,19 +92,19 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
item.setExpanded(true); item.setExpanded(true);
} }
} }
Vector matches = new Vector(); Vector matches = new Vector();
_systemTree.findAllRemoteItemReferences(_parentObject, _parentObject, matches); _systemTree.findAllRemoteItemReferences(_parentObject, _parentObject, matches);
if (matches.size() > 0){ if (matches.size() > 0){
TreeItem item = (TreeItem)matches.get(0); TreeItem item = (TreeItem)matches.get(0);
_systemTree.createTreeItems(item, _children); _systemTree.createTreeItems(item, _children);
item.setExpanded(true); item.setExpanded(true);
IAdaptable container = null; IAdaptable container = null;
String targetPath = getAbsolutePath(_targetRemoteObj); String targetPath = getAbsolutePath(_targetRemoteObj);
// is one of these items our remote object // is one of these items our remote object
for (int i = 0; i < item.getItemCount(); i++){ for (int i = 0; i < item.getItemCount(); i++){
TreeItem childItem = item.getItem(i); TreeItem childItem = item.getItem(i);
@ -112,7 +112,7 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
if (data instanceof IAdaptable){ if (data instanceof IAdaptable){
IAdaptable childObj = (IAdaptable)data; IAdaptable childObj = (IAdaptable)data;
String childPath = getAbsolutePath(childObj); String childPath = getAbsolutePath(childObj);
if (childPath.equals(targetPath)){ if (childPath.equals(targetPath)){
// select our remote file // select our remote file
_systemTree.getTree().setSelection(childItem); _systemTree.getTree().setSelection(childItem);
@ -121,11 +121,11 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
else if (targetPath.startsWith(childPath)){ else if (targetPath.startsWith(childPath)){
container = childObj; // using this to start a deeper search for the target remote file container = childObj; // using this to start a deeper search for the target remote file
} }
} }
} }
// remote file not found so now we have to expand further // remote file not found so now we have to expand further
if (container != null){ if (container != null){
LinkFromContainerJob job = new LinkFromContainerJob(container, _filterReference, _targetRemoteObj, _systemTree); LinkFromContainerJob job = new LinkFromContainerJob(container, _filterReference, _targetRemoteObj, _systemTree);
job.schedule(); job.schedule();
} }
@ -140,23 +140,23 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
private ISubSystem _subSystem; private ISubSystem _subSystem;
private IAdaptable _targetRemoteObj; private IAdaptable _targetRemoteObj;
private ISystemTree _systemTree; private ISystemTree _systemTree;
public LinkFromFilterJob(IAdaptable targetRemoteObject, ISystemTree systemTree) { public LinkFromFilterJob(IAdaptable targetRemoteObject, ISystemTree systemTree) {
super(NLS.bind(CommonMessages.MSG_RESOLVE_PROGRESS, ShowInSystemsViewDelegate.getAdapter(targetRemoteObject).getAbsoluteName(targetRemoteObject))); super(NLS.bind(CommonMessages.MSG_RESOLVE_PROGRESS, ShowInSystemsViewDelegate.getAdapter(targetRemoteObject).getAbsoluteName(targetRemoteObject)));
_targetRemoteObj = targetRemoteObject; _targetRemoteObj = targetRemoteObject;
_subSystem = getSubSystem(_targetRemoteObj); _subSystem = getSubSystem(_targetRemoteObj);
_systemTree = systemTree; _systemTree = systemTree;
} }
private ISubSystem getSubSystem(IAdaptable adaptable) private ISubSystem getSubSystem(IAdaptable adaptable)
{ {
ISystemViewElementAdapter adapter = ShowInSystemsViewDelegate.getAdapter(adaptable); ISystemViewElementAdapter adapter = ShowInSystemsViewDelegate.getAdapter(adaptable);
return adapter.getSubSystem(adaptable); return adapter.getSubSystem(adaptable);
} }
public IStatus run(IProgressMonitor monitor){ public IStatus run(IProgressMonitor monitor){
try try
{ {
@ -170,24 +170,24 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
// get the context // get the context
ContextObject contextObject = new ContextObject(ref, _subSystem, ref); ContextObject contextObject = new ContextObject(ref, _subSystem, ref);
// get the children // get the children
Object[] children = ShowInSystemsViewDelegate.getAdapter((IAdaptable)ref).getChildren(contextObject, monitor); Object[] children = ShowInSystemsViewDelegate.getAdapter((IAdaptable)ref).getChildren(contextObject, monitor);
if (monitor.isCanceled()){ if (monitor.isCanceled()){
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
} }
// put these items in the tree and look for remoteFile // put these items in the tree and look for remoteFile
// if we can't find the remote file under this filter, the ShowChildrenInTree will recurse // if we can't find the remote file under this filter, the ShowChildrenInTree will recurse
Display.getDefault().asyncExec(new ShowChildrenInTree(ref, children, ref, _systemTree, _targetRemoteObj)); Display.getDefault().asyncExec(new ShowChildrenInTree(ref, children, ref, _systemTree, _targetRemoteObj));
} }
catch (Exception e){ catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
return Status.OK_STATUS; return Status.OK_STATUS;
} }
private ISystemFilterReference findMatchingFilterReference(IAdaptable targetObj, IProgressMonitor monitor) private ISystemFilterReference findMatchingFilterReference(IAdaptable targetObj, IProgressMonitor monitor)
{ {
String remoteObjectName = getAbsolutePath(targetObj); String remoteObjectName = getAbsolutePath(targetObj);
@ -201,30 +201,30 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
return ref; return ref;
} }
} }
// not finding it..use registry to try this // not finding it..use registry to try this
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
List matches = sr.findFilterReferencesFor(targetObj, _subSystem, false); List matches = sr.findFilterReferencesFor(targetObj, _subSystem, false);
if (matches != null && matches.size() > 0){ if (matches != null && matches.size() > 0){
return (ISystemFilterReference)matches.get(0); return (ISystemFilterReference)matches.get(0);
} }
// child may be deep in the tree and not directly under a filter // child may be deep in the tree and not directly under a filter
ISystemViewElementAdapter adapter = ShowInSystemsViewDelegate.getAdapter(targetObj); ISystemViewElementAdapter adapter = ShowInSystemsViewDelegate.getAdapter(targetObj);
Object parent = adapter.getParent(targetObj); Object parent = adapter.getParent(targetObj);
ISystemFilterReference filterRef = findMatchingFilterReference((IAdaptable)parent, monitor); ISystemFilterReference filterRef = findMatchingFilterReference((IAdaptable)parent, monitor);
if (filterRef != null){ if (filterRef != null){
return filterRef; return filterRef;
} }
} }
return null; return null;
} }
private String getAbsolutePath(IAdaptable adaptable){ private String getAbsolutePath(IAdaptable adaptable){
ISystemViewElementAdapter adapter = ShowInSystemsViewDelegate.getAdapter(adaptable); ISystemViewElementAdapter adapter = ShowInSystemsViewDelegate.getAdapter(adaptable);
return adapter.getAbsoluteName(adaptable); return adapter.getAbsoluteName(adaptable);
} }
private boolean doesFilterEncompass(ISystemFilter filter, String remoteObjectAbsoluteName) private boolean doesFilterEncompass(ISystemFilter filter, String remoteObjectAbsoluteName)
{ {
boolean would = false; boolean would = false;
@ -236,33 +236,33 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
would = true; would = true;
else if (strings[idx].equals("./*")) //$NON-NLS-1$ else if (strings[idx].equals("./*")) //$NON-NLS-1$
{ {
// my home filter - will encompass iff remoteObjectAbsoluteName is within the home dir // my home filter - will encompass iff remoteObjectAbsoluteName is within the home dir
try try
{ {
IAdaptable homeObj = (IAdaptable)_subSystem.getObjectWithAbsoluteName(".", new NullProgressMonitor()); //$NON-NLS-1$ IAdaptable homeObj = (IAdaptable)_subSystem.getObjectWithAbsoluteName(".", new NullProgressMonitor()); //$NON-NLS-1$
if (homeObj != null){ if (homeObj != null){
String homePath = getAbsolutePath(homeObj); String homePath = getAbsolutePath(homeObj);
would = remoteObjectAbsoluteName.startsWith(homePath); would = remoteObjectAbsoluteName.startsWith(homePath);
} }
} }
catch (Exception e){ catch (Exception e){
} }
} }
else else
would = doesFilterStringEncompass(strings[idx], remoteObjectAbsoluteName); would = doesFilterStringEncompass(strings[idx], remoteObjectAbsoluteName);
} }
} }
return would; return would;
} }
private boolean doesFilterStringEncompass(String filterString, String remoteObjectAbsoluteName) private boolean doesFilterStringEncompass(String filterString, String remoteObjectAbsoluteName)
{ {
return false; return false;
} }
} }
/** /**
* Job for doing a query on a container and then using Display.asyncExec() to reveal the results in the tree. * Job for doing a query on a container and then using Display.asyncExec() to reveal the results in the tree.
*/ */
@ -273,62 +273,62 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
private IAdaptable _targetRemoteObj; private IAdaptable _targetRemoteObj;
private ISystemTree _systemTree; private ISystemTree _systemTree;
private ISystemFilterReference _filterRef; private ISystemFilterReference _filterRef;
public LinkFromContainerJob(IAdaptable remoteContainer, ISystemFilterReference filterRef, IAdaptable targetRemoteObj, ISystemTree systemTree) { public LinkFromContainerJob(IAdaptable remoteContainer, ISystemFilterReference filterRef, IAdaptable targetRemoteObj, ISystemTree systemTree) {
super(NLS.bind(CommonMessages.MSG_RESOLVE_PROGRESS, ShowInSystemsViewDelegate.getAdapter(remoteContainer).getAbsoluteName(targetRemoteObj))); super(NLS.bind(CommonMessages.MSG_RESOLVE_PROGRESS, ShowInSystemsViewDelegate.getAdapter(remoteContainer).getAbsoluteName(targetRemoteObj)));
_remoteContainer = remoteContainer; _remoteContainer = remoteContainer;
_subSystem = getSubSystem(remoteContainer); _subSystem = getSubSystem(remoteContainer);
_filterRef = filterRef; // used for context of query _filterRef = filterRef; // used for context of query
_targetRemoteObj = targetRemoteObj; _targetRemoteObj = targetRemoteObj;
_systemTree = systemTree; _systemTree = systemTree;
} }
private ISubSystem getSubSystem(IAdaptable adaptable) private ISubSystem getSubSystem(IAdaptable adaptable)
{ {
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class); ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class);
return adapter.getSubSystem(adaptable); return adapter.getSubSystem(adaptable);
} }
public IStatus run(IProgressMonitor monitor){ public IStatus run(IProgressMonitor monitor){
try try
{ {
// get the adapter // get the adapter
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)_remoteContainer.getAdapter(ISystemViewElementAdapter.class); ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)_remoteContainer.getAdapter(ISystemViewElementAdapter.class);
// get the context // get the context
ContextObject contextObject = new ContextObject(_remoteContainer, _subSystem, _filterRef); ContextObject contextObject = new ContextObject(_remoteContainer, _subSystem, _filterRef);
// get the children // get the children
Object[] children = adapter.getChildren(contextObject, monitor); Object[] children = adapter.getChildren(contextObject, monitor);
if (monitor.isCanceled()){ if (monitor.isCanceled()){
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
} }
// put these items in the tree and look for remoteFile // put these items in the tree and look for remoteFile
// if we can't find the remote file under this filter, the ShowChildrenInTree will recurse // if we can't find the remote file under this filter, the ShowChildrenInTree will recurse
Display.getDefault().asyncExec(new ShowChildrenInTree(_remoteContainer, children, _filterRef, _systemTree, _targetRemoteObj)); Display.getDefault().asyncExec(new ShowChildrenInTree(_remoteContainer, children, _filterRef, _systemTree, _targetRemoteObj));
} }
catch (Exception e){ catch (Exception e){
} }
return Status.OK_STATUS; return Status.OK_STATUS;
} }
} }
private IAction _action; private IAction _action;
private Object _remoteObject; private Object _remoteObject;
private SystemViewPart _systemViewPart; private SystemViewPart _systemViewPart;
public void init(IViewPart view) { public void init(IViewPart view) {
} }
public void run(IAction action) { public void run(IAction action) {
SystemViewPart viewPart = activateSystemView(); SystemViewPart viewPart = activateSystemView();
SystemView systemTree = viewPart.getSystemView(); SystemView systemTree = viewPart.getSystemView();
// now we've got to show the object in this view part // now we've got to show the object in this view part
TreeItem item = (TreeItem)systemTree.findFirstRemoteItemReference(_remoteObject, null); TreeItem item = (TreeItem)systemTree.findFirstRemoteItemReference(_remoteObject, null);
if (item != null){ if (item != null){
@ -339,7 +339,7 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)_remoteObject).getAdapter(ISystemViewElementAdapter.class); ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)_remoteObject).getAdapter(ISystemViewElementAdapter.class);
if (adapter != null){ if (adapter != null){
ISubSystem subSystem = adapter.getSubSystem(_remoteObject); ISubSystem subSystem = adapter.getSubSystem(_remoteObject);
if (subSystem.getSubSystemConfiguration().supportsFilters()){ if (subSystem.getSubSystemConfiguration().supportsFilters()){
// no match, so we will expand from filter // no match, so we will expand from filter
// query matching filter in a job (to avoid main thread) // query matching filter in a job (to avoid main thread)
LinkFromFilterJob job = new LinkFromFilterJob((IAdaptable)_remoteObject, systemTree); LinkFromFilterJob job = new LinkFromFilterJob((IAdaptable)_remoteObject, systemTree);
@ -348,13 +348,13 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
else { else {
// no filters so need to directly check children // no filters so need to directly check children
Object[] children = subSystem.getChildren(); Object[] children = subSystem.getChildren();
// put these items in the tree and look for remote object // put these items in the tree and look for remote object
// if we can't find the remote object under this, the ShowChildrenInTree will recurse // if we can't find the remote object under this, the ShowChildrenInTree will recurse
Display.getDefault().asyncExec(new ShowChildrenInTree(subSystem, children, null, systemTree, (IAdaptable)_remoteObject)); Display.getDefault().asyncExec(new ShowChildrenInTree(subSystem, children, null, systemTree, (IAdaptable)_remoteObject));
} }
} }
} }
} }
@ -373,7 +373,7 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
return _systemViewPart; return _systemViewPart;
} }
public void selectionChanged(IAction action, ISelection selection) { public void selectionChanged(IAction action, ISelection selection) {
if (_action == null) { if (_action == null) {
_action= action; _action= action;
@ -381,13 +381,13 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
IStructuredSelection sel = (IStructuredSelection)selection; IStructuredSelection sel = (IStructuredSelection)selection;
if (sel.size() == 1){ if (sel.size() == 1){
_action.setEnabled(true); _action.setEnabled(true);
_remoteObject = sel.getFirstElement(); _remoteObject = sel.getFirstElement();
} }
else { else {
_action.setEnabled(false); _action.setEnabled(false);
} }
} }
public static ISystemViewElementAdapter getAdapter(IAdaptable adaptable) public static ISystemViewElementAdapter getAdapter(IAdaptable adaptable)
{ {
return (ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class); return (ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class);