mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-22 15:53:58 +02:00
[228774] Improve ElementComparer Performance
This commit is contained in:
parent
d20c416a1a
commit
7c7d766b17
3 changed files with 468 additions and 470 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,43 +1,38 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2007, 2008 IBM Corporation and others. All rights reserved.
|
* Copyright (c) 2007, 2008 IBM Corporation and others. 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, Kushal Munir,
|
* component that contains this file: David McKnight, Kushal Munir,
|
||||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Kevin Doyle (IBM) - [195537] Move ElementComparer From SystemView to Separate File
|
* Kevin Doyle (IBM) - [195537] Move ElementComparer From SystemView to Separate File
|
||||||
* Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
|
* Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
|
||||||
* David Dykstal (IBM) - [225911] Exception received after deleting a profile containing a connection
|
* David Dykstal (IBM) - [225911] Exception received after deleting a profile containing a connection
|
||||||
* David Dykstal (IBM) - [228774] [regression] AssertionFailedException when connecting to New Connection
|
* David Dykstal (IBM) - [228774] [regression] AssertionFailedException when connecting to New Connection
|
||||||
|
* Martin Oberhuber (Wind River) - [228774] Improve ElementComparer Performance
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.ui.view;
|
package org.eclipse.rse.internal.ui.view;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.jface.viewers.IElementComparer;
|
import org.eclipse.jface.viewers.IElementComparer;
|
||||||
import org.eclipse.rse.core.RSECorePlugin;
|
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
|
||||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
|
||||||
import org.eclipse.rse.internal.core.model.SystemRegistry;
|
import org.eclipse.rse.internal.core.model.SystemRegistry;
|
||||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implememtation of an element comparer for the system view.
|
* An implementation of an element comparer for the system view.
|
||||||
*/
|
*/
|
||||||
public class ElementComparer implements IElementComparer {
|
public class ElementComparer implements IElementComparer {
|
||||||
|
|
||||||
public boolean equals(Object a, Object b) {
|
public boolean equals(Object a, Object b) {
|
||||||
boolean result = false;
|
// equal if same absolute name in same subsystem;
|
||||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
// or, when adapters are not found, both are the same instance.
|
||||||
if (registry instanceof SystemRegistry) {
|
return SystemRegistry.isSameObjectByAbsoluteName(a, null, b, null);
|
||||||
result = ((SystemRegistry) registry).isSameObjectByAbsoluteName(a, null, b, null);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode(Object element) {
|
public int hashCode(Object element) {
|
||||||
|
@ -46,27 +41,34 @@ public class ElementComparer implements IElementComparer {
|
||||||
* Since one adapter is typically used for many elements in RSE,
|
* Since one adapter is typically used for many elements in RSE,
|
||||||
* performance would be better if the original Element's hashCode
|
* performance would be better if the original Element's hashCode
|
||||||
* were used rather than the adapter's hashCode. The problem with
|
* were used rather than the adapter's hashCode. The problem with
|
||||||
* this is, that if the remote object changes, it cannot be
|
* this is, that if the remote object changes, it cannot be
|
||||||
* identified any more.
|
* identified any more.
|
||||||
* Note that currently the hashCode of the object can change
|
* Note that currently the hashCode of the object can change
|
||||||
* over time if properties are modified (this is probably a bug).
|
* over time if properties are modified (this is probably a bug).
|
||||||
* Therefore, if there is no absolute name, play it safe and return the adapter's hashCode which won't ever change.
|
* Therefore, if there is no absolute name, play it safe and return the adapter's hashCode which won't ever change.
|
||||||
*/
|
*/
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
if (element instanceof IAdaptable) {
|
ISystemDragDropAdapter dda = SystemRegistry.getSystemDragDropAdapter(element);
|
||||||
ISystemViewElementAdapter ident = (ISystemViewElementAdapter) ((IAdaptable) element).getAdapter(ISystemViewElementAdapter.class);
|
if (dda != null) {
|
||||||
if (ident != null) {
|
// adapter available
|
||||||
String absName = ident.getAbsoluteName(element);
|
String absName = dda.getAbsoluteName(element);
|
||||||
if (absName != null) {
|
if (absName != null) {
|
||||||
result = absName.hashCode();
|
result = absName.hashCode();
|
||||||
} else {
|
|
||||||
result = ident.hashCode();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
result = element.hashCode();
|
result = dda.hashCode();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// --MOB: Usually, we should fall back to constant hashcode 0
|
||||||
|
// here if no adapter is available, in order to ensure constant
|
||||||
|
// hashcode even if object properties change. But as a matter of
|
||||||
|
// fact, those elements that we have in the SystemView and which
|
||||||
|
// do not have an adapter registered, are very few; and they are
|
||||||
|
// always constant over their lifetime, such as the "Pending..."
|
||||||
|
// node for instance. We therefore return the element's hashcode
|
||||||
|
// here, along with the corresponding equals() code above,
|
||||||
|
// which falls back to Object equality if no adapter is
|
||||||
|
// available.
|
||||||
result = element.hashCode();
|
result = element.hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
|
* Copyright (c) 2002, 2008 IBM Corporation and others. 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, Kushal Munir,
|
* component that contains this file: David McKnight, Kushal Munir,
|
||||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Berger (IBM) - 146339 Added refresh action graphic.
|
* Michael Berger (IBM) - 146339 Added refresh action graphic.
|
||||||
* David Dykstal (IBM) - moved SystemsPreferencesManager to a new package
|
* David Dykstal (IBM) - moved SystemsPreferencesManager to a new package
|
||||||
|
@ -31,7 +31,8 @@
|
||||||
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
|
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
|
||||||
* Xuan Chen (IBM) - [225685] NPE when running archive testcases
|
* Xuan Chen (IBM) - [225685] NPE when running archive testcases
|
||||||
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API type
|
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API type
|
||||||
********************************************************************************/
|
* Martin Oberhuber (Wind River) - [228774] Improve ElementComparer Performance
|
||||||
|
*******************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.ui.view;
|
package org.eclipse.rse.internal.ui.view;
|
||||||
|
|
||||||
|
@ -144,11 +145,11 @@ public class SystemTableViewPart extends ViewPart
|
||||||
|
|
||||||
class BrowseAction extends Action
|
class BrowseAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
public BrowseAction()
|
public BrowseAction()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrowseAction(String label, ImageDescriptor des)
|
public BrowseAction(String label, ImageDescriptor des)
|
||||||
{
|
{
|
||||||
super(label, des);
|
super(label, des);
|
||||||
|
@ -317,13 +318,13 @@ public class SystemTableViewPart extends ViewPart
|
||||||
_isLocked = !_isLocked;
|
_isLocked = !_isLocked;
|
||||||
showLock();
|
showLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the label depending on lock state.
|
* Returns the label depending on lock state.
|
||||||
* @return the label.
|
* @return the label.
|
||||||
*/
|
*/
|
||||||
public String determineLabel() {
|
public String determineLabel() {
|
||||||
|
|
||||||
if (!_isLocked) {
|
if (!_isLocked) {
|
||||||
return SystemResources.ACTION_LOCK_LABEL;
|
return SystemResources.ACTION_LOCK_LABEL;
|
||||||
}
|
}
|
||||||
|
@ -331,18 +332,18 @@ public class SystemTableViewPart extends ViewPart
|
||||||
return SystemResources.ACTION_UNLOCK_LABEL;
|
return SystemResources.ACTION_UNLOCK_LABEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the tooltip depending on lock state.
|
* Returns the tooltip depending on lock state.
|
||||||
* @return the tooltip.
|
* @return the tooltip.
|
||||||
*/
|
*/
|
||||||
public String determineTooltip() {
|
public String determineTooltip() {
|
||||||
|
|
||||||
if (!_isLocked) {
|
if (!_isLocked) {
|
||||||
return SystemResources.ACTION_LOCK_TOOLTIP;
|
return SystemResources.ACTION_LOCK_TOOLTIP;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return SystemResources.ACTION_UNLOCK_TOOLTIP;
|
return SystemResources.ACTION_UNLOCK_TOOLTIP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,7 +352,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
{
|
{
|
||||||
public RefreshAction()
|
public RefreshAction()
|
||||||
{
|
{
|
||||||
super(SystemResources.ACTION_REFRESH_TABLE_LABLE,
|
super(SystemResources.ACTION_REFRESH_TABLE_LABLE,
|
||||||
//RSEUIPlugin.getDefault().getImageDescriptor(ICON_SYSTEM_REFRESH_ID));
|
//RSEUIPlugin.getDefault().getImageDescriptor(ICON_SYSTEM_REFRESH_ID));
|
||||||
RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_REFRESH_ID));
|
RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_REFRESH_ID));
|
||||||
setToolTipText(SystemResources.ACTION_REFRESH_TABLE_TOOLTIP);
|
setToolTipText(SystemResources.ACTION_REFRESH_TABLE_TOOLTIP);
|
||||||
|
@ -402,7 +403,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
_viewer.setSelection(_viewer.getSelection());
|
_viewer.setSelection(_viewer.getSelection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SelectInputAction extends BrowseAction
|
class SelectInputAction extends BrowseAction
|
||||||
{
|
{
|
||||||
public SelectInputAction()
|
public SelectInputAction()
|
||||||
|
@ -410,22 +411,22 @@ public class SystemTableViewPart extends ViewPart
|
||||||
super(SystemResources.ACTION_SELECT_INPUT_LABEL, null);
|
super(SystemResources.ACTION_SELECT_INPUT_LABEL, null);
|
||||||
setToolTipText(SystemResources.ACTION_SELECT_INPUT_TOOLTIP);
|
setToolTipText(SystemResources.ACTION_SELECT_INPUT_TOOLTIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkEnabledState()
|
public void checkEnabledState()
|
||||||
{
|
{
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
|
||||||
SystemSelectAnythingDialog dlg = new SystemSelectAnythingDialog(_viewer.getShell(), SystemResources.ACTION_SELECT_INPUT_DLG);
|
SystemSelectAnythingDialog dlg = new SystemSelectAnythingDialog(_viewer.getShell(), SystemResources.ACTION_SELECT_INPUT_DLG);
|
||||||
|
|
||||||
SystemActionViewerFilter filter = new SystemActionViewerFilter();
|
SystemActionViewerFilter filter = new SystemActionViewerFilter();
|
||||||
Class[] types = {Object.class};
|
Class[] types = {Object.class};
|
||||||
filter.addFilterCriterion(types, "hasChildren", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
filter.addFilterCriterion(types, "hasChildren", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
dlg.setViewerFilter(filter);
|
dlg.setViewerFilter(filter);
|
||||||
|
|
||||||
Object inputObject = _viewer.getInput();
|
Object inputObject = _viewer.getInput();
|
||||||
if (inputObject == null)
|
if (inputObject == null)
|
||||||
{
|
{
|
||||||
|
@ -436,7 +437,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
{
|
{
|
||||||
Object selected = dlg.getSelectedObject();
|
Object selected = dlg.getSelectedObject();
|
||||||
if (selected != null && selected instanceof IAdaptable)
|
if (selected != null && selected instanceof IAdaptable)
|
||||||
{
|
{
|
||||||
IAdaptable adaptable = (IAdaptable)selected;
|
IAdaptable adaptable = (IAdaptable)selected;
|
||||||
((ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class)).setViewer(_viewer);
|
((ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class)).setViewer(_viewer);
|
||||||
setInput(adaptable);
|
setInput(adaptable);
|
||||||
|
@ -674,7 +675,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
final String objectID = memento.getString(TAG_TABLE_VIEW_OBJECT_ID);
|
final String objectID = memento.getString(TAG_TABLE_VIEW_OBJECT_ID);
|
||||||
|
|
||||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||||
|
|
||||||
Object input = null;
|
Object input = null;
|
||||||
if (subsystemId == null)
|
if (subsystemId == null)
|
||||||
{
|
{
|
||||||
|
@ -686,7 +687,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 191288 we now use registry instead of registry ui as input
|
// 191288 we now use registry instead of registry ui as input
|
||||||
input = registry;
|
input = registry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -722,7 +723,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
} // end else
|
} // end else
|
||||||
return runWithInput(monitor, input, memento);
|
return runWithInput(monitor, input, memento);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RunOnceConnectedOnMainThread implements Runnable
|
private class RunOnceConnectedOnMainThread implements Runnable
|
||||||
{
|
{
|
||||||
private IMemento _inmemento;
|
private IMemento _inmemento;
|
||||||
|
@ -738,13 +739,13 @@ public class SystemTableViewPart extends ViewPart
|
||||||
_filterID = filterID;
|
_filterID = filterID;
|
||||||
_objectID = objectID;
|
_objectID = objectID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
runOnceConnected(new NullProgressMonitor(), _inmemento, _input, _subSystem, _filterID, _objectID);
|
runOnceConnected(new NullProgressMonitor(), _inmemento, _input, _subSystem, _filterID, _objectID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IStatus runOnceConnected(IProgressMonitor monitor, IMemento memento, Object input, ISubSystem subsystem, String filterID, String objectID)
|
public IStatus runOnceConnected(IProgressMonitor monitor, IMemento memento, Object input, ISubSystem subsystem, String filterID, String objectID)
|
||||||
{
|
{
|
||||||
if (subsystem.isConnected()) {
|
if (subsystem.isConnected()) {
|
||||||
|
@ -798,14 +799,14 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class SelectColumnsAction extends BrowseAction
|
private class SelectColumnsAction extends BrowseAction
|
||||||
{
|
{
|
||||||
|
|
||||||
class SelectColumnsDialog extends SystemPromptDialog
|
class SelectColumnsDialog extends SystemPromptDialog
|
||||||
{
|
{
|
||||||
private ISystemViewElementAdapter _adapter;
|
private ISystemViewElementAdapter _adapter;
|
||||||
|
@ -813,15 +814,15 @@ public class SystemTableViewPart extends ViewPart
|
||||||
private IPropertyDescriptor[] _uniqueDescriptors;
|
private IPropertyDescriptor[] _uniqueDescriptors;
|
||||||
private ArrayList _currentDisplayedDescriptors;
|
private ArrayList _currentDisplayedDescriptors;
|
||||||
private ArrayList _availableDescriptors;
|
private ArrayList _availableDescriptors;
|
||||||
|
|
||||||
private List _availableList;
|
private List _availableList;
|
||||||
private List _displayedList;
|
private List _displayedList;
|
||||||
|
|
||||||
private Button _addButton;
|
private Button _addButton;
|
||||||
private Button _removeButton;
|
private Button _removeButton;
|
||||||
private Button _upButton;
|
private Button _upButton;
|
||||||
private Button _downButton;
|
private Button _downButton;
|
||||||
|
|
||||||
|
|
||||||
public SelectColumnsDialog(Shell shell, ISystemViewElementAdapter viewAdapter, ISystemTableViewColumnManager columnManager)
|
public SelectColumnsDialog(Shell shell, ISystemViewElementAdapter viewAdapter, ISystemTableViewColumnManager columnManager)
|
||||||
{
|
{
|
||||||
|
@ -852,14 +853,14 @@ public class SystemTableViewPart extends ViewPart
|
||||||
{
|
{
|
||||||
Widget source = e.widget;
|
Widget source = e.widget;
|
||||||
if (source == _addButton)
|
if (source == _addButton)
|
||||||
{
|
{
|
||||||
int[] toAdd = _availableList.getSelectionIndices();
|
int[] toAdd = _availableList.getSelectionIndices();
|
||||||
addToDisplay(toAdd);
|
addToDisplay(toAdd);
|
||||||
}
|
}
|
||||||
else if (source == _removeButton)
|
else if (source == _removeButton)
|
||||||
{
|
{
|
||||||
int[] toAdd = _displayedList.getSelectionIndices();
|
int[] toAdd = _displayedList.getSelectionIndices();
|
||||||
removeFromDisplay(toAdd);
|
removeFromDisplay(toAdd);
|
||||||
}
|
}
|
||||||
else if (source == _upButton)
|
else if (source == _upButton)
|
||||||
{
|
{
|
||||||
|
@ -873,11 +874,11 @@ public class SystemTableViewPart extends ViewPart
|
||||||
moveDown(index);
|
moveDown(index);
|
||||||
_displayedList.select(index + 1);
|
_displayedList.select(index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update button enable states
|
// update button enable states
|
||||||
updateEnableStates();
|
updateEnableStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPropertyDescriptor[] getDisplayedColumns()
|
public IPropertyDescriptor[] getDisplayedColumns()
|
||||||
{
|
{
|
||||||
IPropertyDescriptor[] displayedColumns = new IPropertyDescriptor[_currentDisplayedDescriptors.size()];
|
IPropertyDescriptor[] displayedColumns = new IPropertyDescriptor[_currentDisplayedDescriptors.size()];
|
||||||
|
@ -887,14 +888,14 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
return displayedColumns;
|
return displayedColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateEnableStates()
|
private void updateEnableStates()
|
||||||
{
|
{
|
||||||
boolean enableAdd = false;
|
boolean enableAdd = false;
|
||||||
boolean enableRemove = false;
|
boolean enableRemove = false;
|
||||||
boolean enableUp = false;
|
boolean enableUp = false;
|
||||||
boolean enableDown = false;
|
boolean enableDown = false;
|
||||||
|
|
||||||
int[] availableSelected = _availableList.getSelectionIndices();
|
int[] availableSelected = _availableList.getSelectionIndices();
|
||||||
for (int i = 0; i < availableSelected.length; i++)
|
for (int i = 0; i < availableSelected.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -905,11 +906,11 @@ public class SystemTableViewPart extends ViewPart
|
||||||
enableAdd = true;
|
enableAdd = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_displayedList.getSelectionCount()>0)
|
if (_displayedList.getSelectionCount()>0)
|
||||||
{
|
{
|
||||||
enableRemove = true;
|
enableRemove = true;
|
||||||
|
|
||||||
int index = _displayedList.getSelectionIndex();
|
int index = _displayedList.getSelectionIndex();
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
{
|
{
|
||||||
|
@ -920,63 +921,63 @@ public class SystemTableViewPart extends ViewPart
|
||||||
enableDown = true;
|
enableDown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_addButton.setEnabled(enableAdd);
|
_addButton.setEnabled(enableAdd);
|
||||||
_removeButton.setEnabled(enableRemove);
|
_removeButton.setEnabled(enableRemove);
|
||||||
_upButton.setEnabled(enableUp);
|
_upButton.setEnabled(enableUp);
|
||||||
_downButton.setEnabled(enableDown);
|
_downButton.setEnabled(enableDown);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveUp(int index)
|
private void moveUp(int index)
|
||||||
{
|
{
|
||||||
Object obj = _currentDisplayedDescriptors.remove(index);
|
Object obj = _currentDisplayedDescriptors.remove(index);
|
||||||
_currentDisplayedDescriptors.add(index - 1, obj);
|
_currentDisplayedDescriptors.add(index - 1, obj);
|
||||||
refreshDisplayedList();
|
refreshDisplayedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveDown(int index)
|
private void moveDown(int index)
|
||||||
{
|
{
|
||||||
Object obj = _currentDisplayedDescriptors.remove(index);
|
Object obj = _currentDisplayedDescriptors.remove(index);
|
||||||
_currentDisplayedDescriptors.add(index + 1, obj);
|
_currentDisplayedDescriptors.add(index + 1, obj);
|
||||||
|
|
||||||
refreshDisplayedList();
|
refreshDisplayedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToDisplay(int[] toAdd)
|
private void addToDisplay(int[] toAdd)
|
||||||
{
|
{
|
||||||
ArrayList added = new ArrayList();
|
ArrayList added = new ArrayList();
|
||||||
for (int i = 0; i < toAdd.length; i++)
|
for (int i = 0; i < toAdd.length; i++)
|
||||||
{
|
{
|
||||||
int index = toAdd[i];
|
int index = toAdd[i];
|
||||||
|
|
||||||
IPropertyDescriptor descriptor = (IPropertyDescriptor)_availableDescriptors.get(index);
|
IPropertyDescriptor descriptor = (IPropertyDescriptor)_availableDescriptors.get(index);
|
||||||
|
|
||||||
if (!_currentDisplayedDescriptors.contains(descriptor))
|
if (!_currentDisplayedDescriptors.contains(descriptor))
|
||||||
{
|
{
|
||||||
_currentDisplayedDescriptors.add(descriptor);
|
_currentDisplayedDescriptors.add(descriptor);
|
||||||
added.add(descriptor);
|
added.add(descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < added.size(); i++)
|
for (int i = 0; i < added.size(); i++)
|
||||||
{
|
{
|
||||||
_availableDescriptors.remove(added.get(i));
|
_availableDescriptors.remove(added.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
refreshAvailableList();
|
refreshAvailableList();
|
||||||
refreshDisplayedList();
|
refreshDisplayedList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeFromDisplay(int[] toRemove)
|
private void removeFromDisplay(int[] toRemove)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < toRemove.length; i++)
|
for (int i = 0; i < toRemove.length; i++)
|
||||||
{
|
{
|
||||||
int index = toRemove[i];
|
int index = toRemove[i];
|
||||||
IPropertyDescriptor descriptor = (IPropertyDescriptor)_currentDisplayedDescriptors.get(index);
|
IPropertyDescriptor descriptor = (IPropertyDescriptor)_currentDisplayedDescriptors.get(index);
|
||||||
_currentDisplayedDescriptors.remove(index);
|
_currentDisplayedDescriptors.remove(index);
|
||||||
_availableDescriptors.add(descriptor);
|
_availableDescriptors.add(descriptor);
|
||||||
}
|
}
|
||||||
refreshDisplayedList();
|
refreshDisplayedList();
|
||||||
|
@ -998,38 +999,38 @@ public class SystemTableViewPart extends ViewPart
|
||||||
public Control createInner(Composite parent)
|
public Control createInner(Composite parent)
|
||||||
{
|
{
|
||||||
Composite main = SystemWidgetHelpers.createComposite(parent, 1);
|
Composite main = SystemWidgetHelpers.createComposite(parent, 1);
|
||||||
|
|
||||||
|
|
||||||
Composite c = SystemWidgetHelpers.createComposite(main, 4);
|
Composite c = SystemWidgetHelpers.createComposite(main, 4);
|
||||||
c.setLayoutData(new GridData(GridData.FILL_BOTH));
|
c.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
_availableList = SystemWidgetHelpers.createListBox(c, SystemResources.RESID_TABLE_SELECT_COLUMNS_AVAILABLE_LABEL, this, true);
|
_availableList = SystemWidgetHelpers.createListBox(c, SystemResources.RESID_TABLE_SELECT_COLUMNS_AVAILABLE_LABEL, this, true);
|
||||||
|
|
||||||
Composite addRemoveComposite = SystemWidgetHelpers.createComposite(c, 1);
|
Composite addRemoveComposite = SystemWidgetHelpers.createComposite(c, 1);
|
||||||
addRemoveComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
|
addRemoveComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
|
||||||
_addButton = SystemWidgetHelpers.createPushButton(addRemoveComposite,
|
_addButton = SystemWidgetHelpers.createPushButton(addRemoveComposite,
|
||||||
SystemResources.RESID_TABLE_SELECT_COLUMNS_ADD_LABEL,
|
SystemResources.RESID_TABLE_SELECT_COLUMNS_ADD_LABEL,
|
||||||
this);
|
this);
|
||||||
_addButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_ADD_TOOLTIP);
|
_addButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_ADD_TOOLTIP);
|
||||||
|
|
||||||
_removeButton = SystemWidgetHelpers.createPushButton(addRemoveComposite,
|
_removeButton = SystemWidgetHelpers.createPushButton(addRemoveComposite,
|
||||||
SystemResources.RESID_TABLE_SELECT_COLUMNS_REMOVE_LABEL,
|
SystemResources.RESID_TABLE_SELECT_COLUMNS_REMOVE_LABEL,
|
||||||
this);
|
this);
|
||||||
_removeButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_REMOVE_TOOLTIP);
|
_removeButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_REMOVE_TOOLTIP);
|
||||||
|
|
||||||
_displayedList = SystemWidgetHelpers.createListBox(c, SystemResources.RESID_TABLE_SELECT_COLUMNS_DISPLAYED_LABEL, this, false);
|
_displayedList = SystemWidgetHelpers.createListBox(c, SystemResources.RESID_TABLE_SELECT_COLUMNS_DISPLAYED_LABEL, this, false);
|
||||||
|
|
||||||
Composite upDownComposite = SystemWidgetHelpers.createComposite(c, 1);
|
Composite upDownComposite = SystemWidgetHelpers.createComposite(c, 1);
|
||||||
upDownComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
|
upDownComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
|
||||||
_upButton = SystemWidgetHelpers.createPushButton(upDownComposite,
|
_upButton = SystemWidgetHelpers.createPushButton(upDownComposite,
|
||||||
SystemResources.RESID_TABLE_SELECT_COLUMNS_UP_LABEL,
|
SystemResources.RESID_TABLE_SELECT_COLUMNS_UP_LABEL,
|
||||||
this);
|
this);
|
||||||
_upButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_UP_TOOLTIP);
|
_upButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_UP_TOOLTIP);
|
||||||
|
|
||||||
_downButton = SystemWidgetHelpers.createPushButton(upDownComposite,
|
_downButton = SystemWidgetHelpers.createPushButton(upDownComposite,
|
||||||
SystemResources.RESID_TABLE_SELECT_COLUMNS_DOWN_LABEL,
|
SystemResources.RESID_TABLE_SELECT_COLUMNS_DOWN_LABEL,
|
||||||
this);
|
this);
|
||||||
_downButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_DOWN_TOOLTIP);
|
_downButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_DOWN_TOOLTIP);
|
||||||
|
|
||||||
initLists();
|
initLists();
|
||||||
|
|
||||||
setHelp();
|
setHelp();
|
||||||
|
@ -1042,7 +1043,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
refreshDisplayedList();
|
refreshDisplayedList();
|
||||||
updateEnableStates();
|
updateEnableStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshAvailableList()
|
private void refreshAvailableList()
|
||||||
{
|
{
|
||||||
_availableList.removeAll();
|
_availableList.removeAll();
|
||||||
|
@ -1053,28 +1054,28 @@ public class SystemTableViewPart extends ViewPart
|
||||||
_availableList.add(descriptor.getDisplayName());
|
_availableList.add(descriptor.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshDisplayedList()
|
private void refreshDisplayedList()
|
||||||
{
|
{
|
||||||
_displayedList.removeAll();
|
_displayedList.removeAll();
|
||||||
// initialize display list
|
// initialize display list
|
||||||
for (int i = 0; i < _currentDisplayedDescriptors.size(); i++)
|
for (int i = 0; i < _currentDisplayedDescriptors.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
Object obj = _currentDisplayedDescriptors.get(i);
|
Object obj = _currentDisplayedDescriptors.get(i);
|
||||||
if (obj != null && obj instanceof IPropertyDescriptor)
|
if (obj != null && obj instanceof IPropertyDescriptor)
|
||||||
{
|
{
|
||||||
_displayedList.add(((IPropertyDescriptor)obj).getDisplayName());
|
_displayedList.add(((IPropertyDescriptor)obj).getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp()
|
private void setHelp()
|
||||||
{
|
{
|
||||||
setHelp(RSEUIPlugin.HELPPREFIX + "gntc0000"); //$NON-NLS-1$
|
setHelp(RSEUIPlugin.HELPPREFIX + "gntc0000"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectColumnsAction()
|
public SelectColumnsAction()
|
||||||
{
|
{
|
||||||
super(SystemResources.ACTION_SELECTCOLUMNS_LABEL, null);
|
super(SystemResources.ACTION_SELECTCOLUMNS_LABEL, null);
|
||||||
|
@ -1095,7 +1096,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
ISystemTableViewColumnManager mgr = _viewer.getColumnManager();
|
ISystemTableViewColumnManager mgr = _viewer.getColumnManager();
|
||||||
ISystemViewElementAdapter adapter = _viewer.getAdapterForContents();
|
ISystemViewElementAdapter adapter = _viewer.getAdapterForContents();
|
||||||
SelectColumnsDialog dlg = new SelectColumnsDialog(getShell(), adapter, mgr);
|
SelectColumnsDialog dlg = new SelectColumnsDialog(getShell(), adapter, mgr);
|
||||||
if (dlg.open() == Window.OK)
|
if (dlg.open() == Window.OK)
|
||||||
|
@ -1121,13 +1122,13 @@ public class SystemTableViewPart extends ViewPart
|
||||||
private LockAction _lockAction = null;
|
private LockAction _lockAction = null;
|
||||||
private RefreshAction _refreshAction = null;
|
private RefreshAction _refreshAction = null;
|
||||||
private SystemRefreshAction _refreshSelectionAction = null;
|
private SystemRefreshAction _refreshSelectionAction = null;
|
||||||
|
|
||||||
private SelectInputAction _selectInputAction = null;
|
private SelectInputAction _selectInputAction = null;
|
||||||
private PositionToAction _positionToAction = null;
|
private PositionToAction _positionToAction = null;
|
||||||
private SubSetAction _subsetAction = null;
|
private SubSetAction _subsetAction = null;
|
||||||
private SystemTablePrintAction _printTableAction = null;
|
private SystemTablePrintAction _printTableAction = null;
|
||||||
private SelectColumnsAction _selectColumnsAction = null;
|
private SelectColumnsAction _selectColumnsAction = null;
|
||||||
|
|
||||||
// common actions
|
// common actions
|
||||||
private SystemCopyToClipboardAction _copyAction;
|
private SystemCopyToClipboardAction _copyAction;
|
||||||
private SystemPasteFromClipboardAction _pasteAction;
|
private SystemPasteFromClipboardAction _pasteAction;
|
||||||
|
@ -1144,8 +1145,8 @@ public class SystemTableViewPart extends ViewPart
|
||||||
private String _message, _errorMessage;
|
private String _message, _errorMessage;
|
||||||
private SystemMessage sysErrorMessage;
|
private SystemMessage sysErrorMessage;
|
||||||
private IStatusLineManager _statusLine = null;
|
private IStatusLineManager _statusLine = null;
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
public static final String ID = "org.eclipse.rse.ui.view.systemTableView"; // matches id in plugin.xml, view tag //$NON-NLS-1$
|
public static final String ID = "org.eclipse.rse.ui.view.systemTableView"; // matches id in plugin.xml, view tag //$NON-NLS-1$
|
||||||
|
|
||||||
// Restore memento tags
|
// Restore memento tags
|
||||||
|
@ -1182,7 +1183,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
{
|
{
|
||||||
return _viewer;
|
return _viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Viewer getRSEViewer()
|
public Viewer getRSEViewer()
|
||||||
{
|
{
|
||||||
return _viewer;
|
return _viewer;
|
||||||
|
@ -1195,7 +1196,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||||
registry.addSystemResourceChangeListener(this);
|
registry.addSystemResourceChangeListener(this);
|
||||||
registry.addSystemRemoteChangeListener(this);
|
registry.addSystemRemoteChangeListener(this);
|
||||||
|
|
||||||
Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
|
Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
|
||||||
_viewer = new SystemTableView(table, this);
|
_viewer = new SystemTableView(table, this);
|
||||||
|
|
||||||
|
@ -1220,7 +1221,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
_browseHistory = new ArrayList();
|
_browseHistory = new ArrayList();
|
||||||
_browsePosition = 0;
|
_browsePosition = 0;
|
||||||
|
|
||||||
// register global edit actions
|
// register global edit actions
|
||||||
Clipboard clipboard = RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard();
|
Clipboard clipboard = RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard();
|
||||||
|
|
||||||
CellEditorActionHandler editorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
|
CellEditorActionHandler editorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
|
||||||
|
@ -1234,13 +1235,13 @@ public class SystemTableViewPart extends ViewPart
|
||||||
editorActionHandler.setPasteAction(_pasteAction);
|
editorActionHandler.setPasteAction(_pasteAction);
|
||||||
editorActionHandler.setDeleteAction(_deleteAction);
|
editorActionHandler.setDeleteAction(_deleteAction);
|
||||||
editorActionHandler.setSelectAllAction(new SelectAllAction());
|
editorActionHandler.setSelectAllAction(new SelectAllAction());
|
||||||
|
|
||||||
// register rename action as a global handler
|
// register rename action as a global handler
|
||||||
getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.RENAME.getId(), _renameAction);
|
getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.RENAME.getId(), _renameAction);
|
||||||
|
|
||||||
|
|
||||||
SystemWidgetHelpers.setHelp(_viewer.getControl(), RSEUIPlugin.HELPPREFIX + "sysd0000"); //$NON-NLS-1$
|
SystemWidgetHelpers.setHelp(_viewer.getControl(), RSEUIPlugin.HELPPREFIX + "sysd0000"); //$NON-NLS-1$
|
||||||
|
|
||||||
getSite().registerContextMenu(_viewer.getContextMenuManager(), _viewer);
|
getSite().registerContextMenu(_viewer.getContextMenuManager(), _viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,7 +1291,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||||
registry.removeSystemRemoteChangeListener(this);
|
registry.removeSystemRemoteChangeListener(this);
|
||||||
registry.removeSystemResourceChangeListener(this);
|
registry.removeSystemResourceChangeListener(this);
|
||||||
|
|
||||||
if (_viewer != null)
|
if (_viewer != null)
|
||||||
{
|
{
|
||||||
_viewer.dispose();
|
_viewer.dispose();
|
||||||
|
@ -1311,7 +1312,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
if (adapter != null)
|
if (adapter != null)
|
||||||
{
|
{
|
||||||
alreadyHandled = adapter.handleDoubleClick(element);
|
alreadyHandled = adapter.handleDoubleClick(element);
|
||||||
|
|
||||||
if (!alreadyHandled && adapter.hasChildren((IAdaptable)element))
|
if (!alreadyHandled && adapter.hasChildren((IAdaptable)element))
|
||||||
{
|
{
|
||||||
setInput((IAdaptable) element);
|
setInput((IAdaptable) element);
|
||||||
|
@ -1390,9 +1391,9 @@ public class SystemTableViewPart extends ViewPart
|
||||||
_refreshSelectionAction = new SystemRefreshAction(getShell());
|
_refreshSelectionAction = new SystemRefreshAction(getShell());
|
||||||
actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), _refreshSelectionAction);
|
actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), _refreshSelectionAction);
|
||||||
_refreshSelectionAction.setSelectionProvider(_viewer);
|
_refreshSelectionAction.setSelectionProvider(_viewer);
|
||||||
|
|
||||||
_statusLine = actionBars.getStatusLineManager();
|
_statusLine = actionBars.getStatusLineManager();
|
||||||
|
|
||||||
addToolBarItems(toolBarManager);
|
addToolBarItems(toolBarManager);
|
||||||
addToolBarMenuItems(menuMgr);
|
addToolBarMenuItems(menuMgr);
|
||||||
}
|
}
|
||||||
|
@ -1406,8 +1407,8 @@ public class SystemTableViewPart extends ViewPart
|
||||||
menuManager.add(new Separator("Filter")); //$NON-NLS-1$
|
menuManager.add(new Separator("Filter")); //$NON-NLS-1$
|
||||||
menuManager.add(_positionToAction);
|
menuManager.add(_positionToAction);
|
||||||
menuManager.add(_subsetAction);
|
menuManager.add(_subsetAction);
|
||||||
|
|
||||||
//DKM - this action is useless - remove it
|
//DKM - this action is useless - remove it
|
||||||
// menuManager.add(new Separator("Print"));
|
// menuManager.add(new Separator("Print"));
|
||||||
// menuManager.add(_printTableAction);
|
// menuManager.add(_printTableAction);
|
||||||
|
|
||||||
|
@ -1421,8 +1422,8 @@ public class SystemTableViewPart extends ViewPart
|
||||||
|
|
||||||
toolBarManager.add(_lockAction);
|
toolBarManager.add(_lockAction);
|
||||||
toolBarManager.add(_refreshAction);
|
toolBarManager.add(_refreshAction);
|
||||||
|
|
||||||
|
|
||||||
toolBarManager.add(new Separator("Navigate")); //$NON-NLS-1$
|
toolBarManager.add(new Separator("Navigate")); //$NON-NLS-1$
|
||||||
// only support history when we're locked
|
// only support history when we're locked
|
||||||
if (_isLocked)
|
if (_isLocked)
|
||||||
|
@ -1467,7 +1468,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
if (_currentItem != null)
|
if (_currentItem != null)
|
||||||
{
|
{
|
||||||
IAdaptable item = _currentItem.getObject();
|
IAdaptable item = _currentItem.getObject();
|
||||||
|
|
||||||
ISystemViewElementAdapter adapter1 = (ISystemViewElementAdapter)object.getAdapter(ISystemViewElementAdapter.class);
|
ISystemViewElementAdapter adapter1 = (ISystemViewElementAdapter)object.getAdapter(ISystemViewElementAdapter.class);
|
||||||
ISystemViewElementAdapter adapter2 = (ISystemViewElementAdapter)item.getAdapter(ISystemViewElementAdapter.class);
|
ISystemViewElementAdapter adapter2 = (ISystemViewElementAdapter)item.getAdapter(ISystemViewElementAdapter.class);
|
||||||
if (adapter1 == adapter2)
|
if (adapter1 == adapter2)
|
||||||
|
@ -1501,7 +1502,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
{
|
{
|
||||||
setTitle(object);
|
setTitle(object);
|
||||||
_viewer.setInput(object);
|
_viewer.setInput(object);
|
||||||
|
|
||||||
if (_refreshSelectionAction != null)
|
if (_refreshSelectionAction != null)
|
||||||
{
|
{
|
||||||
_refreshSelectionAction.updateSelection(new StructuredSelection(object));
|
_refreshSelectionAction.updateSelection(new StructuredSelection(object));
|
||||||
|
@ -1519,7 +1520,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentItem = new HistoryItem(object, filters);
|
_currentItem = new HistoryItem(object, filters);
|
||||||
|
|
||||||
|
|
||||||
_browseHistory.add(_currentItem);
|
_browseHistory.add(_currentItem);
|
||||||
_browsePosition = _browseHistory.lastIndexOf(_currentItem);
|
_browsePosition = _browseHistory.lastIndexOf(_currentItem);
|
||||||
|
@ -1544,7 +1545,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
String type = va.getType(object);
|
String type = va.getType(object);
|
||||||
String name = va.getName(object);
|
String name = va.getName(object);
|
||||||
//setPartName(type + " " + name);
|
//setPartName(type + " " + name);
|
||||||
|
|
||||||
setContentDescription(type + " "+ name); //$NON-NLS-1$
|
setContentDescription(type + " "+ name); //$NON-NLS-1$
|
||||||
|
|
||||||
//SystemTableViewProvider provider = (SystemTableViewProvider) _viewer.getContentProvider();
|
//SystemTableViewProvider provider = (SystemTableViewProvider) _viewer.getContentProvider();
|
||||||
|
@ -1577,12 +1578,12 @@ public class SystemTableViewPart extends ViewPart
|
||||||
// Update the history to remove all references to object
|
// Update the history to remove all references to object
|
||||||
removeFromHistory(multi[i]);
|
removeFromHistory(multi[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeFromHistory(Object c)
|
protected void removeFromHistory(Object c)
|
||||||
{
|
{
|
||||||
// if the object is in history, remove it since it's been deleted
|
// if the object is in history, remove it since it's been deleted
|
||||||
|
@ -1605,12 +1606,12 @@ public class SystemTableViewPart extends ViewPart
|
||||||
// Since we are removing an item the size decreased by one so i
|
// Since we are removing an item the size decreased by one so i
|
||||||
// needs to decrease by one or we will skip elements in _browseHistory
|
// needs to decrease by one or we will skip elements in _browseHistory
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_currentItem != null) {
|
if (_currentItem != null) {
|
||||||
Object currentObject = _currentItem.getObject();
|
Object currentObject = _currentItem.getObject();
|
||||||
|
|
||||||
// Update the input of the viewer to the closest item in the history
|
// Update the input of the viewer to the closest item in the history
|
||||||
// that still exists if the current viewer item has been deleted.
|
// that still exists if the current viewer item has been deleted.
|
||||||
if (c == currentObject || c.equals(currentObject) || isParentOf(c,currentObject))
|
if (c == currentObject || c.equals(currentObject) || isParentOf(c,currentObject))
|
||||||
|
@ -1628,7 +1629,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isParentOf(Object parent, Object child) {
|
protected boolean isParentOf(Object parent, Object child) {
|
||||||
if (parent instanceof IAdaptable && child instanceof IAdaptable) {
|
if (parent instanceof IAdaptable && child instanceof IAdaptable) {
|
||||||
ISystemDragDropAdapter adapterParent = (ISystemDragDropAdapter) ((IAdaptable)parent).getAdapter(ISystemDragDropAdapter.class);
|
ISystemDragDropAdapter adapterParent = (ISystemDragDropAdapter) ((IAdaptable)parent).getAdapter(ISystemDragDropAdapter.class);
|
||||||
|
@ -1636,8 +1637,8 @@ public class SystemTableViewPart extends ViewPart
|
||||||
// Check that both parent and child are from the same SubSystem
|
// Check that both parent and child are from the same SubSystem
|
||||||
if (adapterParent != null && adapterChild != null &&
|
if (adapterParent != null && adapterChild != null &&
|
||||||
adapterParent.getSubSystem(parent) == adapterChild.getSubSystem(child)) {
|
adapterParent.getSubSystem(parent) == adapterChild.getSubSystem(child)) {
|
||||||
String parentAbsoluteName = adapterParent.getAbsoluteName(parent);
|
String parentAbsoluteName = adapterParent.getAbsoluteName(parent);
|
||||||
String childAbsoluteName = adapterChild.getAbsoluteName(child);
|
String childAbsoluteName = adapterChild.getAbsoluteName(child);
|
||||||
// Check if the child's absolute name starts with the parents absolute name
|
// Check if the child's absolute name starts with the parents absolute name
|
||||||
// if it does then parent is the parent of child.
|
// if it does then parent is the parent of child.
|
||||||
if(childAbsoluteName != null && childAbsoluteName.startsWith(parentAbsoluteName)) {
|
if(childAbsoluteName != null && childAbsoluteName.startsWith(parentAbsoluteName)) {
|
||||||
|
@ -1647,8 +1648,8 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the method in your class that will be called when a remote resource
|
* This is the method in your class that will be called when a remote resource
|
||||||
* changes. You will be called after the resource is changed.
|
* changes. You will be called after the resource is changed.
|
||||||
|
@ -1666,22 +1667,17 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
|
|
||||||
Object child = event.getResource();
|
Object child = event.getResource();
|
||||||
|
|
||||||
|
|
||||||
Object input = _viewer.getInput();
|
Object input = _viewer.getInput();
|
||||||
|
|
||||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
String[] oldNames = event.getOldNames();
|
||||||
|
// right now assuming only one resource
|
||||||
boolean referToSameObject = false;
|
String oldName = (oldNames == null) ? null : oldNames[0];
|
||||||
if (registry instanceof SystemRegistry)
|
boolean referToSameObject = SystemRegistry.isSameObjectByAbsoluteName(input, null, child, oldName);
|
||||||
{
|
|
||||||
String[] oldNames = event.getOldNames();
|
|
||||||
String oldName = (oldNames == null)? null : oldNames[0];
|
|
||||||
referToSameObject = ((SystemRegistry)registry).isSameObjectByAbsoluteName(input, null, child, oldName); // right now assuming only one resource
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input == child || child instanceof java.util.List || referToSameObject)
|
if (input == child || child instanceof java.util.List || referToSameObject)
|
||||||
{
|
{
|
||||||
switch (eventType)
|
switch (eventType)
|
||||||
{
|
{
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
@ -1689,31 +1685,31 @@ public class SystemTableViewPart extends ViewPart
|
||||||
// --------------------------
|
// --------------------------
|
||||||
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CHANGED :
|
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CHANGED :
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// REMOTE RESOURCE CREATED...
|
// REMOTE RESOURCE CREATED...
|
||||||
// --------------------------
|
// --------------------------
|
||||||
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED :
|
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED :
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// REMOTE RESOURCE DELETED...
|
// REMOTE RESOURCE DELETED...
|
||||||
// --------------------------
|
// --------------------------
|
||||||
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED :
|
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED :
|
||||||
{
|
{
|
||||||
if (child instanceof java.util.List)
|
if (child instanceof java.util.List)
|
||||||
{
|
{
|
||||||
java.util.List list = (java.util.List)child;
|
java.util.List list = (java.util.List)child;
|
||||||
for (int v = 0; v < list.size(); v++)
|
for (int v = 0; v < list.size(); v++)
|
||||||
{
|
{
|
||||||
Object c = list.get(v);
|
Object c = list.get(v);
|
||||||
|
|
||||||
removeFromHistory(c);
|
removeFromHistory(c);
|
||||||
/*
|
/*
|
||||||
if (c == input)
|
if (c == input)
|
||||||
{
|
{
|
||||||
setInput((IAdaptable)null, null, false);
|
setInput((IAdaptable)null, null, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -1723,12 +1719,12 @@ public class SystemTableViewPart extends ViewPart
|
||||||
{
|
{
|
||||||
removeFromHistory(child);
|
removeFromHistory(child);
|
||||||
//setInput((IAdaptable)null);
|
//setInput((IAdaptable)null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// REMOTE RESOURCE RENAMED...
|
// REMOTE RESOURCE RENAMED...
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
@ -1736,12 +1732,12 @@ public class SystemTableViewPart extends ViewPart
|
||||||
{
|
{
|
||||||
setInput((IAdaptable)child);
|
setInput((IAdaptable)child);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shell getShell()
|
public Shell getShell()
|
||||||
{
|
{
|
||||||
return _viewer.getShell();
|
return _viewer.getShell();
|
||||||
|
@ -1762,7 +1758,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
* within the part controls.
|
* within the part controls.
|
||||||
* <p>
|
* <p>
|
||||||
* The parent's default implementation will ignore the memento and initialize
|
* The parent's default implementation will ignore the memento and initialize
|
||||||
* the view in a fresh state. Subclasses may override the implementation to
|
* the view in a fresh state. Subclasses may override the implementation to
|
||||||
* perform any state restoration as needed.
|
* perform any state restoration as needed.
|
||||||
*/
|
*/
|
||||||
public void init(IViewSite site, IMemento memento) throws PartInitException
|
public void init(IViewSite site, IMemento memento) throws PartInitException
|
||||||
|
@ -1780,12 +1776,12 @@ public class SystemTableViewPart extends ViewPart
|
||||||
* Method declared on IViewPart.
|
* Method declared on IViewPart.
|
||||||
*/
|
*/
|
||||||
public void saveState(IMemento memento)
|
public void saveState(IMemento memento)
|
||||||
{
|
{
|
||||||
super.saveState(memento);
|
super.saveState(memento);
|
||||||
|
|
||||||
if (!SystemPreferencesManager.getRememberState())
|
if (!SystemPreferencesManager.getRememberState())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_viewer != null)
|
if (_viewer != null)
|
||||||
{
|
{
|
||||||
Object input = _viewer.getInput();
|
Object input = _viewer.getInput();
|
||||||
|
@ -1794,7 +1790,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
{
|
{
|
||||||
if (input instanceof ISystemRegistry)
|
if (input instanceof ISystemRegistry)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (input instanceof IHost)
|
else if (input instanceof IHost)
|
||||||
{
|
{
|
||||||
|
@ -1863,8 +1859,8 @@ public class SystemTableViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
// ISystemMessageLine interface...
|
// ISystemMessageLine interface...
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
@ -1951,7 +1947,7 @@ public class SystemTableViewPart extends ViewPart
|
||||||
if (_statusLine != null)
|
if (_statusLine != null)
|
||||||
_statusLine.setMessage(message);
|
_statusLine.setMessage(message);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*If the message line currently displays an error,
|
*If the message line currently displays an error,
|
||||||
* the message is stored and will be shown after a call to clearErrorMessage
|
* the message is stored and will be shown after a call to clearErrorMessage
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue