From 076bb8c5c895c65ac98a4aad0e240b6a961c5a9b Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Thu, 24 Jul 2008 14:00:56 +0000 Subject: [PATCH] [241722] Add safeguards for selecting newly created files with deferred queries --- .../rse/internal/ui/view/SystemView.java | 839 +++++++++--------- 1 file changed, 424 insertions(+), 415 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java index 5907fd5c398..69860fade60 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java @@ -1,15 +1,15 @@ /******************************************************************************** * Copyright (c) 2002, 2008 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 + * 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, + * 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: * Kevin Doyle (IBM) - [180875] - Removed part of double click listener that opens files * Michael Berger (IBM) - Patch to remove non-standard expand/collapse from menu. @@ -26,7 +26,7 @@ * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter() * Martin Oberhuber (Wind River) - [186964] Fix adapter actions for multiselect, and and NPE - * Martin Oberhuber (Wind River) - [186991] Avoid remote refresh if no element is remote + * Martin Oberhuber (Wind River) - [186991] Avoid remote refresh if no element is remote * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core * Kevin Doyle (IBM) - [194602] handleDoubleClick does expand/collapse on treepath instead of element * David McKnight (IBM) - [194897] Should not remote refresh objects above subsystem. @@ -65,7 +65,6 @@ package org.eclipse.rse.internal.ui.view; -import java.io.FileReader; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; @@ -103,7 +102,6 @@ import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.ITreePathContentProvider; import org.eclipse.jface.viewers.ITreeSelection; import org.eclipse.jface.viewers.ITreeViewerListener; -import org.eclipse.jface.viewers.LabelProviderChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeExpansionEvent; @@ -231,7 +229,7 @@ public class SystemView extends SafeTreeViewer ISystemResourceChangeListener, ISystemRemoteChangeListener, IMenuListener, IPostSelectionProvider, ISystemDeleteTarget, ISystemRenameTarget, ISystemSelectAllTarget, - ISelectionChangedListener, ITreeViewerListener + ISelectionChangedListener, ITreeViewerListener { protected Shell shell; // shell hosting this viewer: TODO can be removed @@ -256,8 +254,8 @@ public class SystemView extends SafeTreeViewer // global actions: to be accessed by getters only // Note the Edit menu actions are set in SystemViewPart. Here we use these // actions from our own popup menu actions. - private SystemCommonDeleteAction _deleteAction; // for global delete menu item - private SystemCommonRenameAction _renameAction; // for common rename menu item + private SystemCommonDeleteAction _deleteAction; // for global delete menu item + private SystemCommonRenameAction _renameAction; // for common rename menu item private SystemCommonSelectAllAction _selectAllAction; // for common Ctrl+A select-all // special flags needed when building popup menu, set after examining selections protected boolean selectionShowPropertiesAction; @@ -361,7 +359,7 @@ public class SystemView extends SafeTreeViewer } /** - * Constructor to use when you create your own tree widget. + * Constructor to use when you create your own tree widget. * @param shell The shell hosting this tree viewer widget * @param tree The Tree widget you created. * @param inputProvider The input object which will supply the initial root objects in the tree. @@ -442,12 +440,12 @@ public class SystemView extends SafeTreeViewer protected void init() { _setList = new ArrayList(); busyCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT); - + setUseHashlookup(true); // new for our 2nd release. Attempt to fix 38 minutes to refresh for 15K elements - setComparer(new ElementComparer()); - - - + setComparer(new ElementComparer()); + + + // set content provider SystemViewLabelAndContentProvider lcProvider = new SystemViewLabelAndContentProvider(); setLabelAndContentProvider(lcProvider); @@ -462,7 +460,7 @@ public class SystemView extends SafeTreeViewer fromSystemViewPart = ((messageLine != null) && (messageLine instanceof SystemViewPart)); - // set the tree's input. Provides initial roots. + // set the tree's input. Provides initial roots. if (inputProvider != null) { inputProvider.setViewer(this); setInput(inputProvider); @@ -489,7 +487,7 @@ public class SystemView extends SafeTreeViewer getTree().setMenu(menu); // ------------------------------------------- // Enable specific keys: dbl-click, Delete, F5 - // ------------------------------------------- + // ------------------------------------------- addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { handleDoubleClick(event); @@ -502,7 +500,7 @@ public class SystemView extends SafeTreeViewer }); getControl().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { - mouseButtonPressed = e.button; //d40615 + mouseButtonPressed = e.button; //d40615 if (!enabledMode) { //e.doit = false; return; @@ -522,13 +520,13 @@ public class SystemView extends SafeTreeViewer protected void initRefreshKey() { /* DKM - no need for explicit key listener since we * have global action - getControl().addKeyListener(new KeyAdapter() + getControl().addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent event) + public void keyReleased(KeyEvent event) { if (!enabledMode) return; - if (event.keyCode == SWT.F5) + if (event.keyCode == SWT.F5) { //if (debug) // System.out.println("F5 pressed"); @@ -578,13 +576,13 @@ public class SystemView extends SafeTreeViewer /* DKM - 53694 if (showDelete() && canDelete()) { - + SystemCommonDeleteAction dltAction = (SystemCommonDeleteAction)getDeleteAction(); dltAction.setShell(getShell()); dltAction.setSelection(getSelection()); dltAction.setViewer(this); dltAction.run(); - + } */ } else if ((event.character == '-') && (event.stateMask == SWT.CTRL)) { @@ -844,7 +842,7 @@ public class SystemView extends SafeTreeViewer * This is method is called to populate the popup menu */ public void fillContextMenu(IMenuManager menu) { - + if (!showActions) return; //SystemViewPlugin.getDefault().logMessage("inside fillContextMenu"); IStructuredSelection selection = (IStructuredSelection) getSelection(); @@ -862,7 +860,7 @@ public class SystemView extends SafeTreeViewer if (!allSelectionsFromSameParent) { if (selectionHasAncestryRelationship()) { // don't show the menu because actions with - // multiple select on objects that are ancestors + // multiple select on objects that are ancestors // of each other is problematic // still create the standard groups createStandardGroups(menu); @@ -904,20 +902,20 @@ public class SystemView extends SafeTreeViewer ((ISystemAction) getDeleteAction()).setInputs(getShell(), this, selection); menu.add(new Separator()); } - + // PROPERTIES ACTION... // This is supplied by the system, so we pretty much get it for free. It finds the // registered propertyPages extension points registered for the selected object's class type. - //_propertyDialogAction.selectionChanged(selection); + //_propertyDialogAction.selectionChanged(selection); if (showProperties()) { PropertyDialogAction pdAction = getPropertyDialogAction(); if (pdAction.isApplicableForSelection()) menu.appendToGroup(ISystemContextMenuConstants.GROUP_PROPERTIES, pdAction); } - + // GO INTO ACTION... // OPEN IN NEW WINDOW ACTION... if (fromSystemViewPart) { - + Object selectedObject = selection.getFirstElement(); ISystemViewElementAdapter adapter = getViewAdapter(selectedObject); boolean hasChildren = adapter.hasChildren((IAdaptable)selectedObject); @@ -934,7 +932,7 @@ public class SystemView extends SafeTreeViewer menu.appendToGroup(ISystemContextMenuConstants.GROUP_GOTO, goIntoAction); } } - + if (showOpenViewActions()) { SystemOpenExplorerPerspectiveAction opa = getOpenToPerspectiveAction(); @@ -942,7 +940,7 @@ public class SystemView extends SafeTreeViewer menu.appendToGroup(opa.getContextMenuGroup(), opa); } } - + if (showGenericShowInTableAction() && hasChildren) { SystemShowInTableAction showInTableAction = getShowInTableAction(); showInTableAction.setSelection(selection); @@ -954,7 +952,7 @@ public class SystemView extends SafeTreeViewer } } - + // GO TO CASCADING ACTIONS... if (fromSystemViewPart && (selectionIsRemoteObject || showOpenViewActions())) { SystemCascadingGoToAction gotoActions = getGoToActions(); @@ -962,11 +960,11 @@ public class SystemView extends SafeTreeViewer menu.appendToGroup(gotoActions.getContextMenuGroup(), gotoActions.getSubMenu()); } - // ADAPTER SPECIFIC ACTIONS (Must be the last actions added to the menu!!!) + // ADAPTER SPECIFIC ACTIONS (Must be the last actions added to the menu!!!) SystemMenuManager ourMenu = new SystemMenuManager(menu); - // yantzi:artemis 6.0 (defect 53970), do not show adapter specific actions when - // there is not a common adapter for all selected elements (i.e. there are 2 or + // yantzi:artemis 6.0 (defect 53970), do not show adapter specific actions when + // there is not a common adapter for all selected elements (i.e. there are 2 or // more selected elements that have different adapters Iterator elements = selection.iterator(); //Hashtable adapters = new Hashtable(); @@ -997,21 +995,21 @@ public class SystemView extends SafeTreeViewer //{ // ISystemViewElementAdapter nextAdapter = (ISystemViewElementAdapter)uniqueAdapters.nextElement(); adapter.addActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADAPTERS); - + if (adapter instanceof AbstractSystemViewAdapter) { - + AbstractSystemViewAdapter aVA = (AbstractSystemViewAdapter)adapter; - + // add dynamic menu popups aVA.addDynamicPopupMenuActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADDITIONS); - + // add remote actions aVA.addCommonRemoteActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADAPTERS); } //} } - + // whale through all actions, updating shell and selection IContributionItem[] items = menu.getItems(); @@ -1029,8 +1027,8 @@ public class SystemView extends SafeTreeViewer } } - // ***** DO NOT ADD ANY ACTIONS AFTER HERE ***** - + // ***** DO NOT ADD ANY ACTIONS AFTER HERE ***** + } } @@ -1077,7 +1075,7 @@ public class SystemView extends SafeTreeViewer menu.add(new Separator(ISystemContextMenuConstants.GROUP_BUILD)); // build, rebuild, refresh menu.add(new Separator(ISystemContextMenuConstants.GROUP_CHANGE)); // update, change menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORGANIZE)); // rename,move,copy,delete,bookmark,refactoring - menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORDER)); // move up, move down + menu.add(new Separator(ISystemContextMenuConstants.GROUP_REORDER)); // move up, move down menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_GENERATE)); // getters/setters, etc. Typically in editor menu.add(new Separator(ISystemContextMenuConstants.GROUP_SEARCH)); // search menu.add(new Separator(ISystemContextMenuConstants.GROUP_CONNECTION)); // connection-related actions @@ -1117,15 +1115,15 @@ public class SystemView extends SafeTreeViewer * Determines whether the view has an ancestor relation selection so * that actions can be enable/disabled appropriately. * For example, delete needs to be disabled when a parent and it's child - * are both selected. + * are both selected. * @return true if the selection has one or more ancestor relations */ protected boolean hasAncestorRelationSelection() { return selectionHasAncestryRelationship(); /* TreeItem[] elements = getTree().getSelection(); - - + + //Item[] elements = getSelection(getControl()); for (int i = 0; i < elements.length; i++) { TreeItem parentItem = elements[i]; @@ -1138,7 +1136,7 @@ public class SystemView extends SafeTreeViewer //} // } } - return false; + return false; */ } @@ -1165,7 +1163,7 @@ public class SystemView extends SafeTreeViewer if (adapter == null) continue; if (enableDelete) enableDelete = adapter.showDelete(element) && adapter.canDelete(element); } - //System.out.println("Enabling delete action: "+enableDelete); + //System.out.println("Enabling delete action: "+enableDelete); //System.out.println("Enabling selectAll action: "+enableSelectAll(sel)); ((SystemCommonDeleteAction) getDeleteAction()).setEnabled(enableDelete); ((SystemCommonSelectAllAction) getSelectAllAction()).setEnabled(enableSelectAll(sel)); // added by Phil. Noticed Edit->Select All not enabled when it should be @@ -1174,7 +1172,7 @@ public class SystemView extends SafeTreeViewer if (adapter != null) { displayMessage(adapter.getStatusLineText(firstSelection)); if ((mouseButtonPressed == LEFT_BUTTON) && (!expandingTreeOnly)) //d40615 - adapter.selectionChanged(firstSelection); //d40615 + adapter.selectionChanged(firstSelection); //d40615 } else clearMessage(); //System.out.println("Inside selectionChanged in SystemView"); @@ -1183,7 +1181,7 @@ public class SystemView extends SafeTreeViewer protected void logMyDebugMessage(String prefix, String msg) { if (!debugProperties) return; - //RSEUIPlugin.logDebugMessage(prefix, msg); + //RSEUIPlugin.logDebugMessage(prefix, msg); System.out.println(prefix + " " + msg); //$NON-NLS-1$ } @@ -1299,7 +1297,7 @@ public class SystemView extends SafeTreeViewer getShell().getDisplay().asyncExec(new Runnable() { public void run() { String[] allProps = {IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE}; - update(element, allProps); // for refreshing non-structural properties in viewer when model changes + update(element, allProps); // for refreshing non-structural properties in viewer when model changes } }); } @@ -1317,11 +1315,11 @@ public class SystemView extends SafeTreeViewer public void run() { updatePropertySheet(); String[] allProps = { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE }; - update(element, allProps); // for refreshing non-structural properties in viewer when model changes + update(element, allProps); // for refreshing non-structural properties in viewer when model changes } }); } - + /* (non-Javadoc) * Here only for observability. * @see org.eclipse.jface.viewers.AbstractTreeViewer#handleTreeCollapse(org.eclipse.swt.events.TreeEvent) @@ -1365,7 +1363,7 @@ public class SystemView extends SafeTreeViewer } } - + /** * Clear current selection. Ignore widget disposed message. */ @@ -1375,7 +1373,7 @@ public class SystemView extends SafeTreeViewer } catch (Exception exc) { } } - + /** @@ -1406,16 +1404,16 @@ public class SystemView extends SafeTreeViewer * @deprecated should use {@link #getViewAdapter(Object)} since IRemoteObjectIdentifier * is not defined in the adapter factories */ - protected IRemoteObjectIdentifier getRemoteObjectIdentifier(Object o) + protected IRemoteObjectIdentifier getRemoteObjectIdentifier(Object o) { return (IRemoteObjectIdentifier)((IAdaptable)o).getAdapter(IRemoteObjectIdentifier.class); } - + /** * Returns the implementation of ISystemRemoteElementAdapter for the given * object. Returns null if this object is not adaptable to this. */ - protected ISystemRemoteElementAdapter getRemoteAdapter(Object o) + protected ISystemRemoteElementAdapter getRemoteAdapter(Object o) { if (o instanceof IAdaptable) { @@ -1423,7 +1421,7 @@ public class SystemView extends SafeTreeViewer } return null; } - + /** * @@ -1439,7 +1437,7 @@ public class SystemView extends SafeTreeViewer } /** - * Return the connection of the selected object, whatever it is. + * Return the connection of the selected object, whatever it is. */ public IHost getSelectedConnection() { Object firstSelection = ((StructuredSelection) getSelection()).getFirstElement(); @@ -1509,8 +1507,8 @@ public class SystemView extends SafeTreeViewer children = oldResult; } else children = getChildren(parentItem); - - for (int i = 0; i < oldResult.length; i++) + + for (int i = 0; i < oldResult.length; i++) { Item first = removeFirstItem(oldResult, children); newResult[i] = first; @@ -1520,26 +1518,26 @@ public class SystemView extends SafeTreeViewer } - - protected Item removeFirstItem(Item[] items, Item[] children) - { + + protected Item removeFirstItem(Item[] items, Item[] children) + { if (items != null) { - for (int i = 0; i < items.length; i++) + for (int i = 0; i < items.length; i++) { - if (items[i] != null) + if (items[i] != null) { Item current = items[i]; items[i] = null; - return current; + return current; } } } return null; } - - + + /** * Move one tree item to a new location */ @@ -1551,13 +1549,13 @@ public class SystemView extends SafeTreeViewer } if (getExpanded(item)) { setExpanded(item, false); - refresh(src); // flush items from memory + refresh(src); // flush items from memory } createTreeItem(parentItem, src, newPosition); //createTreeItem(parentItem, (new String("New")), newPosition); - //remove(src); + //remove(src); disassociate(item); item.dispose(); @@ -1566,7 +1564,7 @@ public class SystemView extends SafeTreeViewer /** * Move existing items a given number of positions within the same node. - * If the delta is negative, they are all moved up by the given amount. If + * If the delta is negative, they are all moved up by the given amount. If * positive, they are all moved down by the given amount.
*/
protected void moveTreeItems(Widget parentItem, Object[] src, int delta) {
@@ -1575,14 +1573,14 @@ public class SystemView extends SafeTreeViewer
for (int idx = 0; idx < src.length; idx++)
oldItems[idx] = (Item) internalFindRelativeItem(parentItem, src[idx], 1);
-
+
Item[] children = null;
if (parentItem instanceof Item) {
children = getItems((Item) parentItem);
} else
children = getChildren(parentItem);
-
- for (int idx = 0; idx < src.length; idx++)
+
+ for (int idx = 0; idx < src.length; idx++)
{
oldPositions[idx] = getTreeItemPosition(oldItems[idx], children) + 1;
}
@@ -1622,8 +1620,8 @@ public class SystemView extends SafeTreeViewer
return pos;
}
*/
-
-
+
+
/**
* Get the position of a tree item within its parent
*/
@@ -1634,14 +1632,14 @@ public class SystemView extends SafeTreeViewer
}
return pos;
}
-
+
/**
* Expand a given filter, given a subsystem that contains a reference to the filter's pool.
* This will expand down to the filter if needed
* @param parentSubSystem - the subsystem containing a reference to the filter's parent pool
* @param filter - the filter to find, reveal, and expand within the subsystem context
- * @return the filter reference to the filter if found and expanded. This is a unique binary address
+ * @return the filter reference to the filter if found and expanded. This is a unique binary address
* within the object's in this tree, so can be used in the viewer methods to affect this particular
* node.
*/
@@ -1694,12 +1692,12 @@ public class SystemView extends SafeTreeViewer
trace("resource changed while shutting down"); //$NON-NLS-1$
}
}
-
+
public void trace(String str) {
String id = RSEUIPlugin.getDefault().getBundle().getSymbolicName();
String val = Platform.getDebugOption(id + "/debug"); //$NON-NLS-1$
if ("true".equals(val)) { //$NON-NLS-1$
- try {
+ try {
throw new IllegalStateException(str);
} catch(IllegalStateException e) {
e.printStackTrace();
@@ -1738,7 +1736,7 @@ public class SystemView extends SafeTreeViewer
int type = _event.getType();
Object src = _event.getSource();
Object parent = _event.getParent();
-
+
String[] properties = new String[1];
if (parent == RSECorePlugin.getTheSystemRegistry()) parent = inputProvider;
ISubSystem ss = null;
@@ -1829,7 +1827,7 @@ public class SystemView extends SafeTreeViewer
return Status.OK_STATUS;
}
}
-
+
//System.out.println("ADDING CONNECTIONS.........................: " + addingConnection);
//System.out.println("event.getParent() instanceof SystemRegistry: " + (event.getParent() instanceof SystemRegistry));
//System.out.println("inputProvider.showingConnections().........: " + (inputProvider.showingConnections()));
@@ -1841,14 +1839,14 @@ public class SystemView extends SafeTreeViewer
if (pos >= 0) pos++; // want to add after previous
} else
pos = _event.getPosition();
-
+
Item[] currentItems = null;
if (parentItem instanceof Tree)
{
currentItems = ((Tree)parentItem).getItems();
}
else
- {
+ {
currentItems = getItems((Item)parentItem);
}
boolean exists = false;
@@ -1897,7 +1895,7 @@ public class SystemView extends SafeTreeViewer
if (done) return Status.OK_STATUS;
}
// are we adding connections and yet we are not a secondary perspective?
- // If so, this event does not apply to us.
+ // If so, this event does not apply to us.
else if (addingConnections && (_event.getParent() instanceof ISystemRegistry) && !inputProvider.showingConnections()) return Status.OK_STATUS;
for (int idx = 0; idx < multiSource.length; idx++) {
@@ -1918,7 +1916,7 @@ public class SystemView extends SafeTreeViewer
if (parentItem == null) return Status.OK_STATUS;
if (multiSource.length > 0 && parentItem instanceof Item) {
getControl().setRedraw(false);
- collapseNode(parent, true); // collapse and flush gui widgets from memory
+ collapseNode(parent, true); // collapse and flush gui widgets from memory
//setExpandedState(parent, true); // expand the parent
setExpanded((Item) parentItem, true); // expand the parent without calling resolveFilterString
TreeItem[] kids = ((TreeItem) parentItem).getItems(); // any kids? Like a dummy node?
@@ -1949,7 +1947,7 @@ public class SystemView extends SafeTreeViewer
//System.out.println("WAS SELECTED? " + wasSrcSelected);
}
item = findItem(parent);
- //logDebugMsg(" parent = " + parent);
+ //logDebugMsg(" parent = " + parent);
//logDebugMsg(" item = " + item);
// INTERESTING BUG HERE. GETEXPANDED WILL RETURN TRUE IF THE TREE ITEM HAS EVER BEEN
// EXPANDED BUT IS NOW COLLAPSED! I CANNOT FIND ANY API IN TreeItem or TreeViewer THAT
@@ -1962,7 +1960,7 @@ public class SystemView extends SafeTreeViewer
//refresh(parent);
if (debug) System.out.println("Found item and it was expanded for " + parent); //$NON-NLS-1$
getControl().setRedraw(false);
- collapseNode(parent, true); // collapse and flush gui widgets from memory
+ collapseNode(parent, true); // collapse and flush gui widgets from memory
setExpandedState(parent, true); // expand the parent
getControl().setRedraw(true);
if (wasSrcSelected) {
@@ -2013,7 +2011,7 @@ public class SystemView extends SafeTreeViewer
parentItem = ((TreeItem)sitem).getParent();
}
}
- }
+ }
}
if (parentItem == null) {
return Status.OK_STATUS;
@@ -2038,7 +2036,7 @@ public class SystemView extends SafeTreeViewer
}
break;
/* Now done below in systemRemoteResourceChanged
- case EVENT_DELETE_REMOTE:
+ case EVENT_DELETE_REMOTE:
if (debug)
logDebugMsg("SV event: EVENT_DELETE_REMOTE ");
deleteRemoteObject(src);
@@ -2047,19 +2045,19 @@ public class SystemView extends SafeTreeViewer
case EVENT_DELETE_REMOTE_MANY:
// multi-source: array of objects to delete
if (debug)
- logDebugMsg("SV event: EVENT_DELETE_REMOTE_MANY ");
+ logDebugMsg("SV event: EVENT_DELETE_REMOTE_MANY ");
multiSource = event.getMultiSource();
//remoteItemsToSkip = null; // reset
if ((multiSource == null) || (multiSource.length==0))
return;
for (int idx=0; idx
* TODO: This method should not return any invalid matches, i.e. remote objects
@@ -4455,18 +4464,18 @@ public class SystemView extends SafeTreeViewer
* same remote object can appear in multiple contexts in the RSE Tree, a single
* remote object identifier String may evaluate to multiple different matches
* to fill into the matches argument. All those context object matches, however,
- * reference the same real-world model objects due to the constraint that
- * {@link IRemoteObjectIdentifier} uniquely identifies a remote object.
+ * reference the same real-world model objects due to the constraint that
+ * {@link IRemoteObjectIdentifier} uniquely identifies a remote object.
*
* This overload takes a string and a subsystem.
- *
+ *
* @param searchString the absolute name of the remote object to which
* we want to find a tree item which references it.
* @param elementObject the actual remote element to find, for binary matching
* @param subsystem optional subsystem to search within
- * @param matches the List to populate with hits (TreeItem objects),
+ * @param matches the List to populate with hits (TreeItem objects),
* or
* This overload takes a string and a subsystem.
- *
+ *
* @param searchString the absolute name of the remote object to which we want to find a tree item which references it.
* @param elementObject the actual remote element to find, for binary matching
* @param subsystem optional subsystem to search within
@@ -4545,10 +4554,10 @@ public class SystemView extends SafeTreeViewer
protected Item internalFindFirstRemoteItemReference(String searchString, Object elementObject, ISubSystem subsystem) {
Item[] roots = getTree().getItems();
if ((roots == null) || (roots.length == 0)) return null;
-
+
// use map first
Item match = mappedFindFirstRemoteItemReference(elementObject);
-
+
for (int idx = 0; (match == null) && (idx < roots.length); idx++) {
//System.out.println("recursiveFindFirstRemoteItemReference(parentItem, remoteObjectName, remoteObject, subsystem)");
match = recursiveFindFirstRemoteItemReference(roots[idx], searchString, elementObject, subsystem);
@@ -4561,9 +4570,9 @@ public class SystemView extends SafeTreeViewer
{
return (Item)findItem(elementObject);
}
-
+
protected boolean mappedFindAllRemoteItemReferences(Object elementObject, List occurrences)
- {
+ {
Widget[] items = findItems(elementObject);
if (items.length > 0)
{
@@ -4573,10 +4582,10 @@ public class SystemView extends SafeTreeViewer
}
return true;
}
-
+
return false;
}
-
+
/**
* Recursively tries to find all references to a remote object.
* @param parent the parent item at which to start the search.
@@ -4624,21 +4633,21 @@ public class SystemView extends SafeTreeViewer
return occurrences; // they don't match, so don't bother checking the kids
}
// if we are currently visiting a connection, and that connection's hostname is not the same
- // as that of our given subsystem, then we can assume the remote object occurrences we are
+ // as that of our given subsystem, then we can assume the remote object occurrences we are
// looking for are not to be found within this branch...
else if ((rawData instanceof IHost) && (!((IHost) rawData).getHostName().equals(subsystem.getHost().getHostName()))) {
return occurrences; // they don't match, so don't bother checking the kids
}
}
- // recurse over children
+ // recurse over children
Item[] items = getChildren(parent);
for (int i = 0; (i < items.length); i++) {
-
+
if (!items[i].isDisposed()) occurrences = recursiveFindAllRemoteItemReferences(items[i], elementName, elementObject, subsystem, occurrences);
}
return occurrences;
}
-
+
@@ -4649,7 +4658,7 @@ public class SystemView extends SafeTreeViewer
* @param elementName the absolute name of the remote element to find
* @param elementObject the actual remote element to find, for binary matching
* @param subsystem optional subsystem to search within
- * @return TreeItem match if found, null if not found.
+ * @return TreeItem match if found, null if not found.
*/
protected Item recursiveFindFirstRemoteItemReference(Item parent, String elementName, Object elementObject, ISubSystem subsystem) {
Object rawData = parent.getData();
@@ -4692,13 +4701,13 @@ public class SystemView extends SafeTreeViewer
return null; // they don't match, so don't bother checking the kids
}
// if we are currently visiting a connection, and that connection's hostname is not the same
- // as that of our given subsystem, then we can assume the remote object occurrences we are
+ // as that of our given subsystem, then we can assume the remote object occurrences we are
// looking for are not to be found within this branch...
else if ((rawData instanceof IHost) && !((IHost) rawData).getHostName().equals(subsystem.getHost().getHostName())) {
return null; // they don't match, so don't bother checking the kids
}
}
- // recurse over children
+ // recurse over children
Item[] items = getChildren(parent);
Item match = null;
for (int i = 0; (match == null) && (i < items.length); i++) {
@@ -4708,8 +4717,8 @@ public class SystemView extends SafeTreeViewer
}
/**
- * Recursively tries to find all filters affected by a given remote object.
- *
+ * Recursively tries to find all filters affected by a given remote object.
+ *
* @param elementName the absolute name of the remote object to which we want to find a filters which result in it.
* @param subsystem The subsystem which owns the remote resource. Necessary to scope the search for impacted filters.
* @param matches the List to populate with hits. Can be
* Designed to be as fast as possible by going directly to the SWT widgets
*/
@@ -5367,7 +5376,7 @@ public class SystemView extends SafeTreeViewer
protected boolean selectionHasAncestryRelationship() {
if (selectionFlagsUpdated) return selectionHasAncestorRelation;
-
+
Tree tree = getTree();
TreeItem[] items = tree.getSelection();
return hasSelectedAncestor(items);
@@ -5388,7 +5397,7 @@ public class SystemView extends SafeTreeViewer
return false;
*/
}
-
+
protected boolean isAncestorOf(TreeItem container, TreeItem[] items) {
TreeItem[] children = container.getItems();
for (int i = 0; i < children.length; i++) {
@@ -5398,10 +5407,10 @@ public class SystemView extends SafeTreeViewer
TreeItem item = items[j];
if (child == item) {
return true;
- }
- else if (child.getItemCount() > 0)
+ }
+ else if (child.getItemCount() > 0)
{
- if (isAncestorOf(child, items))
+ if (isAncestorOf(child, items))
{
return true;
}
@@ -5410,18 +5419,18 @@ public class SystemView extends SafeTreeViewer
}
return false;
}
-
-
+
+
protected boolean hasSelectedAncestor(TreeItem[] items) {
List cleanParents = new ArrayList();
-
+
for (int j = 0; j < items.length; j++)
{
TreeItem item = items[j];
TreeItem parent = item.getParentItem();
while (parent != null && !cleanParents.contains(parent))
- {
+ {
if (isTreeItemSelected(parent))
{
return true;
@@ -5429,18 +5438,18 @@ public class SystemView extends SafeTreeViewer
else
{
cleanParents.add(parent);
- parent = parent.getParentItem();
+ parent = parent.getParentItem();
}
}
}
return false;
}
-
-
-
-
-
-
+
+
+
+
+
+
/*
protected boolean isAncestorOf(TreeItem container, TreeItem item) {
TreeItem[] children = container.getItems();
@@ -5457,10 +5466,10 @@ public class SystemView extends SafeTreeViewer
return false;
}
*/
-
+
/**
* This is called to accurately get the parent object for the current selection
- * for this viewer.
+ * for this viewer.
*
* The getParent() method in the adapter is very unreliable... adapters can't be sure
* of the context which can change via filtering and view options.
@@ -5584,7 +5593,7 @@ public class SystemView extends SafeTreeViewer
* The array is in reverse order, starting at the leaf and going up.
* This flavor is optimized for the case when you have the tree item directly.
* @return Array of Objects leading to the given TreeItem,
- * sorted from the leaf item up.
+ * sorted from the leaf item up.
*/
public Object[] getElementNodes(TreeItem item) {
List v = new Vector();
@@ -5604,7 +5613,7 @@ public class SystemView extends SafeTreeViewer
* The array is in reverse order, starting at the leaf and going up.
* This flavor returns an array of TreeItem objects versus element objects.
* @return Array of TreeItem objects leading to the given TreeItem,
- * sorted from the leaf item up.
+ * sorted from the leaf item up.
*/
public TreeItem[] getItemNodes(TreeItem item) {
List v = new Vector();
@@ -5642,7 +5651,7 @@ public class SystemView extends SafeTreeViewer
}
}
return isSelected;
- //return isSelected(element, (IStructuredSelection)getSelection());
+ //return isSelected(element, (IStructuredSelection)getSelection());
}
/**
@@ -5666,7 +5675,7 @@ public class SystemView extends SafeTreeViewer
}
}
return isSelected;
- //return isSelected(element, (IStructuredSelection)getSelection());
+ //return isSelected(element, (IStructuredSelection)getSelection());
}
/**
@@ -5687,7 +5696,7 @@ public class SystemView extends SafeTreeViewer
Item[] items = getItems(ti);
for (int i=0; inull
to get a new List created and returned
- * @return the List populated with hits, or null
if
+ * @return the List populated with hits, or null
if
* null
was passed as matches to populate and no matches
* were found.
*/
@@ -4474,12 +4483,12 @@ public class SystemView extends SafeTreeViewer
Tree tree = getTree();
Item[] roots = tree.getItems();
if (roots == null) return matches;
- if (matches == null)
+ if (matches == null)
matches = new Vector();
// try new map lookup method - won't work in cases of rename
if (!mappedFindAllRemoteItemReferences(elementObject, matches)){
-
+
boolean foundExact = false;
for (int idx = 0; idx < roots.length; idx++){
if (recursiveFindExactMatches((TreeItem)roots[idx], elementObject, subsystem, matches)){
@@ -4496,8 +4505,8 @@ public class SystemView extends SafeTreeViewer
}
return matches;
}
-
-
+
+
private boolean recursiveFindExactMatches(TreeItem root, Object elementObject, ISubSystem subsystem, List matches)
{
boolean foundSomething = false;
@@ -4517,7 +4526,7 @@ public class SystemView extends SafeTreeViewer
return false;
}
}
-
+
TreeItem[] children = root.getItems();
for (int i = 0; i < children.length; i++)
{
@@ -4530,13 +4539,13 @@ public class SystemView extends SafeTreeViewer
}
/**
- * Recursively tries to find the first occurrence of a given remote object, starting at the tree root.
+ * Recursively tries to find the first occurrence of a given remote object, starting at the tree root.
* Optionally scoped to a specific subsystem.
- * Since the object memory object for a remote object is not dependable we call getAbsoluteName()
- * on the adapter to do the comparisons.
+ * Since the object memory object for a remote object is not dependable we call getAbsoluteName()
+ * on the adapter to do the comparisons.
* null
,
@@ -4722,7 +4731,7 @@ public class SystemView extends SafeTreeViewer
Tree tree = getTree();
Item[] roots = tree.getItems();
if (roots == null) return matches;
- if (matches == null)
+ if (matches == null)
matches = new Vector();
for (int idx = 0; idx < roots.length; idx++){
@@ -4739,7 +4748,7 @@ public class SystemView extends SafeTreeViewer
* @param elementName the absolute name of the remote element that has been created, changed, deleted or renamed.
* @param subsystem The subsystem which owns the remote resource. Necessary to scope the search for impacted filters.
* @param occurrences the List to populate with hits. Must not be null
.
- *
+ *
* @return The given List of occurrences, populated with FilterMatch objects
* for each affected filter.
*/
@@ -4791,7 +4800,7 @@ public class SystemView extends SafeTreeViewer
}
// -----------------------------------------------------------------------------------------
// if we are currently visiting a connection, and that connection's hostname is not the same
- // as that of our given subsystem, then we can assume the remote object occurrences we are
+ // as that of our given subsystem, then we can assume the remote object occurrences we are
// looking for are not to be found within this branch...
// -----------------------------------------------------------------------------------------
else if (rawData instanceof IHost) {
@@ -4811,7 +4820,7 @@ public class SystemView extends SafeTreeViewer
// ------------------------------------------------------------------------
else if (getRemoteAdapter(rawData) != null) return occurrences;
}
- // recurse over children
+ // recurse over children
Item[] items = getChildren(parent);
for (int i = 0; (i < items.length); i++) {
occurrences = recursiveFindAllRemoteItemFilterReferences(items[i], elementName, subsystem, occurrences);
@@ -4867,7 +4876,7 @@ public class SystemView extends SafeTreeViewer
// protected boolean selectionEnableDeleteAction;
// protected boolean selectionEnableRenameAction;
-
+
// initial these variables to true. Then if set to false even once, leave as false always...
selectionShowPropertiesAction = true;
selectionShowRefreshAction = true;
@@ -4892,7 +4901,7 @@ public class SystemView extends SafeTreeViewer
if (adapter == null) continue;
if (selectionShowPropertiesAction) selectionShowPropertiesAction = adapter.showProperties(element);
-
+
if (selectionShowRefreshAction) selectionShowRefreshAction = adapter.showRefresh(element);
if (selectionShowOpenViewActions) selectionShowOpenViewActions = adapter.showOpenViewActions(element);
@@ -4912,8 +4921,8 @@ public class SystemView extends SafeTreeViewer
if (selectionIsRemoteObject && !selectionFlagsUpdated) {
ISubSystem srcSubSystem = adapter.getSubSystem(element);
- if (srcSubSystem != null &&
- (srcSubSystem.isConnected() || element instanceof ISystemFilterReference || element instanceof ISubSystem))
+ if (srcSubSystem != null &&
+ (srcSubSystem.isConnected() || element instanceof ISystemFilterReference || element instanceof ISubSystem))
{
SystemRemoteElementResourceSet set = null;
if (lastSet != null)
@@ -4925,18 +4934,18 @@ public class SystemView extends SafeTreeViewer
}
if (set == null)
{
- set = getSetFor(srcSubSystem, adapter);
+ set = getSetFor(srcSubSystem, adapter);
lastSet = set;
}
set.addResource(element);
}
}
-
+
}
selectionFlagsUpdated = true;
- //System.out.println("Inside scan selections: selectionShowOpenViewActions = " + selectionShowOpenViewActions);
+ //System.out.println("Inside scan selections: selectionShowOpenViewActions = " + selectionShowOpenViewActions);
}
@@ -4947,7 +4956,7 @@ public class SystemView extends SafeTreeViewer
protected boolean showProperties() {
return selectionShowPropertiesAction;
}
-
+
/**
* Decides whether to even show the refresh menu item.
* Assumes scanSelections() has already been called
@@ -5013,7 +5022,7 @@ public class SystemView extends SafeTreeViewer
/**
* Required method from ISystemDeleteTarget
- * Decides whether to enable the delete menu item.
+ * Decides whether to enable the delete menu item.
* Assumes scanSelections() has already been called
*/
public boolean canDelete() {
@@ -5026,7 +5035,7 @@ public class SystemView extends SafeTreeViewer
/**
* Required method from ISystemDeleteTarget
- *
+ *
* @deprecated all deletion should now occur independently of the view and the
* view should only deal with the handling of refresh events
*/
@@ -5043,10 +5052,10 @@ public class SystemView extends SafeTreeViewer
boolean ok = true;
boolean anyOk = false;
List deletedVector = new Vector();
-
+
// keep track of the current set
SystemRemoteElementResourceSet set = null;
-
+
try {
while (ok && elements.hasNext()) {
element = elements.next();
@@ -5067,10 +5076,10 @@ public class SystemView extends SafeTreeViewer
ISystemViewElementAdapter srcAdapter = set.getViewAdapter();
if (srcSubSystem != null) {
-
+
// this call can throw an exception
ok = srcAdapter.doDeleteBatch(getShell(), set.getResourceSet(), monitor);
-
+
if (ok) {
anyOk = true;
deletedVector.addAll(set.getResourceSet());
@@ -5084,28 +5093,28 @@ public class SystemView extends SafeTreeViewer
String msg = exc.getMessage();
if ((msg == null) || (exc instanceof ClassCastException)) msg = exc.getClass().getName();
SystemMessageDialog.displayErrorMessage(getShell(), RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_DELETING).makeSubstitution(element, msg));
-
+
// refresh all parents if selection is remote objects
if (selectionIsRemoteObject) {
-
+
// we only need to iterate over the last set in the list of sets since presumably the sets before did not cause any exceptions
// if elements in the list before were deleted successfully, then the code after this catch block will handle them (by firing delete events)
// for the current set that caused the exception, we refresh the parents of the elements in the set (since we don't know which
- // elements in the set may have been deleted successfully before the exception occurred).
+ // elements in the set may have been deleted successfully before the exception occurred).
if (set != null) {
List list = set.getResourceSet();
-
+
if (list != null && list.size() > 0) {
-
+
Iterator iter = list.iterator();
-
+
List refreshedList = new Vector();
-
+
while (iter.hasNext()) {
Object obj = iter.next();
ISystemViewElementAdapter adp = getViewAdapter(obj);
Object parent = adp.getParent(obj);
-
+
if ((parent != null) && !(refreshedList.contains(parent))) {
SystemResourceChangeEvent event = new SystemResourceChangeEvent(parent, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null);
sr.fireEvent(event);
@@ -5115,7 +5124,7 @@ public class SystemView extends SafeTreeViewer
}
}
}
-
+
ok = false;
}
//System.out.println("in doDelete. Any ok? " + anyOk + ", selectionIsRemoteObject? " + selectionIsRemoteObject);
@@ -5143,7 +5152,7 @@ public class SystemView extends SafeTreeViewer
Object[] elementAdapters = null;
Object parentElement = null;
String renameMessage = null;
-
+
/**
* RenameJob job.
* @param newNames array of new names of all the elements need to be renamed
@@ -5162,7 +5171,7 @@ public class SystemView extends SafeTreeViewer
setUser(true);
}
- public IStatus runInWorkspace(IProgressMonitor monitor)
+ public IStatus runInWorkspace(IProgressMonitor monitor)
{
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
Object element = null;
@@ -5171,7 +5180,7 @@ public class SystemView extends SafeTreeViewer
String oldFullName = ""; //$NON-NLS-1$
String oldName = ""; //$NON-NLS-1$
Vector fileNamesRenamed = new Vector();
-
+
boolean ok = true;
try {
int steps = elements.length;
@@ -5181,14 +5190,14 @@ public class SystemView extends SafeTreeViewer
element = elements[i];
adapter = (ISystemViewElementAdapter)elementAdapters[i];
remoteAdapter = getRemoteAdapter(element);
- if (remoteAdapter != null)
+ if (remoteAdapter != null)
{
oldName = remoteAdapter.getName(element);
oldFullName = remoteAdapter.getAbsoluteName(element); // pre-rename
monitor.subTask(getRenamingMessage(oldName).getLevelOneText());
}
ok = adapter.doRename(null, element, newNames[i], monitor);
- if (ok)
+ if (ok)
{
fileNamesRenamed.add(oldName);
if (remoteAdapter != null)
@@ -5202,8 +5211,8 @@ public class SystemView extends SafeTreeViewer
}
monitor.worked(1);
}
- }
- catch (SystemMessageException exc)
+ }
+ catch (SystemMessageException exc)
{
ok = false;
//If this operation is cancelled, need to display a proper message to the user.
@@ -5233,7 +5242,7 @@ public class SystemView extends SafeTreeViewer
exc);
ok = false;
}
-
+
return Status.OK_STATUS;
}
}
@@ -5248,20 +5257,20 @@ public class SystemView extends SafeTreeViewer
/**
* Required method from ISystemRenameTarget
- * Decides whether to enable the rename menu item.
+ * Decides whether to enable the rename menu item.
* Assumes scanSelections() has already been called
*/
public boolean canRename() {
if (!selectionFlagsUpdated) scanSelections("canRename"); //$NON-NLS-1$
return selectionEnableRenameAction;
}
-
+
/**
- * Get the specific "Renaming %1..."
+ * Get the specific "Renaming %1..."
*/
protected SystemMessage getRenamingMessage(String oldName)
{
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_RENAMEGENERIC_PROGRESS);
+ SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_RENAMEGENERIC_PROGRESS);
msg.makeSubstitution(oldName);
return msg;
}
@@ -5273,7 +5282,7 @@ public class SystemView extends SafeTreeViewer
IStructuredSelection selection = (IStructuredSelection) getSelection();
Iterator elements = selection.iterator();
Object parentElement = getSelectedParent();
-
+
Object[] renameElements = new Object[newNames.length];
Object[] elementAdapters = new Object[newNames.length];
int i = 0;
@@ -5322,9 +5331,9 @@ public class SystemView extends SafeTreeViewer
/**
* When this action is run via Edit->Select All or via Ctrl+A, perform the
- * select all action. For a tree view, this should select all the children
+ * select all action. For a tree view, this should select all the children
* of the given selected object. You can use the passed in selected object
- * or ignore it and query the selected object yourself.
+ * or ignore it and query the selected object yourself.
*/
public void doSelectAll(IStructuredSelection selection) {
Tree tree = getTree();
@@ -5338,12 +5347,12 @@ public class SystemView extends SafeTreeViewer
fireSelectionChanged(new SelectionChangedEvent(this, new StructuredSelection(childObjects)));
}
- // --------------------------------------------
+ // --------------------------------------------
// ISystemTree methods to facilitate our GUI...
// --------------------------------------------
/**
* This is called to ensure all elements in a multiple-selection have the same parent in the
- * tree viewer. If they don't we automatically disable all actions.
+ * tree viewer. If they don't we automatically disable all actions.
*