Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view')
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java77
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ElementComparer.java78
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ISystemMementoConstants.java51
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SafeTreeViewer.java161
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SubSystemConfigurationAdapterFactory.java60
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemComboBoxCellEditor.java225
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemComboBoxPropertyDescriptor.java90
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java874
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDecoratingLabelProvider.java59
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDeferredTableTreeContentManager.java82
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDropActionDelegate.java280
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemEmptyListAPIProviderImpl.java87
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritablePropertyData.java174
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritableTextCellEditor.java517
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritableTextPropertyDescriptor.java114
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPerspectiveHelpers.java188
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPerspectiveLayout.java94
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPropertySheetForm.java225
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResolveFilterStringAPIProviderImpl.java41
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResourceSelectionForm.java646
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResourceSelectionInputProvider.java194
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemSelectRemoteObjectAPIProviderImpl.java631
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeView.java2057
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeViewProvider.java473
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewColumnManager.java147
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewFilter.java105
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java1993
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewSorter.java186
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTestFilterStringAPIProviderImpl.java128
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java6625
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForConnections.java100
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilterPools.java120
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilterStrings.java191
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilters.java253
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForSubSystems.java99
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAdapterFactory.java169
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewCompositeActionGroup.java105
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java734
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDataDragAdapter.java436
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDataDropAdapter.java414
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDummyObject.java45
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java593
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolAdapter.java299
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java416
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java1049
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterStringAdapter.java297
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewForm.java542
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewLabelAndContentProvider.java498
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewMenuListener.java170
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewMessageAdapter.java210
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewNewConnectionPromptAdapter.java39
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPart.java2053
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPartFrameSource.java56
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPartGotoActionGroup.java107
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPromptableAdapter.java227
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewResources.java143
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewResources.properties117
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewRootInputAdapter.java245
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewScratchpadAdapter.java284
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewSubSystemAdapter.java818
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/BrowseAction.java55
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/ClearAction.java53
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/ClearSelectedAction.java60
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/MonitorViewPage.java587
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/MonitorViewWorkbook.java281
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/SystemMonitorUI.java78
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/SystemMonitorViewPart.java1133
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/TabFolderLayout.java62
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/BrowseAction.java54
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/ClearAction.java68
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/ClearSelectedAction.java105
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadView.java1976
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadViewPart.java418
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadViewProvider.java269
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchClearHistoryAction.java53
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchCopyToClipboardAction.java57
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchHistoryAction.java64
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchRemoveAllMatchesAction.java54
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchRemoveSelectedMatchesAction.java54
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchTableView.java387
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchTableViewProvider.java46
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchUI.java73
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewContentProvider.java184
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewLabelProvider.java94
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewPart.java1278
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemResourceAdaptableProfile.java36
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamView.java269
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewCategoryAdapter.java328
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewCategoryNode.java155
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewContentProvider.java245
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewInputProvider.java149
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewLabelProvider.java215
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewMakeActiveProfileAction.java92
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewMakeInActiveProfileAction.java92
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPart.java1585
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewProfileAdapter.java401
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPropertySetAdapter.java258
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPropertySetNode.java146
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewRefreshAllAction.java80
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewResourceAdapterFactory.java70
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationAdapter.java306
-rw-r--r--rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationNode.java213
102 files changed, 0 insertions, 39674 deletions
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java
deleted file mode 100644
index 6672fbfec..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2008 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight.
- *
- * Contributors:
- * David McKnight (IBM) - [187739] [refresh] Sub Directories are collapsed when Parent Directory is Refreshed on Remote Systems
- ********************************************************************************/
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.IRSECallback;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.view.ContextObject;
-
-public class ContextObjectWithViewer extends ContextObject {
- private Viewer _viewer;
- private IRSECallback _callback;
-
- public ContextObjectWithViewer(Object modelObject, Viewer viewer){
- super(modelObject);
- _viewer = viewer;
- }
-
- public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, Viewer viewer){
- super(modelObject, subsystem);
- _viewer = viewer;
- }
-
- public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, ISystemFilterReference filterReference, Viewer viewer){
- super(modelObject, subsystem, filterReference);
- _viewer = viewer;
- }
-
- public ContextObjectWithViewer(Object modelObject, Viewer viewer, IRSECallback callback){
- super(modelObject);
- _viewer = viewer;
- _callback = callback;
- }
-
- public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, Viewer viewer, IRSECallback callback){
- super(modelObject, subsystem);
- _viewer = viewer;
- _callback = callback;
- }
-
- public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, ISystemFilterReference filterReference, Viewer viewer, IRSECallback callback){
- super(modelObject, subsystem, filterReference);
- _viewer = viewer;
- _callback = callback;
- }
-
- public Viewer getViewer()
- {
- return _viewer;
- }
-
- public IRSECallback getCallback()
- {
- return _callback;
- }
-
- public void setCallback(IRSECallback callback){
- _callback = callback;
- }
-
- public void setViewer(Viewer viewer){
- _viewer = viewer;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ElementComparer.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ElementComparer.java
deleted file mode 100644
index 48e1c205a..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ElementComparer.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2007, 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Kevin Doyle (IBM) - [195537] Move ElementComparer From SystemView to Separate File
- * 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) - [228774] [regression] AssertionFailedException when connecting to New Connection
- * Martin Oberhuber (Wind River) - [228774] Improve ElementComparer Performance
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
-import org.eclipse.rse.internal.core.model.SystemRegistry;
-
-/**
- * An implementation of an element comparer for the system view.
- */
-public class ElementComparer implements IElementComparer {
-
- public boolean equals(Object a, Object b) {
- // equal if same absolute name in same subsystem;
- // or, when adapters are not found, both are the same instance.
- return SystemRegistry.isSameObjectByAbsoluteName(a, null, b, null);
- }
-
- public int hashCode(Object element) {
- /*
- * Hashcodes should be invariant across the lifetime of the object.
- * Since one adapter is typically used for many elements in RSE,
- * performance would be better if the original Element's hashCode
- * were used rather than the adapter's hashCode. The problem with
- * this is, that if the remote object changes, it cannot be
- * identified any more.
- * Note that currently the hashCode of the object can change
- * 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.
- */
- int result = 0;
- if (element != null) {
- ISystemDragDropAdapter dda = SystemRegistry.getSystemDragDropAdapter(element);
- if (dda != null) {
- // adapter available
- String absName = dda.getAbsoluteName(element);
- if (absName != null) {
- result = absName.hashCode();
- } else {
- result = dda.hashCode();
- }
- } 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();
- }
- }
- return result;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ISystemMementoConstants.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ISystemMementoConstants.java
deleted file mode 100644
index e3dcf4ff4..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/ISystemMementoConstants.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-public interface ISystemMementoConstants
-{
-
- /**
- * Memento ID for profiles
- */
- public static final String MEMENTO_KEY_PROFILE = "Profile"; //$NON-NLS-1$
- /**
- * Memento ID for connections
- */
- public static final String MEMENTO_KEY_CONNECTION = "Conn"; //$NON-NLS-1$
- /**
- * Memento ID for subsystems
- */
- public static final String MEMENTO_KEY_SUBSYSTEM = "Subs"; //$NON-NLS-1$
- /**
- * Memento ID for filter pool references
- */
- public static final String MEMENTO_KEY_FILTERPOOLREFERENCE = "FPoolRef"; //$NON-NLS-1$
- /**
- * Memento ID for filter references
- */
- public static final String MEMENTO_KEY_FILTERREFERENCE = "FRef"; //$NON-NLS-1$
- /**
- * Memento ID for filter string references
- */
- public static final String MEMENTO_KEY_FILTERSTRINGREFERENCE = "FSRef"; //$NON-NLS-1$
- /**
- * Memento ID for remote objects
- */
- public static final String MEMENTO_KEY_REMOTE = "Remote"; //$NON-NLS-1$
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SafeTreeViewer.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SafeTreeViewer.java
deleted file mode 100644
index c276c671c..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SafeTreeViewer.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Uwe Stieber (Wind River) - initial API and implementation.
- ********************************************************************************/
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.jface.viewers.IDelayedLabelDecorator;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * The SafeTreeViewer wraps an SWT TreeViewer in order to avoid
- * exceptions due to accessing already disposed items.
- *
- * The main reason for this wrapping is that delayed label providers
- * (i.e. instances of {@link IDelayedLabelDecorator}) can trigger tree
- * item updates called in the viewer after the tree item itself got
- * disposed already. This happens especially if items appear and
- * disappear very fast within the tree which then will lead to nasty
- * SWT Widget already disposed exceptions.
- *
- * Clients may subclass this class.
- *
- * @since RSE 2.0
- */
-public class SafeTreeViewer extends TreeViewer {
-
- /**
- * Constructor.
- *
- * @param parent The parent control.
- */
- public SafeTreeViewer(Composite parent) {
- super(parent);
- }
-
- /**
- * Constructor.
- *
- * @param tree The tree control.
- */
- public SafeTreeViewer(Tree tree) {
- super(tree);
- }
-
- /**
- * Constructor.
- *
- * @param parent The parent control.
- * @param style The SWT style bits passed to the tree creation.
- */
- public SafeTreeViewer(Composite parent, int style) {
- super(parent, style);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#doUpdateItem(org.eclipse.swt.widgets.Item, java.lang.Object)
- */
- protected void doUpdateItem(Item item, Object element) {
- if (item != null && item.isDisposed()) return;
- super.doUpdateItem(item, element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#doUpdateItem(org.eclipse.swt.widgets.Widget, java.lang.Object, boolean)
- */
- protected void doUpdateItem(Widget widget, Object element, boolean fullMap) {
- if (widget != null && widget.isDisposed()) return;
- super.doUpdateItem(widget, element, fullMap);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#getItemCount(org.eclipse.swt.widgets.Control)
- */
- protected int getItemCount(Control widget) {
- if (widget != null && widget.isDisposed()) return 0;
- return super.getItemCount(widget);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#getItemCount(org.eclipse.swt.widgets.Item)
- */
- protected int getItemCount(Item item) {
- if (item != null && item.isDisposed()) return 0;
- return super.getItemCount(item);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#showItem(org.eclipse.swt.widgets.Item)
- */
- protected void showItem(Item item) {
- if (item != null && item.isDisposed()) return;
- super.showItem(item);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#updatePlus(org.eclipse.swt.widgets.Item, java.lang.Object)
- */
- protected void updatePlus(Item item, Object element) {
- if (item != null && item.isDisposed()) return;
- super.updatePlus(item, element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#createChildren(org.eclipse.swt.widgets.Widget)
- */
- protected void createChildren(Widget widget) {
- if (widget != null && widget.isDisposed()) return;
- super.createChildren(widget);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#getChild(org.eclipse.swt.widgets.Widget, int)
- */
- protected Item getChild(Widget widget, int index) {
- if (widget != null && widget.isDisposed()) return null;
- return super.getChild(widget, index);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#getChildren(org.eclipse.swt.widgets.Widget)
- */
- protected Item[] getChildren(Widget widget) {
- if (widget != null && widget.isDisposed()) return new Item[0];
- return super.getChildren(widget);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#getExpanded(org.eclipse.swt.widgets.Item)
- */
- protected boolean getExpanded(Item item) {
- if (item != null && item.isDisposed()) return false;
- return super.getExpanded(item);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#getItems(org.eclipse.swt.widgets.Item)
- */
- protected Item[] getItems(Item item) {
- if (item != null && item.isDisposed()) return new Item[0];
- return super.getItems(item);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.TreeViewer#getParentItem(org.eclipse.swt.widgets.Item)
- */
- protected Item getParentItem(Item item) {
- if (item != null && item.isDisposed()) return null;
- return super.getParentItem(item);
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SubSystemConfigurationAdapterFactory.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SubSystemConfigurationAdapterFactory.java
deleted file mode 100644
index e78215033..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SubSystemConfigurationAdapterFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.ui.view.SubSystemConfigurationAdapter;
-
-
-public class SubSystemConfigurationAdapterFactory implements IAdapterFactory
-{
-
- private ISubSystemConfigurationAdapter ssFactoryAdapter = new SubSystemConfigurationAdapter();
-
- /**
- * @see IAdapterFactory#getAdapterList()
- */
- public Class[] getAdapterList()
- {
- return new Class[] {ISubSystemConfigurationAdapter.class};
- }
- /**
- * Called by our plugin's startup method to register our adaptable object types
- * with the platform. We prefer to do it here to isolate/encapsulate all factory
- * logic in this one place.
- */
- public void registerWithManager(IAdapterManager manager)
- {
- manager.registerAdapters(this, ISubSystemConfiguration.class);
- }
- /**
- * @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptableObject, Class adapterType)
- {
- Object adapter = null;
- if (adaptableObject instanceof ISubSystemConfiguration)
- adapter = ssFactoryAdapter;
-
- return adapter;
- }
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemComboBoxCellEditor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemComboBoxCellEditor.java
deleted file mode 100644
index 6d35e73a4..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemComboBoxCellEditor.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * A slight variation of the Eclipse-supplied ComboBoxCellEditor class, which
- * allows the input array to be changed dynamically.
- * <p>
- * A cell editor that presents a list of items in a combo box. The cell editor's
- * value is the zero-based index of the selected item.
- * </p>
- *
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class SystemComboBoxCellEditor extends CellEditor
-{
- private boolean readOnly = false;
- /**
- * The list of items to present in the combo box.
- */
- private String[] items;
-
- /**
- * The zero-based index of the selected item.
- */
- private int selection;
-
- /**
- * The custom combo box control.
- */
- private CCombo comboBox;
- /**
- * Creates a new cell editor with a combo containing the given
- * list of choices and parented under the given control. The cell
- * editor value is the zero-based index of the selected item.
- * Initially, the cell editor has no cell validator and
- * the first item in the list is selected.
- *
- * @param parent the parent control
- * @param items the list of strings for the combo box
- */
- public SystemComboBoxCellEditor(Composite parent, String[] items)
- {
- super(parent);
- selection = 0;
- if (items != null)
- setItems(items);
- else
- setValueValid(true);
- }
- /**
- * Creates a new cell editor with a combo containing the given
- * list of choices and parented under the given control. The cell
- * editor value is the zero-based index of the selected item.
- * Initially, the cell editor has no cell validator and
- * the first item in the list is selected.
- *
- * @param parent the parent control
- * //@param whether or not this is readonly
- */
- //public SystemComboBoxCellEditor(Composite parent, boolean readOnly)
- public SystemComboBoxCellEditor(Composite parent)
- {
- super(parent);
- selection = 0;
- //this.readOnly = readOnly;
- setValueValid(true);
- }
- /**
- * Change the input items
- */
- public void setItems(String[] items)
- {
- this.items = items;
- populateComboBoxItems();
- setValueValid(true);
- }
- /* (non-Javadoc)
- * Method declared on CellEditor.
- */
- protected Control createControl(Composite parent)
- {
- if (!readOnly)
- comboBox = new CCombo(parent, SWT.NONE);
- else
- comboBox = new CCombo(parent, SWT.READ_ONLY);
- comboBox.setFont(parent.getFont());
-
- comboBox.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- keyReleaseOccured(e);
- }
- });
-
- comboBox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
-
- // DKM - only process this when there is a selection change
- // fix for defect 138324
- if (selection == comboBox.getSelectionIndex() && comboBox.getText().equals(comboBox.getItem(comboBox.getSelectionIndex())))
- return; // no change
-
- // must set the selection before getting value
- selection = comboBox.getSelectionIndex();
- Object newValue = doGetValue();
-
-
- boolean newValidState = isCorrect(newValue);
- if (newValidState) {
- doSetValue(newValue);
- } else {
- // try to insert the current value into the error message.
- setErrorMessage(
- NLS.bind(getErrorMessage(), items[selection]));
- }
- fireApplyEditorValue();
- }
- });
-
- comboBox.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- }
- }
- });
-
- return comboBox;
- }
- /**
- * The <code>ComboBoxCellEditor</code> implementation of
- * this <code>CellEditor</code> framework method returns
- * the zero-based index of the current selection.
- *
- * @return the zero-based index of the current selection wrapped
- * as an <code>Integer</code>
- */
- protected Object doGetValue()
- {
- return new Integer(selection);
- }
- /* (non-Javadoc)
- * Method declared on CellEditor.
- */
- protected void doSetFocus()
- {
- comboBox.setFocus();
- }
- /**
- * The <code>ComboBoxCellEditor</code> implementation of
- * this <code>CellEditor</code> framework method
- * accepts a zero-based index of a selection.
- *
- * @param value the zero-based index of the selection wrapped
- * as an <code>Integer</code>
- */
- protected void doSetValue(Object value)
- {
- if (!(value instanceof Integer))
- {
- String[] items = comboBox.getItems();
- for (int i = 0; i < items.length; i++)
- {
- String item = items[i];
- if (item.equals(value))
- {
- selection = i;
- }
- }
- return;
- }
-
- //Assert.isTrue(comboBox != null && (value instanceof Integer));
- int newselection = ((Integer) value).intValue();
- if (newselection != selection)
- {
- selection = newselection;
- }
- String curText = comboBox.getText();
- if (!comboBox.getItem(selection).equals(curText))
- {
- comboBox.select(selection);
- }
- }
- /**
- * Add the items to the combo box.
- */
- private void populateComboBoxItems()
- {
- if (comboBox != null && items != null)
- {
- comboBox.removeAll();
- for (int i = 0; i < items.length; i++)
- comboBox.add(items[i], i);
- setValueValid(true);
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemComboBoxPropertyDescriptor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemComboBoxPropertyDescriptor.java
deleted file mode 100644
index e849c9158..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemComboBoxPropertyDescriptor.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-/**
- * A variation of the Eclipse-supplied ComboBoxPropertyDescriptor for
- * displaying properties are a list. This list will be different for each
- * selected object, hence we need the ability to change that list as each
- * object is selected.
- */
-public class SystemComboBoxPropertyDescriptor
- extends PropertyDescriptor
-{
- private SystemComboBoxCellEditor editor;
-
- /**
- * The list of possible values to display in the combo box
- */
- protected String[] values;
- /**
- * Creates an property descriptor with the given id, display name, and list
- * of value labels to display in the combo box cell editor.
- *
- * @param id the id of the property
- * @param displayName the name to display for the property
- * @param valuesArray the list of possible values to display in the combo box
- */
- public SystemComboBoxPropertyDescriptor(Object id, String displayName, String[] valuesArray)
- {
- super(id, displayName);
- values = valuesArray;
- }
- /**
- * Creates an property descriptor with the given id, display name, but no list.
- * You must call setValues.
- *
- * @param id the id of the property
- * @param displayName the name to display for the property
- */
- public SystemComboBoxPropertyDescriptor(Object id, String displayName)
- {
- super(id, displayName);
- }
- /**
- * The <code>ComboBoxPropertyDescriptor</code> implementation of this
- * <code>IPropertyDescriptor</code> method creates and returns a new
- * <code>ComboBoxCellEditor</code>.
- * <p>
- * The editor is configured with the current validator if there is one.
- * </p>
- */
- public CellEditor createPropertyEditor(Composite parent)
- {
- //editor = new SystemComboBoxCellEditor(parent, false); // last parm = readonly
- editor = new SystemComboBoxCellEditor(parent);
- editor.setItems(values);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
- /**
- * Set the values to display in the list.
- */
- public void setValues(String[] values)
- {
- this.values = values;
- if (editor != null)
- editor.setItems(values);
- }
-
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java
deleted file mode 100644
index 0acd6e9ad..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java
+++ /dev/null
@@ -1,874 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes
- * Rupen Mardirossian (IBM) - [187713] Check to see if target is null before attempting to retrieve targetAdapter in tranferRSEResources method (line 248)
- * Martin Oberhuber (Wind River) - [200682] Fix drag&drop for elements just adaptable to IResource, like CDT elements
- * David McKnight (IBM) - [186363] get rid of obsolete calls to SubSystem.connect()
- * Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
- * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
- * David McKnight (IBM) - [228587] [dnd] NPE From Refresh on Copy/Paste
- * David McKnight (IBM) - [232889] Dragging and dropping files from a remote unix system to a local project does not work
- * David McKnight (IBM) - [234721] [dnd] When dragging a file from windows file explorer into RSE, a refresh error is given.
- * David McKnight (IBM) - [248922] [dnd] Remote to local overwrite copy does not work
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemContainer;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.model.ISystemResourceSet;
-import org.eclipse.rse.core.model.SystemRemoteResourceSet;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
-import org.eclipse.rse.internal.ui.GenericMessages;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.internal.model.SystemScratchpad;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.undo.CopyResourcesOperation;
-import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
-import org.eclipse.ui.progress.UIJob;
-
-
-/**
- * Runnable to perform actual transfer operation.
- *
- */
-public class SystemDNDTransferRunnable extends WorkspaceJob
-{
-
- public static final int SRC_TYPE_RSE_RESOURCE = 0;
- public static final int SRC_TYPE_ECLIPSE_RESOURCE = 1;
- public static final int SRC_TYPE_OS_RESOURCE = 2;
- public static final int SRC_TYPE_TEXT = 3;
- public static final int SRC_TYPE_UNKNOWN = 4;
-
- private List _srcObjects;
- private List _resultSrcObjects;
- private List _resultTgtObjects;
- private List _setList;
-
-
- private Object _currentTarget;
- private int _sourceType;
- private Viewer _originatingViewer;
- private boolean _ok;
- private Shell _shell;
-
- public SystemDNDTransferRunnable(Object target, ArrayList srcObjects, Viewer originatingViewer, int sourceType)
- {
- super(GenericMessages.TransferOperation_message);
- _srcObjects = srcObjects;
- _currentTarget = target;
- _sourceType = sourceType;
- _originatingViewer = originatingViewer;
- _resultSrcObjects = new ArrayList(_srcObjects.size());
- _resultTgtObjects = new ArrayList();
- _setList = new ArrayList();
- this.setUser(true);
- _shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- }
-
- protected SystemRemoteResourceSet getSetFor(ISubSystem subSystem, ISystemDragDropAdapter adapter)
- {
- for (int i = 0; i < _setList.size(); i++)
- {
- SystemRemoteResourceSet set = (SystemRemoteResourceSet)_setList.get(i);
- if (set.getAdapter() == adapter && set.getSubSystem() == subSystem)
- {
- return set;
- }
- }
-
- // no existing set - create one
- SystemRemoteResourceSet newSet = new SystemRemoteResourceSet(subSystem, adapter);
- _setList.add(newSet);
- return newSet;
- }
-
- protected boolean transferRSEResources(Object target, ISubSystem targetSubSystem, ISystemDragDropAdapter targetAdapter, IProgressMonitor monitor)
- {
-
-
- // transfer local artificts and categorize remote objects
- for (int i = 0; i < _srcObjects.size() && _ok; i++)
- {
- Object srcObject = _srcObjects.get(i);
- _resultSrcObjects.add(srcObject);
-
- if (srcObject instanceof SystemMessage)
- {
- operationFailed(monitor);
- showErrorMessage((SystemMessage) srcObject);
- return _ok;
- }
- else if (srcObject != null)
- {
- ISystemDragDropAdapter srcAdapter = (ISystemDragDropAdapter) ((IAdaptable) srcObject).getAdapter(ISystemDragDropAdapter.class);
-
- if (srcAdapter != null)
- {
- if (srcObject instanceof IHost)
- {
- Object tempObject = srcAdapter.doDrag(srcObject, false, monitor);
- if (targetAdapter.validateDrop(tempObject, target, false))
- {
- targetAdapter.doDrop(tempObject, target, false, false, _sourceType, monitor);
- _resultTgtObjects.add(tempObject);
- }
- }
- else
- {
- ISubSystem srcSubSystem = srcAdapter.getSubSystem(srcObject);
- if (srcSubSystem.isConnected() ||
- srcObject instanceof ISystemFilterReference ||
- srcObject instanceof ISubSystem)
- {
- SystemRemoteResourceSet set = getSetFor(srcSubSystem, srcAdapter);
- set.addResource(srcObject);
- }
- }
- }
- }
- }
-
- String targetPath = targetAdapter.getAbsoluteName(target);
- boolean sameSubSystemType = true;
- String targetType = ""; //$NON-NLS-1$
- if (targetSubSystem != null)
- {
- targetType = targetSubSystem.getName();
- }
-
- // now we have things divided into sets
- // transfer 1 set at a time
- for (int s = 0; s < _setList.size(); s++)
- {
- SystemRemoteResourceSet set = (SystemRemoteResourceSet)_setList.get(s);
-
-
-
-
- ISubSystem srcSubSystem = set.getSubSystem();
- ISystemDragDropAdapter srcAdapter = set.getAdapter();
-
- String srcType = srcSubSystem.getName();
- sameSubSystemType = targetType.equals(srcType);
-
- if (!sameSubSystemType && targetSubSystem != null)
- {
- ISystemResourceSet tempObjects = srcAdapter.doDrag(set, monitor);
-
- if (tempObjects == null)
- {
- // drag failed
- operationFailed(monitor);
- showInvalidTransferMessage(set, targetPath);
- }
- else if (tempObjects.hasMessage())
- {
- operationFailed(monitor);
- showErrorMessage(tempObjects.getMessage());
- }
- else
- {
- if (targetAdapter.validateDrop(tempObjects, target, (targetSubSystem == srcSubSystem)))
- {
- // special case for filters
- if (target instanceof ISystemFilterReference)
- {
- ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
- if (factory.supportsDropInFilters())
- {
- target = targetSubSystem.getTargetForFilter((ISystemFilterReference)target);
- targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
- }
- }
-
-
- ISystemResourceSet droppedObjects = targetAdapter.doDrop(tempObjects, target, sameSubSystemType, (targetSubSystem == srcSubSystem), _sourceType, monitor);
- if (droppedObjects == null)
- {
- operationFailed(monitor);
- }
- else if (droppedObjects.hasMessage())
- {
- //Even the droppedObject has message, it could still has
- //dropped results. (user cancels the operation, but some objects
- //has already been copied.
- //Need to make sure we refresh those copied object.
- List results = droppedObjects.getResourceSet();
- for (int d = 0; d < results.size(); d++)
- {
- _resultTgtObjects.add(results.get(d));
- }
- operationFailed(monitor);
- showErrorMessage(droppedObjects.getMessage());
- }
- else
- {
- List results = droppedObjects.getResourceSet();
- for (int d = 0; d < results.size(); d++)
- {
- _resultTgtObjects.add(results.get(d));
- }
- }
- }
- else
- {
- // invalid drop
- operationFailed(monitor);
- showInvalidTransferMessage(set, targetPath);
- }
- }
- }
- else
- {
- // special case for filters
- if (target instanceof ISystemFilterReference && targetSubSystem != null)
- {
- ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
- if (factory.supportsDropInFilters())
- {
- target = targetSubSystem.getTargetForFilter((ISystemFilterReference)target);
- if (target == null)
- {
- return false;
- }
- else
- {
- targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
- }
- }
- }
- if (targetAdapter.validateDrop(set, target, (targetSubSystem == srcSubSystem)))
- {
-
- ISystemResourceSet droppedObjects = targetAdapter.doDrop(set, target, sameSubSystemType, (targetSubSystem == srcSubSystem), _sourceType, monitor);
- if (droppedObjects == null)
- {
- operationFailed(monitor);
- }
- else if (droppedObjects.hasMessage())
- {
- operationFailed(monitor);
- showErrorMessage(droppedObjects.getMessage());
- }
- else
- {
- List results = droppedObjects.getResourceSet();
- for (int d = 0; d < results.size(); d++)
- {
- _resultTgtObjects.add(results.get(d));
- }
- }
- }
- else
- {
- // invalid drop
- operationFailed(monitor);
- showInvalidTransferMessage(set, targetPath);
- }
- }
- }
-
- return _ok;
- }
-
- protected boolean transferRSEResourcesToEclipseResource(IResource target, ISubSystem targetSubSystem, IProgressMonitor monitor)
- {
- boolean alwaysOverwrite = false;
-
- List resourcesToCopy = new ArrayList();
- IWorkspaceRoot root = target.getWorkspace().getRoot();
- for (int i = 0; i < _srcObjects.size() && _ok; i++)
- {
- Object srcObject = _srcObjects.get(i);
-
- _resultSrcObjects.add(srcObject);
-
- if (srcObject instanceof SystemMessage)
- {
- operationFailed(monitor);
- showErrorMessage((SystemMessage) srcObject);
- }
- else if (srcObject != null)
- {
- // find all the files to copy and check that they don't exist first
- ISystemDragDropAdapter srcAdapter = (ISystemDragDropAdapter) ((IAdaptable) srcObject).getAdapter(ISystemDragDropAdapter.class);
- Object tempFile = srcAdapter.doDrag(srcObject, true, monitor);
- if (tempFile instanceof IResource)
- {
- boolean canCopy = true;
- IResource res = (IResource)tempFile;
- try
- {
- IPath destPath = target.getFullPath();
- destPath = destPath.append(res.getName());
-
- IResource newResource = root.findMember(destPath);
-
- // check for existing files
- if (!alwaysOverwrite){
- if (newResource != null && newResource.exists()){
- int result = checkOverwrite(res, newResource);
- if (result != IDialogConstants.OK_ID){
- canCopy = false;
- if (result == IDialogConstants.CANCEL_ID){
- // cancel the whole operation
- monitor.setCanceled(true);
- return false;
- }
-
- _resultSrcObjects.remove(srcObject);
- }
- }
- }
-
- // add to the list of files to copy
- if (canCopy){
- resourcesToCopy.add(res);
- }
- }
- catch (Exception e)
- {
- operationFailed(monitor);
- SystemBasePlugin.logError(e.getMessage(), e);
- }
- }
- }
- }
-
- // now doing the actual copy
- if (!resourcesToCopy.isEmpty()) {
- IResource[] resources = (IResource[])resourcesToCopy.toArray(new IResource[resourcesToCopy.size()]);
- IPath destinationPath = target.getFullPath();
- CopyResourcesOperation op = new CopyResourcesOperation(resources, destinationPath,
- SystemResources.RESID_COPY_TITLE);
-
-
- IAdaptable adaptable = WorkspaceUndoUtil.getUIInfoAdapter(_shell);
- try {
- PlatformUI.getWorkbench().getOperationSupport()
- .getOperationHistory().execute(op, monitor,adaptable);
- } catch (ExecutionException e) {
- SystemMessage errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_OCCURRED);
- if (e.getCause() instanceof CoreException) {
- SystemBasePlugin.logError(e.getMessage(), e);
- errorMessage.makeSubstitution(e.getCause().getMessage());
- } else {
- SystemBasePlugin.logError(e.getMessage(), e);
- errorMessage.makeSubstitution(e.getMessage());
- }
-
- showErrorMessage(errorMessage);
- operationFailed(monitor);
- return false;
- }
- }
-
- return true;
- }
-
-
- private int checkOverwrite(final IResource source, final IResource destination) {
- final int[] result = new int[1]; // using array since you can't change a final int
-
- Runnable query = new Runnable() {
- public void run() {
- int resultId[] = {
- IDialogConstants.OK_ID,
- IDialogConstants.CANCEL_ID };
-
- String labels[] = new String[] {
- IDialogConstants.OK_LABEL,
- IDialogConstants.CANCEL_LABEL };
-
- String title = SystemResources.RESID_COLLISION_RENAME_TITLE;
- String correctedVerbiage = SystemResources.RESID_COLLISION_RENAME_VERBIAGE.replaceAll("&1" , "{0}"); //$NON-NLS-1$//$NON-NLS-2$
- String msg = NLS.bind(correctedVerbiage, destination.getFullPath().makeRelative());
-
- MessageDialog dialog = new MessageDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- title,
- null, msg, MessageDialog.QUESTION, labels, 0);
- dialog.open();
- if (dialog.getReturnCode() == SWT.DEFAULT) {
- // A window close returns SWT.DEFAULT - mapped to a cancel
- result[0] = IDialogConstants.CANCEL_ID;
- } else {
- result[0] = resultId[dialog.getReturnCode()];
- }
- }
- };
-
- PlatformUI.getWorkbench().getDisplay().syncExec(query);
- return result[0];
- }
-
- protected boolean transferNonRSEResources(Object target, ISubSystem targetSubSystem, ISystemDragDropAdapter targetAdapter, IProgressMonitor monitor)
- {
-
- for (int i = 0; i < _srcObjects.size() && _ok; i++)
- {
- Object srcObject = _srcObjects.get(i);
-
- _resultSrcObjects.add(srcObject);
-
- if (srcObject instanceof SystemMessage)
- {
- operationFailed(monitor);
- showErrorMessage((SystemMessage) srcObject);
- }
- else if (srcObject != null)
- {
-
-
- // special case for filters
- if (target instanceof ISystemFilterReference && targetSubSystem != null)
- {
-
- ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
- if (factory.supportsDropInFilters() && factory.providesCustomDropInFilters())
- {
- ((ISystemFilterReference)target).markStale(true);
-
- target = targetSubSystem.getTargetForFilter((ISystemFilterReference)target);
- targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
-
- }
- }
-
- if (_sourceType == SRC_TYPE_ECLIPSE_RESOURCE)
- {
- // Eclipse resource transfer
- IResource resource = null;
- if (srcObject instanceof IResource) {
- resource = (IResource) srcObject;
- } else if (srcObject instanceof IAdaptable) {
- resource = (IResource)((IAdaptable)srcObject).getAdapter(IResource.class);
- } else {
- resource = (IResource)Platform.getAdapterManager().getAdapter(srcObject, IResource.class);
- }
- if (resource!=null) {
- Object droppedObject = targetAdapter.doDrop(resource, target, false, false, _sourceType, monitor);
- if (droppedObject == null)
- operationFailed(monitor);
- else
- _resultTgtObjects.add(droppedObject);
- }
- }
- else if (_sourceType == SRC_TYPE_OS_RESOURCE)
- {
- if (srcObject instanceof String)
- {
- // non-Eclipse file transfer
- String file = (String) srcObject;
-
- Object droppedObject = targetAdapter.doDrop(file, target, false, false, _sourceType, monitor);
- if (droppedObject == null)
- operationFailed(monitor);
- else
- _resultTgtObjects.add(droppedObject);
- }
- }
- else if (_sourceType == SRC_TYPE_TEXT)
- {
- if (srcObject instanceof String)
- {
- String text = (String) srcObject;
- Object droppedObject = targetAdapter.doDrop(text, target, false, false, _sourceType, monitor);
- if (droppedObject == null)
- operationFailed(monitor);
- else
- _resultTgtObjects.add(droppedObject);
- }
- }
- else if (_sourceType == SRC_TYPE_RSE_RESOURCE)
- {
- ISystemDragDropAdapter srcAdapter = (ISystemDragDropAdapter) ((IAdaptable) srcObject).getAdapter(ISystemDragDropAdapter.class);
-
- if (srcAdapter != null)
- {
- if (srcObject instanceof IHost)
- {
- Object tempObject = srcAdapter.doDrag(srcObject, false, monitor);
- if (targetAdapter.validateDrop(tempObject, target, false))
- {
- targetAdapter.doDrop(tempObject, target, false, false, _sourceType, monitor);
- _resultTgtObjects.add(tempObject);
- }
- }
- else
- {
- ISubSystem srcSubSystem = srcAdapter.getSubSystem(srcObject);
-
- if (srcSubSystem.isConnected() ||
- srcObject instanceof ISystemFilterReference ||
- srcObject instanceof ISubSystem)
- {
- String srcType = srcSubSystem.getName();
- String srcPath = srcAdapter.getAbsoluteName(srcObject);
- String targetPath = targetAdapter.getAbsoluteName(target);
- boolean sameSubSystemType = true;
- if (targetSubSystem != null)
- {
- String targetType = targetSubSystem.getName();
- sameSubSystemType = targetType.equals(srcType);
- }
-
- if (!sameSubSystemType)
- {
- Object tempObject = srcAdapter.doDrag(srcObject, sameSubSystemType, monitor);
- if (tempObject == null)
- {
- // drag failed
- operationFailed(monitor);
- showInvalidTransferMessage(srcPath, targetPath);
- }
- else if (tempObject instanceof SystemMessage)
- {
- operationFailed(monitor);
- showErrorMessage((SystemMessage) tempObject);
- }
- else
- {
-
- if (targetAdapter.validateDrop(tempObject, target, (targetSubSystem == srcSubSystem)))
- {
- // special case for filters
- if (target instanceof ISystemFilterReference && targetSubSystem != null)
- {
- ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
- if (factory.supportsDropInFilters() && factory.providesCustomDropInFilters())
- {
- target = targetSubSystem.getTargetForFilter((ISystemFilterReference)target);
- targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
-
- }
- }
-
- Object droppedObject = targetAdapter.doDrop(tempObject, target, sameSubSystemType, (targetSubSystem == srcSubSystem), _sourceType, monitor);
- if (droppedObject == null)
- {
- operationFailed(monitor);
- }
- else if (droppedObject instanceof SystemMessage)
- {
- operationFailed(monitor);
- showErrorMessage((SystemMessage) droppedObject);
- }
- else
- _resultTgtObjects.add(droppedObject);
- }
- else
- {
- // invalid drop
- operationFailed(monitor);
- showInvalidTransferMessage(srcPath, targetPath);
- }
- }
- }
- else if (srcObject != target && !srcPath.equals(targetPath))
- {
- // special case for filters
-
- if (target instanceof ISystemFilterReference && targetSubSystem != null)
- {
- ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
- if (factory.supportsDropInFilters() && factory.providesCustomDropInFilters())
- {
- target = targetSubSystem.getTargetForFilter((ISystemFilterReference)target);
- targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
-
- }
- }
- if (targetAdapter.validateDrop(srcObject, target, (targetSubSystem == srcSubSystem)))
- {
-
- Object droppedObject = targetAdapter.doDrop(srcObject, target, sameSubSystemType, (targetSubSystem == srcSubSystem), _sourceType, monitor);
- if (droppedObject == null)
- {
- operationFailed(monitor);
- }
- else if (droppedObject instanceof SystemMessage)
- {
- operationFailed(monitor);
- showErrorMessage((SystemMessage) droppedObject);
- }
- else
- _resultTgtObjects.add(droppedObject);
- }
- else
- {
- // invalid drop
- operationFailed(monitor);
- showInvalidTransferMessage(srcPath, targetPath);
- }
- }
- else
- {
- // can't drop src onto itself
- // invalid drop
- operationFailed(monitor);
- showInvalidTransferMessage(srcPath, targetPath);
- }
- }
- }
- }
- }
- }
- if (monitor != null && monitor.isCanceled())
- {
- _ok = false;
- return _ok;
- }
- }
-
-
- return true;
- }
-
- public IStatus runInWorkspace(IProgressMonitor monitor)
- {
-
- _ok = true;
-
- Object target = _currentTarget;
- ISubSystem targetSubSystem = null;
- //boolean expandFolder = false;
-
-
- if (target instanceof IAdaptable)
- {
- ISystemDragDropAdapter targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
-
- // checking for IResource since we already handle them specially
- if (targetAdapter != null && !(target instanceof IResource))
- {
- targetSubSystem = targetAdapter.getSubSystem(target);
-
- if (targetSubSystem != null && !targetSubSystem.isConnected())
- {
- try
- {
- targetSubSystem.connect(monitor, false);
- }
- catch (Exception e)
- {
- }
- }
-
- SystemMessage copyMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COPYGENERIC_PROGRESS);
- if (monitor != null)
- monitor.beginTask(copyMessage.getLevelOneText(), IProgressMonitor.UNKNOWN);
-
- if (_sourceType == SRC_TYPE_RSE_RESOURCE)
- {
- transferRSEResources(target, targetSubSystem, targetAdapter, monitor);
- }
- else
- {
- transferNonRSEResources(target, targetSubSystem, targetAdapter, monitor);
- }
- }
- else if (target instanceof IResource)
- {
- transferRSEResourcesToEclipseResource((IResource)target, targetSubSystem, monitor);
- }
- }
-
- // fire refresh for target
- if (_ok && monitor != null) // I added this test: phil
- {
- monitor.done();
- }
-
-
- if (target != null && target instanceof ISystemContainer)
- {
- ((ISystemContainer)target).markStale(true);
- }
-
- RefreshJob refresh = new RefreshJob(target, targetSubSystem);
- refresh.schedule();
- return Status.OK_STATUS;
- }
-
- public class RefreshJob extends UIJob
- {
- private Object _target;
- private ISubSystem _targetSubSystem;
- public RefreshJob(Object target, ISubSystem targetSubSystem)
- {
- super("Refresh"); //$NON-NLS-1$
- _target = target;
- _targetSubSystem = targetSubSystem;
- }
-
- public IStatus runInUIThread(IProgressMonitor monitor)
- {
- String[] oldNames = new String[_resultSrcObjects.size()];
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- if (_resultTgtObjects.size() > 0)
- {
- boolean doRefresh = _ok;
-
- for (int t = 0; t < _resultTgtObjects.size() && t < _resultSrcObjects.size(); t++)
- {
- Object tgt = _resultTgtObjects.get(t);
- Object src = _resultSrcObjects.get(t);
- if (tgt == src || tgt == null)
- {
- doRefresh = false;
- }
- else
- {
- doRefresh = true;
- }
- ISystemDragDropAdapter adapter = null;
- if (src instanceof IAdaptable) {
- adapter = (ISystemDragDropAdapter)((IAdaptable)src).getAdapter(ISystemDragDropAdapter.class);
- }
- else {
- adapter = (ISystemDragDropAdapter)Platform.getAdapterManager().getAdapter(src, ISystemDragDropAdapter.class);
- }
-
- if (adapter != null){
- oldNames[t] = adapter.getAbsoluteName(src);
- }
- else if (src instanceof IResource){ // could be an eclipse resource
- oldNames[t] = ((IResource)src).getFullPath().toOSString();
- }
- else if (src instanceof String){ // local os resource
- oldNames[t] = (String)src;
- }
- else {
- oldNames[t] = ""; // source resource unknown //$NON-NLS-1$
- }
- }
-
- if (_originatingViewer instanceof TreeViewer)
- {
- try
- {
- TreeViewer viewer = (TreeViewer) _originatingViewer;
- viewer.setExpandedState(_target, true);
- }
- catch (Exception e)
- {
-
- }
- }
-
- if (doRefresh)
- {
- String operation = ISystemRemoteChangeEvents.SYSTEM_REMOTE_OPERATION_COPY;
- registry.fireRemoteResourceChangeEvent(operation, ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, _resultTgtObjects, _target, _targetSubSystem, oldNames, _originatingViewer);
- }
- else if (_target instanceof SystemScratchpad)
- {
- registry.fireEvent(new SystemResourceChangeEvent(_resultTgtObjects, ISystemResourceChangeEvents.EVENT_ADD_MANY, _target));
- }
- }
-
- return Status.OK_STATUS;
- }
- }
-
- private void operationFailed(IProgressMonitor monitor)
- {
-
- _ok = false;
- if (monitor != null)
- monitor.done();
- }
-
- private void showInvalidTransferMessage(String srcPath, String targetPath)
- {
- SystemMessage errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_TRANSFER_INVALID);
- errorMessage.makeSubstitution(srcPath, targetPath);
- showErrorMessage(errorMessage);
- }
-
- private void showInvalidTransferMessage(ISystemResourceSet resourceSet, String targetPath)
- {
- SystemMessage errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_TRANSFER_INVALID);
- errorMessage.makeSubstitution(resourceSet.toString(), targetPath);
- showErrorMessage(errorMessage);
- }
-
- private void showErrorMessage(SystemMessage errorMessage)
- {
- Display.getDefault().asyncExec(new ShowErrorRunnable(errorMessage));
- }
-
- public class ShowErrorRunnable implements Runnable
- {
- SystemMessage _errorMessage;
- public ShowErrorRunnable(SystemMessage errorMessage)
- {
- _errorMessage = errorMessage;
- }
-
- public void run()
- {
- Shell shell = SystemBasePlugin.getActiveWorkbenchShell();
- SystemMessageDialog dlg = new SystemMessageDialog(shell, _errorMessage);
- dlg.open();
- }
-
- }
-
- public boolean dropOkay()
- {
- return _ok;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDecoratingLabelProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDecoratingLabelProvider.java
deleted file mode 100644
index 9d9eda810..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDecoratingLabelProvider.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @author mjberger
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class SystemDecoratingLabelProvider extends DecoratingLabelProvider implements ITableLabelProvider
-{
- private ITableLabelProvider _tableLabelProvider;
-
- public SystemDecoratingLabelProvider(ITableLabelProvider provider, ILabelDecorator decorator) {
- super((ILabelProvider)provider, decorator);
- // TODO Auto-generated constructor stub
- _tableLabelProvider = provider;
- }
-
-
- public Image getColumnImage(Object element, int columnIndex)
- {
- if (columnIndex == 0) //TODO: Make this more generic
- {
- return getImage(element);
- }
- return _tableLabelProvider.getColumnImage(element, columnIndex);
- }
-
- public String getColumnText(Object element, int columnIndex)
- {
- if (columnIndex == 0) //TODO: Make this more generic
- {
- return getText(element);
- }
- return _tableLabelProvider.getColumnText(element, columnIndex);
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDeferredTableTreeContentManager.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDeferredTableTreeContentManager.java
deleted file mode 100644
index cdb4cc0be..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDeferredTableTreeContentManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed the initial implementation:
- * David McKnight.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.rse.ui.operations.SystemDeferredTreeContentManager;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-public class SystemDeferredTableTreeContentManager extends
- SystemDeferredTreeContentManager {
-
- private SystemTableTreeViewProvider _provider;
- private SystemTableTreeView _view;
- public SystemDeferredTableTreeContentManager(SystemTableTreeViewProvider provider, SystemTableTreeView viewer) {
- super(provider, viewer);
- _provider = provider;
- _view = viewer;
- }
-
-
- protected void addChildren(Object parent, Object[] children, IProgressMonitor monitor) {
- super.addChildren(parent, children, monitor);
-
- _provider.setCachedObjects(parent, children);
- IPropertyDescriptor[] descriptors = _view.getUniqueDescriptors();
- if (descriptors == null)
- {
- Display.getDefault().asyncExec(new RelayoutView(parent));
- }
- }
-
- /**
- * Return the IDeferredWorkbenchAdapter for element or the element if it is
- * an instance of IDeferredWorkbenchAdapter. If it does not exist return
- * null.
- *
- * @param element
- * @return IDeferredWorkbenchAdapter or <code>null</code>
- */
- protected IDeferredWorkbenchAdapter getAdapter(Object element)
- {
-
- if (element instanceof IContextObject)
- {
- element = ((IContextObject)element).getModelObject();
- }
- return super.getAdapter(element);
- }
-
-
- public class RelayoutView implements Runnable
- {
- public RelayoutView(Object parent)
- {
- }
-
- public void run()
- {
- _view.computeLayout();
- _view.refresh(true);
- //SystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- //registry.fireEvent(new SystemResourceChangeEvent(_parent, ISystemResourceChangeEvents.EVENT_PROPERTYSHEET_UPDATE, _parent));
- }
- }
-
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDropActionDelegate.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDropActionDelegate.java
deleted file mode 100644
index c0a3b2ca0..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDropActionDelegate.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.part.IDropActionDelegate;
-
-
-
-/**
- * This class is used for dropping RSE src objects on known non-RSE targets
- *
- */
-public class SystemDropActionDelegate implements IDropActionDelegate
-{
-
- public static final String ID = "org.eclipse.rse.ui.view.DropActions"; //ID fixed, by Phil //$NON-NLS-1$
-
-
- /** (non-Javadoc)
- * Method declared on IDropActionDelegate
- */
- public boolean run(Object data, Object target)
- {
- String localPath = null;
- IResource resource = null;
-
- if (target instanceof IProjectNature)
- {
- target = ((IProjectNature)target).getProject();
- }
-
- if (target instanceof IResource)
- {
- resource = (IResource) target;
- localPath = resource.getLocation().toOSString();
- }
- else if (target instanceof String)
- {
- localPath = (String)target;
- }
- else if (target instanceof IAdaptable)
- {
- target = ((IAdaptable)target).getAdapter(IResource.class);
- if (target != null && target instanceof IResource)
- {
- resource = (IResource)target;
- localPath = resource.getLocation().toOSString();
- }
- }
-
-
- if (localPath != null)
- {
-
- if (data instanceof byte[])
- {
- byte[] result = (byte[]) data;
-
- // get the sources
- //StringTokenizer tokenizer = new StringTokenizer(new String(result), SystemViewDataDropAdapter.RESOURCE_SEPARATOR);
- String[] tokens = (new String(result)).split("\\"+SystemViewDataDropAdapter.RESOURCE_SEPARATOR); //$NON-NLS-1$
- ArrayList srcObjects = new ArrayList();
-
- //while (tokenizer.hasMoreTokens())
- for (int i = 0; i <tokens.length; i++)
- {
- String srcStr = tokens[i];
-
- Object srcObject = getObjectFor(srcStr);
- srcObjects.add(srcObject);
- }
-
- SystemDNDTransferRunnable runnable = new SystemDNDTransferRunnable(target, srcObjects, null, SystemDNDTransferRunnable.SRC_TYPE_RSE_RESOURCE);
-
- runnable.schedule();
-
- if (resource != null)
- {
- try
- {
- resource.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- catch (CoreException e)
- {
- }
- }
- RSEUIPlugin.getTheSystemRegistryUI().clearRunnableContext();
- }
-
- /** FIXME - IREmoteFile is systems.core independent now
- IRemoteFileSubSystem localFS = getLocalFileSubSystem();
- try
- {
- IRemoteFile rsfTarget = localFS.getRemoteFileObject(localPath);
-
- if (data instanceof byte[])
- {
- byte[] result = (byte[]) data;
-
- // get the sources
- //StringTokenizer tokenizer = new StringTokenizer(new String(result), SystemViewDataDropAdapter.RESOURCE_SEPARATOR);
- String[] tokens = (new String(result)).split("\\"+SystemViewDataDropAdapter.RESOURCE_SEPARATOR);
- ArrayList srcObjects = new ArrayList();
- ArrayList rulesList = new ArrayList();
- int j = 0;
- //while (tokenizer.hasMoreTokens())
- for (int i = 0; i <tokens.length; i++)
- {
- String srcStr = tokens[i];
-
- Object srcObject = getObjectFor(srcStr);
- srcObjects.add(srcObject);
- if (srcObject instanceof ISchedulingRule)
- {
- rulesList.add(srcObject);
- j++;
- }
- else if (srcObject instanceof IRemoteFile)
- {
- rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)srcObject));
- j++;
- }
- }
- if (resource != null)
- {
- rulesList.add(resource);
- j++;
- }
-
- ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
- MultiRule rule = null;
- if (j > 0)
- {
- rule = new MultiRule(rules);
- }
-
- Viewer currentViewer = null; // todo: figure out how to determine the current viewer! Phil
- SystemDNDTransferRunnable runnable = new SystemDNDTransferRunnable(rsfTarget, srcObjects, currentViewer, SystemDNDTransferRunnable.SRC_TYPE_RSE_RESOURCE);
-
- runnable.setRule(rule);
-
- runnable.schedule();
-
- if (resource != null)
- {
- try
- {
- resource.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- catch (CoreException e)
- {
- }
- }
- RSEUIPlugin.getTheSystemRegistryUI().clearRunnableContext();
- }
- }
- catch (SystemMessageException e)
- {
- }
- **/
- return true;
- }
-
- return false;
- }
- /**
- * Method for decoding an source object ID to the actual source object.
- * We determine the profile, connection and subsystem, and then
- * we use the SubSystem.getObjectWithKey() method to get at the
- * object.
- *
- */
- private Object getObjectFor(String str)
- {
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- // first extract subsystem id
- int connectionDelim = str.indexOf(":"); //$NON-NLS-1$
- if (connectionDelim == -1) // not subsystem, therefore likely to be a connection
- {
- int profileDelim = str.indexOf("."); //$NON-NLS-1$
- if (profileDelim != -1)
- {
- String profileId = str.substring(0, profileDelim);
- String connectionId = str.substring(profileDelim + 1, str.length());
- ISystemProfile profile = registry.getSystemProfile(profileId);
- return registry.getHost(profile, connectionId);
- }
- }
-
-
- int subsystemDelim = str.indexOf(":", connectionDelim + 1); //$NON-NLS-1$
- if (subsystemDelim == -1) // not remote object, therefore likely to be a subsystem
- {
- return registry.getSubSystem(str);
- }
- else
- {
- String subSystemId = str.substring(0, subsystemDelim);
- String srcKey = str.substring(subsystemDelim + 1, str.length());
-
-
- ISubSystem subSystem = registry.getSubSystem(subSystemId);
- if (subSystem != null)
- {
- Object result = null;
- try
- {
- result = subSystem.getObjectWithAbsoluteName(srcKey);
- }
- catch (SystemMessageException e)
- {
- return e.getSystemMessage();
- }
- catch (Exception e)
- {
- }
- if (result != null)
- {
- return result;
- }
- else
- {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_FILE_NOTFOUND);
- msg.makeSubstitution(srcKey, subSystem.getHostAliasName());
- return msg;
- }
- }
- else
- {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_CONNECTION_NOTFOUND);
- msg.makeSubstitution(subSystemId);
- return msg;
- }
- }
- }
-
- protected IRunnableContext getRunnableContext(Shell shell)
- {
- IRunnableContext irc = RSEUIPlugin.getTheSystemRegistryUI().getRunnableContext();
- if (irc != null)
- {
- return irc;
- }
-
- irc = new ProgressMonitorDialog(shell);
- RSEUIPlugin.getTheSystemRegistryUI().setRunnableContext(shell, irc);
- return irc;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemEmptyListAPIProviderImpl.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemEmptyListAPIProviderImpl.java
deleted file mode 100644
index 076c5ad93..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemEmptyListAPIProviderImpl.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- * David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * It is a special-case provider when we want the list to be empty.
- */
-public class SystemEmptyListAPIProviderImpl
- extends SystemAbstractAPIProvider
-{
-
-
- /**
- * Constructor
- */
- public SystemEmptyListAPIProviderImpl()
- {
- super();
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
- /**
- * Return the children objects to consistute the root elements in the system view tree.
- * <p>We return an empty list.
- */
- public Object[] getSystemViewRoots()
- {
- return emptyList;
- }
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- * We return false.
- */
- public boolean hasSystemViewRoots()
- {
- return false;
- }
- /**
- * This method is called by the connection adapter when the user expands
- * a connection. This method must return the child objects to show for that
- * connection.
- * <p>We return an empty list
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- return emptyList; //
- }
- /**
- * This method is called by the connection adapter when deciding to show a plus-sign
- * or not beside a connection. Return true if this connection has children to be shown.
- * <p>we return false
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- return false;
- }
-
-
- // ----------------------------------
- // OUR OWN METHODS...
- // ----------------------------------
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritablePropertyData.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritablePropertyData.java
deleted file mode 100644
index 2453553da..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritablePropertyData.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.rse.internal.ui.SystemPropertyResources;
-/**
- * This class captures the data needed to populate a
- * InheritableTextCellEditor.
- */
-public class SystemInheritablePropertyData
-{
- private String localValue=""; //$NON-NLS-1$
- private String inheritedValue=""; //$NON-NLS-1$
- private boolean isLocal;
- private boolean notApplicable = false;
-
- private String inheritedXlatedString;
-
- public SystemInheritablePropertyData()
- {
- super();
- setInheritedDisplayString(SystemPropertyResources.RESID_PROPERTY_INHERITED);
- }
-
- /**
- * Identify this value as "not applicable". This causes
- * this string to be displayed, and prevents users from editing this property.
- */
- public void setNotApplicable(boolean set)
- {
- notApplicable = set;
- }
- /**
- * Get the notApplicable flag. Default is false.
- */
- public boolean getNotApplicable()
- {
- return notApplicable;
- }
-
- /**
- * Gets the localValue
- * @return Returns a String
- */
- public String getLocalValue()
- {
- return localValue;
- }
- /**
- * Sets the localValue
- * @param localValue The localValue to set
- */
- public void setLocalValue(String localValue)
- {
- if (localValue == null)
- localValue = ""; // to prevent equals() from crashing //$NON-NLS-1$
- this.localValue = localValue;
- }
-
- /**
- * Gets the inheritedValue
- * @return Returns a String
- */
- public String getInheritedValue()
- {
- return inheritedValue;
- }
- /**
- * Sets the inheritedValue
- * @param inheritedValue The inheritedValue to set
- */
- public void setInheritedValue(String inheritedValue)
- {
- if (inheritedValue == null)
- inheritedValue = ""; // to prevent equals() from crashing //$NON-NLS-1$
- this.inheritedValue = inheritedValue;
- }
-
-
- /**
- * Gets the isLocal
- * @return Returns a boolean
- */
- public boolean getIsLocal()
- {
- return isLocal;
- }
- /**
- * Sets the isLocal
- * @param isLocal The isLocal to set
- */
- public void setIsLocal(boolean isLocal)
- {
- this.isLocal = isLocal;
- }
-
- /**
- * Set the string to append to the inherited value in display-only mode
- */
- public void setInheritedDisplayString(String s)
- {
- inheritedXlatedString = s;
- }
-
- /**
- * Convert to string for readonly-property sheet value
- */
- public String toString()
- {
- if (notApplicable)
- return SystemPropertyResources.RESID_TERM_NOTAPPLICABLE;
- String value = null;
- if (isLocal)
- value = localValue;
- else
- //value = " (*INHERITED)";
- value = inheritedValue + " " + inheritedXlatedString; //$NON-NLS-1$
- return value;
- }
-
- /**
- * The property sheet viewer will decide to call the adapter back when Enter is pressed,
- * only if the result of calling equals() on the previous and current versions of this
- * object returns false. If we did not have this method, they'd always return true.
- */
- public boolean equals(Object other)
- {
- if (other instanceof SystemInheritablePropertyData)
- {
- SystemInheritablePropertyData otherData = (SystemInheritablePropertyData)other;
- boolean equal =
- ((isLocal == otherData.getIsLocal()) &&
- (localValue.equals(otherData.getLocalValue())) &&
- (inheritedValue.equals(otherData.getInheritedValue())) );
- /*
- System.out.println("inside equals. Result? " + equal + " Local value: " + localValue);
- if (!equal)
- {
- System.out.println("... isLocal.......: " + isLocal + " vs " + otherData.getIsLocal());
- System.out.println("... localValue....: '" + localValue + "' vs '" + otherData.getLocalValue() + "'");
- System.out.println("... inheritedValue: '" + inheritedValue + "' vs " + otherData.getInheritedValue() + "'");
- }
- */
- return equal;
- }
- else
- return super.equals(other);
- }
-
- /**
- * For debugging
- */
- public void printDetails()
- {
- System.out.println("SystemInheritablePropertyData: "); //$NON-NLS-1$
- System.out.println("...localValue = "+localValue); //$NON-NLS-1$
- System.out.println("...inheritedValue = "+inheritedValue); //$NON-NLS-1$
- System.out.println("...isLocal = "+isLocal); //$NON-NLS-1$
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritableTextCellEditor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritableTextCellEditor.java
deleted file mode 100644
index e02669709..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritableTextCellEditor.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.rse.ui.widgets.InheritableEntryField;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-
-
-/**
- * A cell editor that manages an inheritable text entry field.
- * The cell editor's value is the text string itself.
- */
-public class SystemInheritableTextCellEditor
- //extends DialogCellEditor
- extends CellEditor
- implements SelectionListener
-{
- protected InheritableEntryField textField;
- protected Text text;
- protected SystemInheritablePropertyData data;
- private String toggleButtonToolTipText, entryFieldToolTipText;
-
- private ModifyListener modifyListener;
-
- /**
- * State information for updating action enablement
- */
- private boolean isSelection = false;
- private boolean isDeleteable = false;
- private boolean isSelectable = false;
-
- /**
- * Creates a new text string cell editor parented under the given control.
- * The cell editor value is the string itself, which is initially the empty string.
- * Initially, the cell editor has no cell validator.
- *
- * @param parent the parent control
- */
- public SystemInheritableTextCellEditor(Composite parent)
- {
- super(parent);
- }
- /**
- * Checks to see if the "deleteable" state (can delete/
- * nothing to delete) has changed and if so fire an
- * enablement changed notification.
- */
- private void checkDeleteable()
- {
- boolean oldIsDeleteable = isDeleteable;
- isDeleteable = isDeleteEnabled();
- if (oldIsDeleteable != isDeleteable)
- {
- fireEnablementChanged(DELETE);
- }
- }
-
-
- /**
- * Checks to see if the "selectable" state (can select)
- * has changed and if so fire an enablement changed notification.
- */
- private void checkSelectable()
- {
- boolean oldIsSelectable = isSelectable;
- isSelectable = isSelectAllEnabled();
- if (oldIsSelectable != isSelectable)
- {
- fireEnablementChanged(SELECT_ALL);
- }
- }
- /**
- * Checks to see if the selection state (selection /
- * no selection) has changed and if so fire an
- * enablement changed notification.
- */
- private void checkSelection()
- {
- boolean oldIsSelection = isSelection;
- isSelection = getTextField().getSelectionCount() > 0;
- if (oldIsSelection != isSelection)
- {
- fireEnablementChanged(COPY);
- fireEnablementChanged(CUT);
- }
- }
- /**
- * Return the entry field of the composite control
- */
- private Text getTextField()
- {
- return textField.getTextField();
- }
-
- public InheritableEntryField getInheritableEntryField()
- {
- return textField;
- }
-
- /**
- * Gets the toggleButtonToolTipText
- * @return Returns a String
- */
- public String getToggleButtonToolTipText()
- {
- return toggleButtonToolTipText;
- }
- /**
- * Sets the toggleButtonToolTipText
- * @param toggleButtonToolTipText The toggleButtonToolTipText to set
- */
- public void setToggleButtonToolTipText(String toggleButtonToolTipText)
- {
- this.toggleButtonToolTipText = toggleButtonToolTipText;
- if (textField != null)
- textField.setToggleToolTipText(toggleButtonToolTipText);
- }
-
- /**
- * Gets the entryFieldToolTipText
- * @return Returns a String
- */
- public String getEntryFieldToolTipText()
- {
- return entryFieldToolTipText;
- }
- /**
- * Sets the entryFieldToolTipText
- * @param entryFieldToolTipText The entryFieldToolTipText to set
- */
- public void setEntryFieldToolTipText(String entryFieldToolTipText)
- {
- this.entryFieldToolTipText = entryFieldToolTipText;
- if (textField != null)
- textField.setTextFieldToolTipText(entryFieldToolTipText);
- }
-
- /* (non-Javadoc)
- * Method declared on CellEditor.
- */
- protected Control createControl(Composite parent)
- {
- // specify no borders on text widget as cell outline in
- // table already provides the look of a border.
- textField = new InheritableEntryField(parent, SWT.NULL, SWT.BORDER, SWT.SINGLE);
- textField.setToggleButtonHeight(14);
- textField.setBackground(parent.getBackground());
- textField.addSelectionListener(this);
- if (toggleButtonToolTipText != null)
- textField.setToggleToolTipText(toggleButtonToolTipText);
- if (entryFieldToolTipText != null)
- textField.setTextFieldToolTipText(entryFieldToolTipText);
- text = getTextField();
- text.addKeyListener(new KeyAdapter()
- {
- public void keyPressed(KeyEvent e)
- {
- // The call to inherited keyReleaseOccurred is what causes the apply
- // event if the key pressed is Enter.
- keyReleaseOccured(e);
- // as a result of processing the above call, clients may have
- // disposed this cell editor
- if ((getControl() == null) || getControl().isDisposed())
- return;
- checkSelection(); // see explaination below
- checkDeleteable();
- checkSelectable();
- }
- });
- text.addTraverseListener(new TraverseListener()
- {
- public void keyTraversed(TraverseEvent e)
- {
- if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN)
- {
- e.doit = false;
- }
- }
- });
- // We really want a selection listener but it is not supported so we
- // use a key listener and a mouse listener to know when selection changes
- // may have occured
- text.addMouseListener(new MouseAdapter()
- {
- public void mouseUp(MouseEvent e) {
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- });
- text.addFocusListener(new FocusAdapter() {
- public void focusGained(FocusEvent e) {
- }
-
- public void focusLost(FocusEvent e) {
- SystemInheritableTextCellEditor.this.focusLost();
- }
- });
- textField.getToggleButton().addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent e) {
- SystemInheritableTextCellEditor.this.focusLost();
- }
-
- public void focusGained(FocusEvent e) {
- }
- });
-
- text.setFont(parent.getFont());
- //text.setBackground(parent.getBackground());
- text.setText("");//$NON-NLS-1$
- text.addModifyListener(getModifyListener());
- setValueValid(true);
- return textField;
- }
-
- protected void focusLost()
- {
- super.focusLost();
- }
-
- /**
- * Return current data.
- *
- * @return the SystemInheritablePropertyData data object
- */
- protected Object doGetValue()
- {
- SystemInheritablePropertyData outputData = new SystemInheritablePropertyData();
- outputData.setIsLocal(textField.isLocal());
- outputData.setLocalValue(textField.getLocalText());
- outputData.setInheritedValue(textField.getInheritedText());
- return outputData;
- }
-
-
- /* (non-Javadoc)
- * Method declared on CellEditor.
- */
- protected void doSetFocus()
- {
- if (text != null)
- {
- if (text.isEnabled())
- {
- text.selectAll();
- text.setFocus();
- }
- else
- {
- textField.setToggleButtonFocus();
- }
-
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- }
- /**
- * The <code>TextCellEditor</code> implementation of
- * this <code>CellEditor</code> framework method accepts
- * a SystemInheritablePropertyData data object.
- *
- * @param value a SystemInheritablePropertyData object
- */
- protected void doSetValue(Object value)
- {
- Assert.isTrue(text != null && (value instanceof SystemInheritablePropertyData));
- textField.removeModifyListener(getModifyListener());
- data = (SystemInheritablePropertyData)value;
- textField.setLocalText(data.getLocalValue());
- textField.setInheritedText(data.getInheritedValue());
- textField.setLocal(data.getIsLocal());
- textField.addModifyListener(getModifyListener());
- }
- /**
- * Processes a modify event that occurred in this text cell editor.
- * This framework method performs validation and sets the error message
- * accordingly, and then reports a change via <code>fireEditorValueChanged</code>.
- * Subclasses should call this method at appropriate times. Subclasses
- * may extend or reimplement.
- *
- * @param e the SWT modify event
- */
- protected void editOccured(ModifyEvent e)
- {
- String value = text.getText();
- if (value == null)
- value = ""; //$NON-NLS-1$
- Object typedValue = value;
- boolean oldValidState = isValueValid();
- boolean newValidState = isCorrect(typedValue);
- if (!newValidState)
- {
- // try to insert the current value into the error message.
- setErrorMessage(NLS.bind(getErrorMessage(), value));
- }
- valueChanged(oldValidState, newValidState);
- }
- /**
- * Since a text editor field is scrollable we don't
- * set a minimumSize.
- */
- public LayoutData getLayoutData()
- {
- return new LayoutData();
- }
- /**
- * Return the modify listener.
- */
- private ModifyListener getModifyListener()
- {
- if (modifyListener == null)
- {
- modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e)
- {
- editOccured(e);
- }
- };
- }
- return modifyListener;
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method returns <code>true</code> if
- * the current selection is not empty.
- */
- public boolean isCopyEnabled()
- {
- if (text == null || text.isDisposed() || !text.isEnabled())
- return false;
- return text.getSelectionCount() > 0;
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method returns <code>true</code> if
- * the current selection is not empty.
- */
- public boolean isCutEnabled()
- {
- if (text == null || text.isDisposed() || !text.isEnabled())
- return false;
- return text.getSelectionCount() > 0;
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method returns <code>true</code>
- * if there is a selection or if the caret is not positioned
- * at the end of the text.
- */
- public boolean isDeleteEnabled()
- {
- if (text == null || text.isDisposed() || !text.isEnabled())
- return false;
- return text.getSelectionCount() > 0 || text.getCaretPosition() < text.getCharCount();
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method always returns <code>true</code>.
- */
- public boolean isPasteEnabled()
- {
- if (text == null || text.isDisposed() || !text.isEnabled())
- return false;
- return true;
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method always returns <code>true</code>.
- */
- public boolean isSaveAllEnabled()
- {
- if (text == null || text.isDisposed() || !text.isEnabled())
- return false;
- return true;
- }
- /**
- * Returns <code>true</code> if this cell editor is
- * able to perform the select all action.
- * <p>
- * This default implementation always returns
- * <code>false</code>.
- * </p>
- * <p>
- * Subclasses may override
- * </p>
- * @return <code>true</code> if select all is possible,
- * <code>false</code> otherwise
- */
- public boolean isSelectAllEnabled()
- {
- if (text == null || text.isDisposed() || !text.isEnabled())
- return false;
- return text.getText().length() > 0;
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method copies the
- * current selection to the clipboard.
- */
- public void performCopy()
- {
- text.copy();
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method cuts the
- * current selection to the clipboard.
- */
- public void performCut()
- {
- text.cut();
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method deletes the
- * current selection or, if there is no selection,
- * the character next character from the current position.
- */
- public void performDelete()
- {
- if (text.getSelectionCount() > 0)
- // remove the contents of the current selection
- text.insert(""); //$NON-NLS-1$
- else
- {
- // remove the next character
- int pos = text.getCaretPosition();
- if (pos < text.getCharCount())
- {
- text.setSelection(pos, pos + 1);
- text.insert(""); //$NON-NLS-1$
- }
- }
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method pastes the
- * the clipboard contents over the current selection.
- */
- public void performPaste()
- {
- text.paste();
- checkSelection();
- checkDeleteable();
- checkSelectable();
- }
- /**
- * The <code>TextCellEditor</code> implementation of this
- * <code>CellEditor</code> method selects all of the
- * current text.
- */
- public void performSelectAll()
- {
- text.selectAll();
- checkSelection();
- checkDeleteable();
- }
-
- // Selection Listener methods for InheritableTextCellEditor toggle switches
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
- public void widgetSelected(SelectionEvent e)
- {
- //System.out.println("Got widget selected event. isLocal() = " + textField.isLocal()+", text='"+textField.getText()+"'");
- boolean isLocal = textField.isLocal();
- String value = text.getText();
- data.setIsLocal(isLocal);
- boolean oldValidState = isValueValid();
- boolean newValidState = isLocal?isCorrect(value):true; //isCorrect(typedValue);
- if (!newValidState)
- {
- // try to insert the current value into the error message.
- setErrorMessage(NLS.bind(getErrorMessage(), value));
- }
- valueChanged(oldValidState, newValidState);
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritableTextPropertyDescriptor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritableTextPropertyDescriptor.java
deleted file mode 100644
index 55ef23897..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemInheritableTextPropertyDescriptor.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-/**
- * A variation of the Eclipse-supplied TextPropertyDescriptor for
- * displaying text string properties that are inheritable.
- */
-public class SystemInheritableTextPropertyDescriptor
- extends PropertyDescriptor
-{
- private SystemInheritableTextCellEditor editor;
- private String toggleButtonToolTipText, entryFieldToolTipText;
- private boolean editable = true;
-
- /**
- * Creates a property descriptor with the given id, display name
- *
- * @param id the id of the property
- * @param displayName the name to display for the property
- */
- public SystemInheritableTextPropertyDescriptor(Object id, String displayName)
- {
- super(id, displayName);
- }
- /**
- * Call this with false in special circumstances to user's disable ability to edit this value.
- * Default is true
- * @see #getEditable()
- */
- public void setEditable(boolean allow)
- {
- editable = allow;
- }
- /**
- * Query the allow-editing value. Default is true.
- */
- public boolean getEditable()
- {
- return editable;
- }
-
- /**
- * Return an instance of SystemInheritableTextCellEditor, unless
- * our editable property is false, in which case we return null;
- */
- public CellEditor createPropertyEditor(Composite parent)
- {
- if (!editable)
- return null;
- editor = new SystemInheritableTextCellEditor(parent);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- if (toggleButtonToolTipText != null)
- editor.setToggleButtonToolTipText(toggleButtonToolTipText);
- if (entryFieldToolTipText != null)
- editor.setEntryFieldToolTipText(entryFieldToolTipText);
- return editor;
- }
-
-
- /**
- * Gets the toggleButtonToolTipText
- * @return Returns a String
- */
- public String getToggleButtonToolTipText()
- {
- return toggleButtonToolTipText;
- }
- /**
- * Sets the toggleButtonToolTipText
- * @param toggleButtonToolTipText The toggleButtonToolTipText to set
- */
- public void setToggleButtonToolTipText(String toggleButtonToolTipText)
- {
- this.toggleButtonToolTipText = toggleButtonToolTipText;
- }
-
- /**
- * Gets the entryFieldToolTipText
- * @return Returns a String
- */
- public String getEntryFieldToolTipText()
- {
- return entryFieldToolTipText;
- }
- /**
- * Sets the entryFieldToolTipText
- * @param entryFieldToolTipText The entryFieldToolTipText to set
- */
- public void setEntryFieldToolTipText(String entryFieldToolTipText)
- {
- this.entryFieldToolTipText = entryFieldToolTipText;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPerspectiveHelpers.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPerspectiveHelpers.java
deleted file mode 100644
index 5c3b52f8e..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPerspectiveHelpers.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-
-
-/**
- * @author coulthar
- *
- * Helper methods related to finding and switching perspectives, views and
- * so on.
- */
-public class SystemPerspectiveHelpers
-{
-
- // constants
- /**
- * The ID of the RSE perspective
- */
- public static String RSE_PERSP_ID = SystemPerspectiveLayout.ID;
-
-
- /**
- * Opens the RSE perspective, if not already, in the current window
- */
- public static boolean openRSEPerspective()
- {
- return openInNewPage(RSE_PERSP_ID);
- }
- /**
- * Tests if the RSE perspective is the active perspective
- */
- public static boolean isRSEPerspectiveActive()
- {
- IPerspectiveDescriptor activePersp = getActivePerspective();
- if ((activePersp!=null) && activePersp.getId().equals(RSE_PERSP_ID))
- return true;
- else
- return false;
- }
- /**
- * Opens a new page with a particular perspective, given the perspective's ID
- * @return true if was open or successfully opened/focused. False if anything went wrong
- */
- public static boolean openInNewPage(String perspID)
- {
- boolean ok = false;
- IPerspectiveDescriptor persp = getActivePerspective();
- if (persp == null)
- return ok;
- if (persp.getId().equals(perspID))
- return true;
- // If the perspective is already open, then reuse it.
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage[] pages = window.getPages();
- for (int i = 0; i < pages.length; i++)
- {
- persp = pages[i].getPerspective();
- if (persp != null && persp.getId().equals(perspID))
- {
- window.setActivePage(pages[i]);
- return true;
- }
- }
- // Open the page.
- try {
- //window.openPage(perspID, ResourcesPlugin.getWorkspace().getRoot()); OPENS A NEW WINDOW!!
- window.getWorkbench().showPerspective(perspID, window);
- ok = true;
- } catch (WorkbenchException e) {
- SystemBasePlugin.logError("Error opening perspective "+perspID, e); //$NON-NLS-1$
- }
- return ok;
- }
- /**
- * Return the currently active perpsective in the currently active page in the
- * currently active window.
- * May return null!
- */
- public static IPerspectiveDescriptor getActivePerspective()
- {
- // get the active window
- IWorkbenchWindow window = getActiveWindow();
- if (window != null)
- {
- // get the active page
- IWorkbenchPage page = window.getActivePage();
- if (page != null)
- // get the active perspective
- return page.getPerspective();
- }
- return null;
- }
- /**
- * Return the currently active window.
- * May return null!
- */
- public static IWorkbenchWindow getActiveWindow()
- {
- // get the active window
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- }
-
- /**
- * Search for, and return, a view with the given ID, in the active perspective
- */
- public static IViewPart findView(String viewID)
- {
- IViewPart viewPart = null;
- IWorkbenchWindow window = getActiveWindow();
- if (window != null)
- {
- IWorkbenchPage page = window.getActivePage();
- if (page != null)
- viewPart= page.findView(viewID);
- } // end if window != null
- return viewPart;
- }
-
- /**
- * Return the RSE tree view in the active perspective, or null if the active
- * perspective is NOT the RSE perspective.
- */
- public static SystemView findRSEView()
- {
- IViewPart viewPart = findView(SystemViewPart.ID);
- if ((viewPart != null) && (viewPart instanceof SystemViewPart))
- return ((SystemViewPart)viewPart).getSystemView();
- else
- return null;
- }
-
- /**
- * Show the view with given ID, if not already showing in current perspective,
- * in current page, in current window.
- * @return the view part instance if found or opened successfully. Null if something went wrong
- */
- public static IViewPart showView(String viewID)
- {
- IViewPart viewPart = null;
- IWorkbenchWindow window = getActiveWindow();
- if (window != null)
- {
- IWorkbenchPage page = window.getActivePage();
- if (page != null)
- {
- try
- {
- viewPart= page.findView(viewID);
- if ( viewPart != null )
- page.bringToTop(viewPart);
- else
- {
- //IWorkbenchPart activePart= page.getActivePart(); not used? Phil
- viewPart = page.showView(viewID);
- }
- }
- catch (PartInitException pie)
- {
- SystemBasePlugin.logError("Error opening view " + viewID, pie); //$NON-NLS-1$
- }
- } //end if page != null
- } // end if window != null
- return viewPart;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPerspectiveLayout.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPerspectiveLayout.java
deleted file mode 100644
index 7a1183db0..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPerspectiveLayout.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - Fix 164628: get rid of dependency to debug.ui
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-
-
-import org.eclipse.rse.internal.ui.view.scratchpad.SystemScratchpadViewPart;
-import org.eclipse.rse.internal.ui.view.team.SystemTeamViewPart;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-
-/**
- * This class is responsible for laying out the views in the RSE perspective
- */
-public class SystemPerspectiveLayout implements IPerspectiveFactory
-{
-
- public static final String ID = "org.eclipse.rse.ui.view.SystemPerspective"; // matches id in plugin.xml, layout tag //$NON-NLS-1$
- /**
- * Defines the initial layout for a perspective.
- * This method is only called when a new perspective is created. If
- * an old perspective is restored from a persistence file then
- * this method is not called.
- *
- * @param layout the page layout
- */
- public void createInitialLayout(IPageLayout layout)
- {
- String editorArea = layout.getEditorArea();
-
- IFolderLayout folder= layout.createFolder("org.eclipse.rse.ui.view.NavFolder", IPageLayout.LEFT, //$NON-NLS-1$
- (float)0.25, editorArea);
- //folder.addView(IPageLayout.ID_RES_NAV);
- folder.addView(SystemViewPart.ID);
- folder.addView(SystemTeamViewPart.ID);
-
- folder= layout.createFolder("org.eclipse.rse.ui.view.MiscFolder", IPageLayout.BOTTOM, //$NON-NLS-1$
- (float).60, editorArea);
-
- folder.addView(SystemTableViewPart.ID);
- //folder.addView(SystemMonitorViewPart.ID);
- folder.addView(IPageLayout.ID_TASK_LIST); // put in the desktop-supplied task list view
-
-
- folder= layout.createFolder("org.eclipse.rse.ui.view.OutlineFolder", IPageLayout.RIGHT, //$NON-NLS-1$
- (float).80, editorArea);
-
- folder.addView(IPageLayout.ID_OUTLINE); // put in desktop-supplied outline view
- // unfortunately we can't do the following as snippets aren't in wswb, according to DKM
-
- folder= layout.createFolder("org.eclipse.rse.ui.view.PropertiesFolder", IPageLayout.BOTTOM, //$NON-NLS-1$
- (float).75, "org.eclipse.rse.ui.view.NavFolder"); //$NON-NLS-1$
- //layout.addView(IPageLayout.ID_PROP_SHEET, IPageLayout.BOTTOM,
- // (float)0.75, "org.eclipse.rse.ui.view.NavFolder"); // put in desktop-supplied property sheet view
- folder.addView(IPageLayout.ID_PROP_SHEET);
- folder.addView(SystemScratchpadViewPart.ID);
-
- // update Show View menu with our views
- layout.addShowViewShortcut(SystemViewPart.ID);
- layout.addShowViewShortcut(SystemTableViewPart.ID);
-
- layout.addShowViewShortcut(SystemTableViewPart.ID);
- layout.addShowViewShortcut(SystemViewPart.ID);
- layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
- // update Perspective Open menu with our perspective
- layout.addPerspectiveShortcut(ID);
-
- // Add action sets to the tool bar.
- // Fix 164628: get rid of dependency to debug.ui
- //layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
- //layout.addActionSet(IDebugUIConstants.DEBUG_ACTION_SET);
- layout.addActionSet("org.eclipse.debug.ui.launchActionSet"); //$NON-NLS-1$
- layout.addActionSet("org.eclipse.debug.ui.debugActionSet"); //$NON-NLS-1$
-
-
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPropertySheetForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPropertySheetForm.java
deleted file mode 100644
index 952a26fb3..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemPropertySheetForm.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-
-
-
-/**
- * This re-usable widget is for a property-sheet widget that is imbeddable in dialogs.
- * It is similar to the workbench property sheet but there are some important differences.
- */
-public class SystemPropertySheetForm extends Composite
-{
-
- private PropertySheetPage tree = null;
- private boolean enabledMode = true;
- //private ISystemViewInputProvider inputProvider = null;
- //private ISystemViewInputProvider emptyProvider = new SystemEmptyListAPIProviderImpl();
- public static final int DEFAULT_WIDTH = 300;
- public static final int DEFAULT_HEIGHT = 250;
-
- /**
- * Constructor
- * @param shell The owning window
- * @param parent The owning composite
- * @param style The swt style to apply to the overall composite. Typically SWT.NULL
- * @param msgLine where to show messages and tooltip text
- */
- public SystemPropertySheetForm(Shell shell, Composite parent, int style, ISystemMessageLine msgLine)
- {
- this(shell, parent, style, msgLine, 1, 1);
- }
- /**
- * Constructor when you want to span more than one column or row
- * @param shell The owning window
- * @param parent The owning composite
- * @param style The swt style to apply to the overall composite. Typically SWT.NULL
- * @param horizontalSpan how many columns in parent composite to span
- * @param verticalSpan how many rows in parent composite to span
- * @param msgLine where to show messages and tooltip text
- */
- public SystemPropertySheetForm(Shell shell, Composite parent, int style, ISystemMessageLine msgLine, int horizontalSpan, int verticalSpan)
- {
- super(parent, style);
- prepareComposite(1, horizontalSpan, verticalSpan);
- createPropertySheetView(shell);
- addOurSelectionListener();
- addOurMouseListener();
- addOurKeyListener();
- }
-
- /**
- * Return the system view tree viewer
- */
- public PropertySheetPage getPropertySheetView()
- {
- return tree;
- }
- /**
- * Return the underlying control
- */
- public Control getControl()
- {
- return tree.getControl();
- }
-
- /**
- * Set the tree's tooltip text
- */
- public void setToolTipText(String tip)
- {
- tree.getControl().setToolTipText(tip);
- }
- /**
- * Refresh contents
- */
- public void refresh()
- {
- tree.refresh();
- }
-
- /**
- * Method declared on ISelectionListener.
- */
- public void selectionChanged(ISelection selection)
- {
- tree.selectionChanged(null, selection);
- }
-
- /**
- * Disable/Enable all the child controls.
- */
- public void setEnabled(boolean enabled)
- {
- enabledMode = enabled;
- }
-
- // -----------------------
- // INTERNAL-USE METHODS...
- // -----------------------
- /**
- * Prepares this composite control and sets the default layout data.
- * @param Number of columns the new group will contain.
- */
- protected Composite prepareComposite(int numColumns,
- int horizontalSpan, int verticalSpan)
- {
- Composite composite = this;
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- composite.setLayout(layout);
- //GridData
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- data.widthHint = DEFAULT_WIDTH;
- data.heightHint = DEFAULT_HEIGHT;
- data.horizontalSpan = horizontalSpan;
- data.verticalSpan = verticalSpan;
- composite.setLayoutData(data);
- return composite;
- }
-
- protected void createPropertySheetView(Shell shell)
- {
- tree = new PropertySheetPage();
- tree.createControl(this);
- Control c = tree.getControl();
- GridData treeData = new GridData();
- treeData.horizontalAlignment = GridData.FILL;
- treeData.verticalAlignment = GridData.FILL;
- treeData.grabExcessHorizontalSpace = true;
- treeData.grabExcessVerticalSpace = true;
- treeData.widthHint = 220;
- treeData.heightHint= 200;
- c.setLayoutData(treeData);
- //tree.setShowActions(showActions);
-
- }
-
-
- protected void addOurSelectionListener()
- {
- // Add the button listener
-/* SelectionListener selectionListener = new SelectionListener()
- {
- public void widgetDefaultSelected(SelectionEvent event)
- {
- }
- public void widgetSelected(SelectionEvent event)
- {
- if (!enabledMode)
- return;
- }
- };*/
- //tree.getControl().addSelectionListener(selectionListener);
- }
-
- protected void addOurMouseListener()
- {
- MouseListener mouseListener = new MouseAdapter()
- {
- public void mouseDown(MouseEvent e)
- {
- if (!enabledMode)
- return;
- //requestActivation();
- }
- };
- tree.getControl().addMouseListener(mouseListener);
- }
-
- protected void addOurKeyListener()
- {
- KeyListener keyListener = new KeyAdapter()
- {
- public void keyPressed(KeyEvent e)
- {
- if (!enabledMode)
- {
- //e.doit = false;
- return;
- }
- //handleKeyPressed(e);
- }
- };
- tree.getControl().addKeyListener(keyListener);
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResolveFilterStringAPIProviderImpl.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResolveFilterStringAPIProviderImpl.java
deleted file mode 100644
index 23b08dffe..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResolveFilterStringAPIProviderImpl.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * It is used when the contents are used to show the resolution of a single filter string.
- */
-public class SystemResolveFilterStringAPIProviderImpl extends SystemTestFilterStringAPIProviderImpl
-{
-
-
-
- /**
- * Constructor
- * @param subsystem The subsystem that will resolve the filter string
- * @param filterString The filter string to test
- */
- public SystemResolveFilterStringAPIProviderImpl(ISubSystem subsystem, String filterString)
- {
- super(subsystem, filterString);
- } // end constructor
-
-
-} // end class SystemResolveFilterStringAPIProviderImpl
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResourceSelectionForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResourceSelectionForm.java
deleted file mode 100644
index b178a665e..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResourceSelectionForm.java
+++ /dev/null
@@ -1,646 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2006, 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Kevin Doyle (IBM) - Added getSystemViewForm()
- * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Martin Oberhuber (Wind River) - [190442] made SystemActionViewerFilter API
- * Martin Oberhuber (Wind River) - [202866] Fix exceptions in RSE browse dialog when SystemRegistry is not yet fully initialized
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- * David Dykstal (IBM) - [232130] meaningless label provided for filter references
- * David McKnight (IBM) - [244430] [regression] Incorrect behaviour for SystemSelectRemoteFolderAction
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.SystemActionViewerFilter;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.rse.ui.view.ISystemResourceSelectionInputProvider;
-import org.eclipse.rse.ui.view.ISystemTree;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.rse.ui.widgets.SystemHostCombo;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-
-public class SystemResourceSelectionForm implements ISelectionChangedListener
-{
- private Shell _shell;
- private boolean _multipleSelection = true;
- protected static final int PROMPT_WIDTH = 400; // The maximum width of the dialog's prompt, in pixels.
-
- private ISystemResourceSelectionInputProvider _inputProvider;
- private SystemHostCombo _connectionCombo;
- private SystemViewForm _systemViewForm;
- private Composite _propertySheetContainer;
- private SystemPropertySheetForm _ps;
-
- private Text _pathText;
- private boolean _isValid;
- private ISystemMessageLine _msgLine;
- protected Object previousSelection = null;
- private IValidatorRemoteSelection _selectionValidator = null;
- private boolean showPropertySheet = false;
-
-
- protected Object caller;
- protected boolean callerInstanceOfWizardPage, callerInstanceOfSystemPromptDialog;
-
- protected String _verbiage = null;
- protected Label verbiageLabel;
- private Composite _container;
-
- // history
- private HashMap _history;
-
- // outputs
- protected IHost outputConnection = null;
- protected Object[] outputObjects = null;
-
-
- public SystemResourceSelectionForm(Shell shell, Composite parent, Object caller,
- ISystemResourceSelectionInputProvider inputProvider,
- String verbiage,
- boolean multipleSelection,
- ISystemMessageLine msgLine)
- {
- _msgLine= msgLine;
- _history = new HashMap();
- _inputProvider = inputProvider;
- _multipleSelection = multipleSelection;
- _shell = shell;
- _verbiage = verbiage;
- this.caller = caller;
- callerInstanceOfWizardPage = (caller instanceof WizardPage);
- callerInstanceOfSystemPromptDialog = (caller instanceof SystemPromptDialog);
-
- createControls(parent);
- }
-
- public void setMessageLine(ISystemMessageLine msgLine)
- {
- _msgLine = msgLine;
- }
-
- /**
- * Return first selected object
- */
- public Object getSelectedObject()
- {
- if ((outputObjects != null) && (outputObjects.length>=1))
- return outputObjects[0];
- else
- return null;
- }
- /**
- * Return all selected objects.
- */
- public Object[] getSelectedObjects()
- {
- return outputObjects;
- }
-
- /**
- * Return the embedded System Tree object.
- * Will be null until createControls is called.
- */
- public ISystemTree getSystemTree()
- {
- return _systemViewForm.getSystemTree();
- }
-
- public void createControls(Composite parent)
- {
- _container = SystemWidgetHelpers.createComposite(parent, showPropertySheet ? 2 : 1);
- //Composite container = new Composite(parent, SWT.NULL);
-
-
- // INNER COMPOSITE
- int gridColumns = 2;
- Composite composite_prompts = SystemWidgetHelpers.createFlushComposite(_container, gridColumns);
-
- // PROPERTY SHEET COMPOSITE
- if (showPropertySheet)
- {
- createPropertySheet(_container, _shell);
- }
-
-
- // MESSAGE/VERBIAGE TEXT AT TOP
- verbiageLabel = SystemWidgetHelpers.createVerbiage(composite_prompts, _verbiage, gridColumns, false, PROMPT_WIDTH);
-
-
- boolean allowMultipleConnnections = _inputProvider.allowMultipleConnections();
- if (!allowMultipleConnnections)
- {
- //Label connectionLabel = SystemWidgetHelpers.createLabel(composite_prompts, _inputProvider.getSystemConnection().getHostName());
- }
- else
- {
- IRSESystemType[] systemTypes = _inputProvider.getSystemTypes();
- String category = _inputProvider.getCategory();
-
- if (systemTypes != null)
- {
- _connectionCombo = new SystemHostCombo(composite_prompts, SWT.NULL, systemTypes, _inputProvider.getSystemConnection(), _inputProvider.allowNewConnection());
- }
- else if (category != null)
- {
- _connectionCombo = new SystemHostCombo(composite_prompts, SWT.NULL, _inputProvider.getSystemConnection(), _inputProvider.allowNewConnection(), category);
- }
- else
- {
- _connectionCombo = new SystemHostCombo(composite_prompts, SWT.NULL,
- SystemWidgetHelpers.getValidSystemTypes(null),
- _inputProvider.getSystemConnection(),
- _inputProvider.allowNewConnection());
-
- }
- _connectionCombo.addSelectionListener(new SelectionAdapter()
- {
- public void widgetSelected(SelectionEvent evt)
- {
- IHost connection = _connectionCombo.getHost();
- connectionChanged(connection);
- }}
- );
- _connectionCombo.listenToConnectionEvents(true);
- }
-
- _pathText = SystemWidgetHelpers.createReadonlyTextField(composite_prompts);
- _systemViewForm = new SystemViewForm(_shell, composite_prompts, SWT.NULL, _inputProvider, !_multipleSelection, _msgLine);
- _systemViewForm.addSelectionChangedListener(this);
-
-
- GridLayout layout = new GridLayout();
- GridData gdata = new GridData(GridData.FILL_BOTH);
- composite_prompts.setLayout(layout);
- composite_prompts.setLayoutData(gdata);
-
- doInitializeFields();
- }
-
- private void doInitializeFields()
- {
- setPageComplete();
- return;
- }
-
- /**
- * Create the property sheet viewer
- */
- private void createPropertySheet(Composite outerParent, Shell shell)
- {
- _propertySheetContainer = SystemWidgetHelpers.createFlushComposite(outerParent, 1);
- ((GridData)_propertySheetContainer.getLayoutData()).grabExcessVerticalSpace = true;
- ((GridData)_propertySheetContainer.getLayoutData()).verticalAlignment = GridData.FILL;
-
- // PROPERTY SHEET VIEWER
- _ps = new SystemPropertySheetForm(shell,_propertySheetContainer, SWT.BORDER, _msgLine);
- }
-
- public Control getInitialFocusControl()
- {
- return _systemViewForm.getTreeControl();
- }
-
- public void applyViewerFilter(SystemActionViewerFilter filter)
- {
- if (filter != null)
- {
- _systemViewForm.getSystemTree().addFilter(filter);
- }
- }
-
- /**
- * Completes processing of the wizard page or dialog. If this
- * method returns true, the wizard/dialog will close;
- * otherwise, it will stay active.
- *
- * @return true if no errors
- */
- public boolean verify()
- {
- if (_isValid)
- {
- if (_msgLine != null)
- {
- _msgLine.clearErrorMessage();
- }
- return true;
- }
- else
- {
- return false;
- }
- }
-
- protected ISystemViewElementAdapter getViewAdapter(Object selection)
- {
- if (selection != null && selection instanceof IAdaptable)
- {
- return (ISystemViewElementAdapter)((IAdaptable)selection).getAdapter(ISystemViewElementAdapter.class);
- }
- return null;
- }
-
- protected ISystemRemoteElementAdapter getRemoteAdapter(Object selection)
- {
- if (selection != null && selection instanceof IAdaptable)
- {
- return SystemAdapterHelpers.getRemoteAdapter(selection);
- }
- return null;
- }
-
- protected ISystemRemoteElementAdapter[] getRemoteAdapters(ISelection selection)
- {
- Object[] selectedObjects = getSelections(selection);
- ISystemRemoteElementAdapter[] adapters = new ISystemRemoteElementAdapter[selectedObjects.length];
- for (int idx=0; idx<adapters.length; idx++)
- {
- adapters[idx] = getRemoteAdapter(selectedObjects[idx]);
- }
- return adapters;
- }
-
-
- public void connectionChanged(IHost connection)
- {
- IHost previousConnection = _inputProvider.getSystemConnection();
- if (previousConnection != connection)
- {
-
- _inputProvider.setSystemConnection(connection, false);
-
- _systemViewForm.refresh();
- Object oldSelection = _history.get(connection);
- if (oldSelection != null)
- {
- setPreSelection(oldSelection);
- }
- }
- }
-
- public void setVerbiage(String verbiage)
- {
- _verbiage = verbiage;
- }
-
- public boolean setPreSelection(Object selection)
- {
- ISystemViewElementAdapter adapter = getViewAdapter(selection);
- if (adapter != null)
- {
- Object parent = adapter.getParent(selection);
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- ISubSystem ss = adapter.getSubSystem(selection);
- IHost connection = ss.getHost();
- if (_inputProvider.allowMultipleConnections())
- {
- if (_connectionCombo.getHost()!= connection || _inputProvider.getSystemConnection() != connection)
- {
- _connectionCombo.select(connection);
- }
- }
- List filterRefs = registry.findFilterReferencesFor(selection, ss, false);
-
- ISystemTree systemTree = _systemViewForm.getSystemTree();
- if (filterRefs.size() > 0)
- {
- ISystemFilterReference ref = (ISystemFilterReference)filterRefs.get(0);
- systemTree.expandTo(ref, selection);
-
- return true;
- }
- else
- {
- if (setPreSelection(parent))
- {
- systemTree.expandTo(parent, selection);
- return true;
- }
- }
- }
- return false;
- }
-
-
- protected void setPathText(String text)
- {
- _pathText.setText(text);
- }
-
-
- public Object[] getOutputObjects()
- {
- return outputObjects;
- }
-
- /**
- * Return selected connection
- */
- public IHost getSelectedConnection()
- {
- return outputConnection;
- }
-
- /**
- * Return first item currently selected.
- */
- protected Object getFirstSelection(ISelection selection)
- {
- IStructuredSelection sSelection = (IStructuredSelection)selection;
- if (sSelection != null)
- {
- Iterator selectionIterator = sSelection.iterator();
- if (selectionIterator.hasNext())
- return selectionIterator.next();
- else
- return null;
- }
- return null;
- }
- /**
- * Return all items currently selected.
- */
- protected Object[] getSelections(ISelection selection)
- {
- IStructuredSelection sSelection = (IStructuredSelection)selection;
- if (sSelection != null)
- {
- Object[] selectedObjects = new Object[sSelection.size()];
- Iterator selectionIterator = sSelection.iterator();
- int idx = 0;
- while (selectionIterator.hasNext())
- selectedObjects[idx++] = selectionIterator.next();
- return selectedObjects;
- }
- return null;
- }
-
-
- private void setPathTextFromSelection(Object selection)
- {
- String text = ""; //$NON-NLS-1$
- ISystemViewElementAdapter adapter = getViewAdapter(selection);
- if (selection instanceof ISystemFilterReference) {
- text = adapter.getText(selection);
- } else {
- text = adapter.getAbsoluteName(selection);
- }
- setPathText(text);
- }
-
- /**
- * Show or hide the property sheet. This is called after the contents are created when the user
- * toggles the Details button.
- * @param shell Use getShell() in your dialog or wizard page
- * @param contents Use getContents() in your dialog or wizard page
- * @return new state -> true if showing, false if hiding
- */
- public boolean toggleShowPropertySheet(Shell shell, Control contents)
- {
- Point windowSize = shell.getSize();
- Point oldSize = contents.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- if (showPropertySheet) // hiding?
- {
- _ps.dispose();
-
- _propertySheetContainer.dispose();
- _ps = null;
- _propertySheetContainer = null;
- ((GridLayout)_container.getLayout()).numColumns = 1;
- }
- else // showing?
- {
- //createPropertySheet((Composite)contents, shell);
- ((GridLayout)_container.getLayout()).numColumns = 2;
- createPropertySheet(_container, shell);
- }
-
- Point newSize = contents.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- shell.setSize(new Point(windowSize.x + (newSize.x - oldSize.x), windowSize.y));
-
- if (_ps != null)
- {
- ISelection s = _systemViewForm.getSelection();
- if (s != null)
- _ps.selectionChanged(s);
- }
-
- showPropertySheet = !showPropertySheet;
- return showPropertySheet;
- }
-
-
-// ---------------------------------------------------
- // METHODS FOR SELECTION CHANGED LISTENER INTERFACE...
- // ---------------------------------------------------
- /**
- * User selected something in the _systemViewForm.
- */
- public void selectionChanged(SelectionChangedEvent e)
- {
- _isValid = true;
- ISelection selection = e.getSelection();
- outputObjects = null;
- int selectionSize = ((IStructuredSelection)selection).size();
- if ((selectionSize > 1) && !_systemViewForm.sameParent())
- {
- clearErrorMessage();
-
- setPathText(""); //$NON-NLS-1$
- setPageComplete();
- return; // don't enable OK/Add if selections from different parents
- }
-
- if (_ps != null)
- _ps.selectionChanged(selection);
-
- Object selectedObject = getFirstSelection(selection);
- if (selectedObject == previousSelection && selectionSize == 1)
- {
- // DKM we null set this before, so we need to reset it
- outputObjects = getSelections(selection);
- return;
- }
- clearErrorMessage();
- setPathText(""); //$NON-NLS-1$
- setPageComplete();
-
- previousSelection = selectedObject;
- if (selectedObject != null)
- {
-
- ISystemRemoteElementAdapter remoteAdapter = getRemoteAdapter(selectedObject);
- if (remoteAdapter != null)
- {
- setPathTextFromSelection(selectedObject);
-
- outputObjects = getSelections(selection);
- outputConnection = remoteAdapter.getSubSystem(selectedObject).getHost();
-
- _history.put(outputConnection, previousSelection);
- }
- else
- {
- ISystemViewElementAdapter elementAdapter = (ISystemViewElementAdapter)((IAdaptable)selectedObject).getAdapter(ISystemViewElementAdapter.class);
- if (elementAdapter != null)
- {
- setPathTextFromSelection(selectedObject);
-
- outputObjects = getSelections(selection);
- outputConnection = elementAdapter.getSubSystem(selectedObject).getHost();
-
- _history.put(outputConnection, previousSelection);
- }
- }
-
-
- if (_selectionValidator != null)
- {
- SystemMessage selectionMsg = _selectionValidator.isValid(outputConnection, getSelections(selection), getRemoteAdapters(selection));
-
- if (selectionMsg != null)
- {
- _isValid = false;
- setErrorMessage(selectionMsg);
- }
- }
- setPageComplete();
- }
-
- }
-
- /**
- * This method can be called by the dialog or wizard page host, to decide whether to enable
- * or disable the next, final or ok buttons. It returns true if the minimal information is
- * available and is correct.
- */
- public boolean isPageComplete()
- {
- return ( (_pathText.getText().length() > 0) ) && _isValid;
- }
-
- /**
- * Inform caller of page-complete status of this form
- */
- public void setPageComplete()
- {
- if (callerInstanceOfWizardPage)
- {
- ((WizardPage)caller).setPageComplete(isPageComplete());
- }
- else if (callerInstanceOfSystemPromptDialog)
- {
- ((SystemPromptDialog)caller).setPageComplete(isPageComplete());
- }
- }
-
- /**
- * Show the property sheet on the right hand side, to show the properties of the
- * selected object.
- * <p>
- * Default is false
- */
- public void setShowPropertySheet(boolean show)
- {
- this.showPropertySheet = show;
- }
-
-
-
- /**
- * Specify a validator to use when the user selects a remote file or folder.
- * This allows you to decide if OK should be enabled or not for that remote file or folder.
- */
- public void setSelectionValidator(IValidatorRemoteSelection selectionValidator)
- {
- _selectionValidator = selectionValidator;
- }
-
- protected void clearErrorMessage()
- {
- if (_msgLine != null)
- _msgLine.clearErrorMessage();
- }
- protected void setErrorMessage(String msg)
- {
- if (_msgLine != null)
- if (msg != null)
- _msgLine.setErrorMessage(msg);
- else
- _msgLine.clearErrorMessage();
- }
- protected void setErrorMessage(SystemMessage msg)
- {
- if (_msgLine != null)
- if (msg != null)
- _msgLine.setErrorMessage(msg);
- else
- _msgLine.clearErrorMessage();
- }
-
-
- /**
- * Set the message shown as the text at the top of the form. Eg, "Select a file"
- */
- public void setMessage(String message)
- {
- this._verbiage = message;
- if (verbiageLabel != null)
- verbiageLabel.setText(message);
- }
- /**
- * Set the tooltip text for the remote systems tree from which an item is selected.
- */
- public void setSelectionTreeToolTipText(String tip)
- {
- _systemViewForm.setToolTipText(tip);
- }
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResourceSelectionInputProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResourceSelectionInputProvider.java
deleted file mode 100644
index f5aee241c..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemResourceSelectionInputProvider.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2004, 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Martin Oberhuber (Wind River) - [202866] Fix exceptions in RSE browse dialog when SystemRegistry is not yet fully initialized
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- * David McKnight (IBM) - [252912] SystemRemoteFileDialog shows Local contents even when specifying a SystemType
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.view.ISystemResourceSelectionInputProvider;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-
-
-public abstract class SystemResourceSelectionInputProvider extends SystemAbstractAPIProvider
- implements ISystemResourceSelectionInputProvider
-{
- private IHost _connection = null;
- private boolean _onlyConnection = false;
- private boolean _allowNew = true;
- private IRSESystemType[] _systemTypes;
- private String _category = null;
-
- public SystemResourceSelectionInputProvider(IHost connection)
- {
- _connection = connection;
- }
-
- public SystemResourceSelectionInputProvider()
- {
- // choose random host
- IHost[] hosts = getValidHosts();
- if (hosts != null && hosts.length>0) {
- _connection = hosts[0];
- }
- }
-
- private boolean validHost(IHost host){
- if (_systemTypes != null){
- IRSESystemType hostType = host.getSystemType();
- for (int t = 0; t < _systemTypes.length; t++){
- IRSESystemType type = _systemTypes[t];
- if (hostType.equals(type)){
- return true;
- }
- }
- return false;
- }
- else {
- return true;
- }
- }
-
- private IHost[] getValidHosts() {
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- IHost[] hosts = registry.getHosts();
-
- // make sure the hosts are valid for the specified system types
- if (_systemTypes != null){
- List hostList = new ArrayList();
- for (int i = 0; i < hosts.length; i++){
- IHost host = hosts[i];
- if (validHost(host)){
- hostList.add(host);
- }
- }
- return (IHost[])hostList.toArray(new IHost[hostList.size()]);
- }
- else {
- return hosts;
- }
- }
-
- public IHost getSystemConnection()
- {
- return _connection;
- }
-
- public boolean allowMultipleConnections()
- {
- return !_onlyConnection;
- }
-
- public void setAllowNewConnection(boolean flag)
- {
- _allowNew = flag;
- }
-
- public boolean allowNewConnection()
- {
- return _allowNew;
- }
-
- public void setSystemConnection(IHost connection, boolean onlyConnection)
- {
- _connection = connection;
- _onlyConnection = onlyConnection;
- }
-
- public IRSESystemType[] getSystemTypes()
- {
- return _systemTypes;
- }
-
- public void setSystemTypes(IRSESystemType[] types)
- {
- _systemTypes = types;
- if (_connection != null){ // reset the connection if isn't valid
- if (!validHost(_connection)){
- _connection = null;
- }
- }
- }
-
- public Object[] getSystemViewRoots()
- {
- if (_connection == null)
- {
- IHost[] hosts = getValidHosts();
- if (hosts!=null && hosts.length!=0) {
- _connection = hosts[0];
- }
- }
- if (_connection != null){
- return getConnectionChildren(_connection);
- }
- else {
- return new Object[0];
- }
- }
-
- public boolean hasSystemViewRoots()
- {
- return false;
- }
-
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- if (selectedConnection != null)
- {
- ISubSystem ss = getSubSystem(selectedConnection);
- if (ss!=null) {
- return ss.getChildren();
- }
- }
- return new Object[0];
- }
-
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- if (selectedConnection != null)
- {
- ISubSystem ss = getSubSystem(selectedConnection);
- if (ss!=null) {
- return ss.hasChildren();
- }
- }
- return false;
- }
-
- protected abstract ISubSystem getSubSystem(IHost selectedConnection);
-
-
- public void setCategory(String category)
- {
- _category = category;
- }
-
- public String getCategory()
- {
- return _category;
- }
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemSelectRemoteObjectAPIProviderImpl.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemSelectRemoteObjectAPIProviderImpl.java
deleted file mode 100644
index af65137d8..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemSelectRemoteObjectAPIProviderImpl.java
+++ /dev/null
@@ -1,631 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
- * Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * David Dykstal (IBM) - [224671] [api] org.eclipse.rse.core API leaks non-API types
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.filters.ISystemFilterStringReference;
-import org.eclipse.rse.core.filters.SystemFilterUtil;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.internal.model.SystemNewConnectionPromptObject;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.rse.ui.view.ISystemSelectRemoteObjectAPIProvider;
-import org.eclipse.rse.ui.view.ISystemSelectRemoteObjectAPIProviderCaller;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * <p>
- * It is used when the contents are used to allow the user to select a remote system object.
- * The tree will begin with the filter pool references or filter references (depending on
- * the user's preferences setting) of the given subsystem.
- * <p>
- * Alternatively, a filter string can be given and the contents will be the result of resolving
- * that filter string.
- */
-public class SystemSelectRemoteObjectAPIProviderImpl
- extends SystemAbstractAPIProvider
- implements ISystemSelectRemoteObjectAPIProvider
- {
-
-
- protected ISubSystem subsystem = null;
- protected String filterString = null;
- protected ISystemViewElementAdapter subsystemAdapter = null;
-
- // For mode when we want to list the connections ...
- protected boolean listConnectionsMode = false;
- protected boolean showNewConnectionPrompt = false;
- protected boolean singleConnectionMode = false;
- protected String subsystemConfigurationId;
- protected String subsystemConfigurationCategory;
- protected String filterSuffix;
- protected IRSESystemType[] systemTypes;
- protected String preSelectFilterChild;
- protected Object preSelectFilterChildObject;
- protected ISystemFilter[] quickFilters;
- protected IHost[] inputConnections;
- protected SystemNewConnectionPromptObject connPrompt = null;
- protected Object[] connPromptAsArray;
- protected ISystemSelectRemoteObjectAPIProviderCaller caller;
- protected boolean multiConnections = false;
-
- /**
- * Constructor that takes the input needed to drive the list. Specifically,
- * we need to know what connections to list, and when a connection is expanded,
- * what subsystems to query for the remote objects.
- * <p>
- * This can be done by giving one of two possible pieces of information:
- * <ul>
- * <li>a subsystem factory Id, which scopes the connections to those containing subsystems
- * owned by this factory, and scopes subsystems to only those from this factory.
- * <li>The subsystem factory Id is usually the right choice, unless you want to include
- * connections and subsystems from multiple subsystem factories, such as is the case
- * for universal files ... there is one base factory but it is subclassed a number of
- * times. For this and any other case we also allow scoping by subsystem factory
- * category. All connections from any factory of this category are included, and
- * subsystems of factories from this category are used to populate the list.
- * </ul>
- * <p>
- * You must supply one of these. There is no need to supply both.
- * <p>
- * Also, it is often desired to restrict what system types the user can create new connections for.
- * While this could be deduced from the first two pieces of information, it is safer to ask the
- * caller to explicitly identify these. If null is passed, then there is no restrictions.
- *
- * @param configId The subsystemConfigurationId to restrict connections and subsystems to
- * An alternative to factoryCategory. Specify only one, pass null for the other.
- * @param configCategory The subsystem configuration category to restrict connections and subsystems to.
- * An alternative to factoryId. Specify only one, pass null for the other.
- * @param showNewConnectionPrompt true if to show "New Connection" prompt, false if not to
- * @param systemTypes Optional list of system types to restrict the "New Connection" wizard to. Pass null for no restrictions
- */
- public SystemSelectRemoteObjectAPIProviderImpl(String configId, String configCategory,
- boolean showNewConnectionPrompt, IRSESystemType[] systemTypes)
- {
- super();
- this.subsystemConfigurationId = configId;
- this.subsystemConfigurationCategory = configCategory;
- this.systemTypes = systemTypes;
- this.showNewConnectionPrompt = showNewConnectionPrompt;
- this.listConnectionsMode = true;
- }
-
- /**
- * Set the caller to callback to for some events, such as the expansion of a prompting
- * transient filter.
- */
- public void setCaller(ISystemSelectRemoteObjectAPIProviderCaller caller)
- {
- this.caller = caller;
- }
-
- /**
- * Specify whether the user should see the "New Connection..." special connection prompt
- */
- public void setShowNewConnectionPrompt(boolean show)
- {
- this.showNewConnectionPrompt = show;
- }
-
- /**
- * Specify system types to restrict what types of connections
- * the user can create, and see.
- * This will override subsystemConfigurationId,if that has been set!
- *
- * @param systemTypes An array of system types, or
- * <code>null</code> to allow all registered valid system types.
- * A system type is valid if at least one subsystem configuration
- * is registered against it.
- */
- public void setSystemTypes(IRSESystemType[] systemTypes)
- {
- this.systemTypes = systemTypes;
- }
-
- /**
- * Constructor when there is a subsystem
- * @param subsystem The subsystem that will resolve the filter string
- */
- public SystemSelectRemoteObjectAPIProviderImpl(ISubSystem subsystem)
- {
- super();
- setSubSystem(subsystem);
- }
-
- /**
- * Constructor when there is no subsystem yet
- * @see #setSubSystem(ISubSystem)
- */
- public SystemSelectRemoteObjectAPIProviderImpl()
- {
- super();
- }
-
- /**
- * Default or Restrict to a specific connection.
- * If default mode, it is preselected.
- * If only mode, it is the only connection listed.
- * @param connection The connection to default or restrict to
- * @param onlyMode true if this is to be the only connection shown in the list
- */
- public void setSystemConnection(IHost connection, boolean onlyMode)
- {
- this.inputConnections = new IHost[] {connection};
- this.singleConnectionMode = onlyMode;
- if (onlyMode)
- multiConnections = false;
- }
-
- /**
- * Change the input subsystem
- */
- public void setSubSystem(ISubSystem subsystem)
- {
- this.subsystem = subsystem;
- if (subsystem != null)
- this.subsystemAdapter = getViewAdapter(subsystem);
- else
- this.subsystemAdapter = null;
- }
-
- /**
- * Set the filter string to use to resolve the inputs.
- * If this is an absolute filter string, it gets turned into a quick filter string,
- * so that the user sees it and can expand it. If it is a relative filter string
- * to apply to all expansions, it is used to decorate all filtering as the user drills down.
- */
- public void setFilterString(String string)
- {
- // WARNING: ENTERING BIG HUGE HACK AREA!
- this.filterString = string;
- filterSuffix = null;
- if (string == null)
- return;
-
- if (string.endsWith(",")) //$NON-NLS-1$
- {
- int idx = string.indexOf('/');
- if (idx == -1)
- idx = string.indexOf('\\');
- if (idx == -1)
- {
- filterSuffix = string;
- }
- }
-
- if (filterSuffix != null)
- filterString = null;
-
- SystemBasePlugin.logDebugMessage(this.getClass().getName(), "*** FILTER SUFFIX = '" + filterSuffix + "' ***"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Set the filters to be exposed to the user. These will be shown to the
- * user when they expand a connection.
- */
- public void setQuickFilters(ISystemFilter[] filters)
- {
- this.quickFilters = filters;
- }
-
- /**
- * Set child of the first filter to preselect
- */
- public void setPreSelectFilterChild(String name)
- {
- this.preSelectFilterChild = name;
- }
-
- /**
- * Get the name of the item to select when the first filter is expanded.
- * Called by the filter adapter.
- */
- public String getPreSelectFilterChild()
- {
- return preSelectFilterChild;
- }
-
- /**
- * Set actual child object of the first filter to preselect. Called
- * by the filter adapter once the children are resolved and a match on
- * the name is found.
- */
- public void setPreSelectFilterChildObject(Object obj)
- {
- this.preSelectFilterChildObject = obj;
- }
-
- /**
- * Get the actual object of the item to select when the first filter is expanded.
- * Called by the GUI form after expansion, so it can select this object
- */
- public Object getPreSelectFilterChildObject()
- {
- return preSelectFilterChildObject;
- }
-
- /**
- * Adorn filter string with any relative attributes requested. Eg "/nf" for folders only
- */
- public String decorateFilterString(Object selectedObject, String inputFilterString)
- {
- // this is a hack explicitly for the universal file system. We want to propogate "type filters"
- // like "/nf" and "class," on down the chain, even though we start by showing the user's filters.
- // When those filters are finally expanded, the filter adapter calls us to do this adornment.
-
- if (inputFilterString == null)
- return inputFilterString;
- else if ((filterSuffix != null) && (inputFilterString.indexOf(filterSuffix)==-1))
- {
- SystemBasePlugin.logDebugMessage(this.getClass().getName(), "*** INPUT FILTER = '" + inputFilterString + "' ***"); //$NON-NLS-1$ //$NON-NLS-2$
- String result = inputFilterString;
- if (filterSuffix.equals(" /nf")) //$NON-NLS-1$
- result = inputFilterString + filterSuffix;
- else
- {
- /** FIXME - can't be coupled with IRemoteFile
- RemoteFileFilterString rffs =
- new RemoteFileFilterString((IRemoteFileSubSystemConfiguration)getSubSystemConfiguration(selectedObject), inputFilterString);
- rffs.setFile(filterSuffix);
- result = rffs.toString();
- */
- result = inputFilterString;
- }
- SystemBasePlugin.logDebugMessage(this.getClass().getName(), "*** ADORNED FILTER = '" + result + "' ***"); //$NON-NLS-1$ //$NON-NLS-2$
- return result;
- }
- else
- return inputFilterString;
- }
-
- /**
- * For performance reasons, pre-check to see if filter decoration is even necessary...
- */
- public boolean filtersNeedDecoration(Object selectedObject)
- {
- ISubSystemConfiguration ssf = getSubSystemConfiguration(selectedObject);
- if (ssf == null)
- return false;
- /** FIXME - can't be coupled with IRemoteFile
- return ((ssf instanceof IRemoteFileSubSystemConfiguration) && (filterSuffix != null));
- */
- return false;
-
- }
-
- /**
- * get subsystem factory from filter or filter string
- */
- private ISubSystemConfiguration getSubSystemConfiguration(Object selectedObject)
- {
- if (selectedObject instanceof ISystemFilterReference)
- {
- ISubSystem ss = (ISubSystem)((ISystemFilterReference)selectedObject).getProvider();
- return ss.getSubSystemConfiguration();
- }
- else if (selectedObject instanceof ISystemFilterStringReference)
- {
- ISubSystem ss = (ISubSystem)((ISystemFilterStringReference)selectedObject).getProvider();
- return ss.getSubSystemConfiguration();
- }
- else
- return null;
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
- /**
- * Return the children objects to consistute the root elements in the system view tree.
- */
- public Object[] getSystemViewRoots()
- {
- if (listConnectionsMode)
- return getConnections();
-
- if (subsystemAdapter == null)
- {
- return emptyList;
- }
-
- Object[] children = null;
-
- if (filterString == null)
- children = subsystemAdapter.getChildren((IAdaptable)subsystem, new NullProgressMonitor());
- else
- {
- children = resolveFilterString(subsystem, filterString);
- }
-
- return checkForEmptyList(children, null, true);
- }
-
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- */
- public boolean hasSystemViewRoots()
- {
- if (listConnectionsMode)
- return true;
- else
- {
- boolean hasroots = false;
- if (subsystemAdapter == null)
- hasroots = false;
- else if (filterString != null)
- hasroots = true;
- else
- hasroots = subsystemAdapter.hasChildren((IAdaptable)subsystem);
-
- return hasroots;
- }
- }
-
- /**
- * This method is called by the connection adapter when the user expands
- * a connection. This method must return the child objects to show for that
- * connection.
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- if (!listConnectionsMode)
- return null; // not applicable, never get called
- else
- {
- Object[] children = null;
- ISubSystem[] subsystems = getSubSystems(selectedConnection);
- ISubSystem subsystem = null;
-
- if ((subsystems != null) && (subsystems.length > 0))
- {
- subsystem = subsystems[0]; // always just use first. Hopefully never a problem!
-
- if (subsystems.length > 1)
- SystemBasePlugin.logWarning(this.getClass().getName() + ": More than one subsystem meeting criteria. SSFID = "+subsystemConfigurationId+", SSFCat = "+subsystemConfigurationCategory); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (quickFilters != null)
- {
- // DKM - quick filters are only work properly for first subsystem, so for now, I'm only
- // only going to use them for the initial subsystem
- //boolean useFilters = false;
-
- // Phil
- // 50167: re-using the same filter object for every connection causes
- // grief, so we have to clone the filter for each connection.
- if (multiConnections)
- {
- // walk through quick filters, and create a clone for each one
- children = new ISystemFilter[quickFilters.length];
-
- for (int idx=0; idx<quickFilters.length; idx++)
- {
- ISystemFilter quickFilter = quickFilters[idx];
- children[idx] = SystemFilterUtil.makeSimpleFilter(quickFilter.getName());
- quickFilter.clone((ISystemFilter)children[idx]);
- ((ISystemFilter)children[idx]).setSubSystem(subsystem);
- }
- }
-
- else
- {
- // walk through quickFilters and if they are transient, assign current subsystem as parent
- for (int idx=0; idx<quickFilters.length; idx++)
- {
- if ((quickFilters[idx].isTransient()))
- {
- quickFilters[idx].setSubSystem(subsystem);
- }
- }
-
- children = quickFilters;
- }
- }
-
- else if ((filterString == null) || (filterSuffix != null))
- {
- children = subsystem.getChildren();
- }
- else
- {
- children = resolveFilterString(subsystem, filterString);
- }
- }
-
- return checkForEmptyList(children, subsystem, true);
- }
- }
-
- /**
- * This method is called by the connection adapter when deciding to show a plus-sign
- * or not beside a connection. Return true if this connection has children to be shown.
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- return true;
- }
-
- /**
- * Return true if we are listing connections or not, so we know whether we are interested in
- * connection-add events
- */
- public boolean showingConnections()
- {
- return listConnectionsMode;
- }
-
-
- // ----------------------------------
- // OUR OWN METHODS...
- // ----------------------------------
-
- /**
- * Return the connections appropriate for our subsystem factory ID or category
- * requirements.
- */
- protected Object[] getConnections()
- {
- if (singleConnectionMode && !showNewConnectionPrompt)
- return inputConnections;
- if ((connPrompt == null) && showNewConnectionPrompt)
- {
- connPrompt = new SystemNewConnectionPromptObject();
- connPromptAsArray = new Object[1];
- connPromptAsArray[0] = connPrompt;
- }
- if ((connPrompt!=null) && (systemTypes != null))
- {
- connPrompt.setSystemTypes(systemTypes);
- }
-
- IHost[] conns = null;
-
- if (singleConnectionMode)
- conns = inputConnections;
- else if (systemTypes != null)
- conns = sr.getHostsBySystemTypes(systemTypes);
- else if (subsystemConfigurationId != null) {
- ISubSystemConfiguration config = sr.getSubSystemConfiguration(subsystemConfigurationId);
- conns = sr.getHostsBySubSystemConfiguration(config);
- }
- else if (subsystemConfigurationCategory != null)
- conns = sr.getHostsBySubSystemConfigurationCategory(subsystemConfigurationCategory);
- else
- conns = sr.getHosts();
-
- Object[] children = null;
-
- if (showNewConnectionPrompt)
- {
- if ((conns == null) || (conns.length == 0))
- children = connPromptAsArray;
- else
- {
- multiConnections = (conns.length>1); // 50167pc
- children = new Object[1+conns.length];
- children[0] = connPrompt;
- for (int idx=0; idx<conns.length; idx++)
- children[idx+1] = conns[idx];
- }
- }
- else
- {
- children = conns;
- multiConnections = ((conns!=null) && (conns.length>1)); // 50167pc
- }
-
- return checkForEmptyList(children, null, false);
- }
-
- /**
- * Given a connection, return the subsystem(s) appropriate for the given
- * subsystem configuration id or category
- */
- protected ISubSystem[] getSubSystems(IHost selectedConnection)
- {
- ISubSystem[] subsystems = null;
- if (subsystemConfigurationId != null) {
- ISubSystemConfiguration config = sr.getSubSystemConfiguration(subsystemConfigurationId);
- if (config==null)
- subsystems = new ISubSystem[0];
- else
- subsystems = config.getSubSystems(selectedConnection, true);
- }
- else if (subsystemConfigurationCategory != null) {
- subsystems = sr.getSubSystemsBySubSystemConfigurationCategory(subsystemConfigurationCategory, selectedConnection);
- }
- else
- subsystems = sr.getSubSystems(selectedConnection);
- return subsystems;
- }
-
- /**
- * Return the result of asking a given subsystem to resolve a filter string
- */
- protected Object[] resolveFilterString(ISubSystem subsystem, String filterString)
- {
- Object[] children = null;
- try
- {
- children = subsystem.resolveFilterString(filterString, new NullProgressMonitor());
- } catch (InterruptedException exc)
- {
- if (cancelledObject == null)
- children = getCancelledMessageObject();
- } catch (Exception exc)
- {
- children = getFailedMessageObject();
- SystemBasePlugin.logError("Error in SystemTestFilterStringAPIProviderImpl#getSystemViewRoots()",exc); //$NON-NLS-1$
- }
- return children;
- }
-
- /**
- * Returns the implementation of ISystemViewElement for the given
- * object. Returns null if the adapter is not defined or the
- * object is not adaptable.
- */
- protected ISystemViewElementAdapter getViewAdapter(Object o)
- {
- return SystemAdapterHelpers.getViewAdapter(o);
- }
-
- /**
- * Returns the implementation of ISystemRemoteElement for the given
- * object. Returns null if this object does not adaptable to this.
- */
- protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
- {
- return SystemAdapterHelpers.getRemoteAdapter(o);
- }
-
-
- /**
- * Prompt the user to create a new filter as a result of the user expanding a promptable
- * transient filter
- * <p>
- * Simply passes the request on to the caller.
- * <p>
- * NOT SUPPORTED YET!
- *
- * @return the filter created by the user or null if they cancelled the prompting
- */
- public ISystemFilter createFilterByPrompting(ISystemFilter filterPrompt, Shell shell)
- throws Exception
- {
- if (caller!=null)
- return caller.createFilterByPrompting(filterPrompt, shell);
- else
- return null;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeView.java
deleted file mode 100644
index 321df29dc..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeView.java
+++ /dev/null
@@ -1,2057 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Kevin Doyle (IBM) - [196582] ClassCastException when doing copy/paste with Search view open
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.SameShellProvider;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvent;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
-import org.eclipse.rse.core.events.ISystemRemoteChangeListener;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.internal.ui.SystemPropertyResources;
-import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonSelectAllAction;
-import org.eclipse.rse.internal.ui.actions.SystemOpenExplorerPerspectiveAction;
-import org.eclipse.rse.internal.ui.actions.SystemShowInTableAction;
-import org.eclipse.rse.internal.ui.actions.SystemSubMenuManager;
-import org.eclipse.rse.services.clientserver.StringCompare;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemDeleteTarget;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.ISystemRenameTarget;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.actions.ISystemAction;
-import org.eclipse.rse.ui.actions.SystemRefreshAction;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ContextObject;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.rse.ui.view.ISystemSelectAllTarget;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.part.EditorInputTransfer;
-import org.eclipse.ui.part.PluginTransfer;
-import org.eclipse.ui.progress.PendingUpdateAdapter;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-
-/**
- * This subclass of the standard JFace tabletree viewer is used to
- * show a generic tabletree view of the selected object
- * <p>
- *
- */
-public class SystemTableTreeView
- //FIXEM change TreeViewer to TableTreeViewer when Eclipse fixes SWT viewer
- //extends TableTreeViewer
- extends TreeViewer
- implements IMenuListener,
- ISystemDeleteTarget, ISystemRenameTarget, ISystemSelectAllTarget,
- ISystemResourceChangeListener, ISystemRemoteChangeListener,
- ISystemShellProvider, ISelectionChangedListener, ISelectionProvider
-{
-
- protected Composite getTableTree()
- {
- // TODO - turn back to table tree
- return getTree();
- }
-
- // TODO - turn back into tabletree
- // inner class to support cell editing - only use with table
- private ICellModifier cellModifier = new ICellModifier()
- {
- public Object getValue(Object element, String property)
- {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- adapter.setPropertySourceInput(element);
- Object value = adapter.getPropertyValue(property);
- if (value == null)
- {
- value = ""; //$NON-NLS-1$
- }
- return value;
- }
-
- public boolean canModify(Object element, String property)
- {
- boolean modifiable = true;
- return modifiable;
- }
-
- public void modify(Object element, String property, Object value)
- {
- if (element instanceof TableItem && value != null)
- {
- Object obj = ((TableItem) element).getData();
- ISystemViewElementAdapter adapter = getViewAdapter(obj);
- if (adapter != null)
- {
- adapter.setPropertyValue(property, value);
-
- SelectionChangedEvent event = new SelectionChangedEvent(SystemTableTreeView.this, getSelection());
-
- // fire the event
- fireSelectionChanged(event);
- }
- }
- }
- };
-
- private class HeaderSelectionListener extends SelectionAdapter
- {
-
- public HeaderSelectionListener()
- {
- _upI = RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_MOVEUP_ID);
- _downI = RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_MOVEDOWN_ID);
- }
-
-
- /**
- * Handles the case of user selecting the
- * header area.
- * <p>If the column has not been selected previously,
- * it will set the sorter of that column to be
- * the current table view sorter. Repeated
- * presses on the same column header will
- * toggle sorting order (ascending/descending).
- */
- public void widgetSelected(SelectionEvent e)
- {
- Tree table = getTree();
- if (!table.isDisposed())
- {
- // column selected - need to sort
- TreeColumn tcolumn = (TreeColumn)e.widget;
- int column = table.indexOf(tcolumn);
- SystemTableViewSorter oldSorter = (SystemTableViewSorter) getSorter();
- if (oldSorter != null && column == oldSorter.getColumnNumber())
- {
- oldSorter.setReversed(!oldSorter.isReversed());
- if (tcolumn.getImage() == _upI)
- {
- tcolumn.setImage(_downI);
- }
- else
- {
- tcolumn.setImage(_upI);
- }
- }
- else
- {
- setSorter(new SystemTableViewSorter(column, SystemTableTreeView.this, _columnManager));
- tcolumn.setImage(_downI);
- }
-
- // unset image of other columns
- TreeColumn[] allColumns = table.getColumns();
- for (int i = 0; i < allColumns.length; i++)
- {
- if (i != column)
- {
- if (allColumns[i].getImage() != null)
- {
- allColumns[i].setImage(null);
- }
- }
- }
- refresh();
- }
- }
- }
- private Object _objectInput;
- //private ArrayList _attributeColumns;
- private TableLayout _layout;
- protected SystemTableTreeViewProvider _provider;
- private HeaderSelectionListener _columnSelectionListener;
- private SystemTableViewColumnManager _columnManager;
- private MenuManager _menuManager;
- private int _charWidth = 3;
- private SystemTableViewFilter _filter;
- private IPropertyDescriptor[] _uniqueDescriptors;
-
- // these variables were copied from SystemView to allow for limited support
- // of actions. I say limited because somethings don't yet work properly.
- protected SystemRefreshAction _refreshAction;
- protected PropertyDialogAction _propertyDialogAction;
- protected SystemOpenExplorerPerspectiveAction _openToPerspectiveAction;
- protected SystemShowInTableAction _showInTableAction;
-
- // global actions
- // Note the Edit menu actions are set in SystemViewPart. Here we use these
- // actions from our own popup menu actions.
- protected SystemCommonDeleteAction _deleteAction;
- // for global delete menu item
- protected SystemCommonRenameAction _renameAction;
- // for common rename menu item
- protected SystemCommonSelectAllAction _selectAllAction;
- // for common Ctrl+A select-all
-
- protected boolean _selectionShowRefreshAction;
- protected boolean _selectionShowOpenViewActions;
- protected boolean _selectionShowDeleteAction;
- protected boolean _selectionShowRenameAction;
- protected boolean _selectionEnableDeleteAction;
- protected boolean _selectionEnableRenameAction;
-
- protected boolean _selectionIsRemoteObject = true;
- protected boolean _selectionFlagsUpdated = false;
-
- private int[] _lastWidths = null;
- private ISystemMessageLine _messageLine;
- protected boolean menuListenerAdded = false;
-
-
- private static final int LEFT_BUTTON = 1;
- private int mouseButtonPressed = LEFT_BUTTON;
-
- private Image _upI;
- private Image _downI;
-
-
- /**
- * Constructor for the table view
- *
- */
- public SystemTableTreeView(Tree tableTree, ISystemMessageLine msgLine)
- {
- super(tableTree);
- _messageLine = msgLine;
- //_attributeColumns = new ArrayList();
- _layout = new TableLayout();
-
- _columnManager = new SystemTableViewColumnManager(this);
- _provider = new SystemTableTreeViewProvider(_columnManager);
- _columnSelectionListener = new HeaderSelectionListener();
-
-
- setContentProvider(_provider);
- setLabelProvider(_provider);
-
- _filter = new SystemTableViewFilter();
- addFilter(_filter);
-
- _charWidth = tableTree.getFont().getFontData()[0].getHeight() / 2;
- computeLayout();
-
- _menuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- _menuManager.setRemoveAllWhenShown(true);
- _menuManager.addMenuListener(this);
- Menu menu = _menuManager.createContextMenu(tableTree);
- tableTree.setMenu(menu);
-
- addSelectionChangedListener(this);
-
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.addSystemResourceChangeListener(this);
- sr.addSystemRemoteChangeListener(this);
-
- initDragAndDrop();
-
- tableTree.setVisible(false);
- // key listening for delete press
- getControl().addKeyListener(new KeyAdapter()
- {
- public void keyPressed(KeyEvent e)
- {
- handleKeyPressed(e);
- }
- });
- getControl().addMouseListener(new MouseAdapter()
- {
- public void mouseDown(MouseEvent e)
- {
- mouseButtonPressed = e.button; //d40615
- }
- });
- }
-
- public Layout getLayout()
- {
- return _layout;
- }
-
-
- public void setViewFilters(String[] filter)
- {
- if (_filter.getFilters() != filter)
- {
- _filter.setFilters(filter);
- refresh();
- }
- }
-
- public String[] getViewFilters()
- {
- return _filter.getFilters();
- }
-
- /**
- * Return the popup menu for the table
- */
- public Menu getContextMenu()
- {
- return getTableTree().getMenu();
- }
- /**
- * Return the popup menu for the table
- */
- public MenuManager getContextMenuManager()
- {
- return _menuManager;
- }
-
- /**
- * Called whenever the input for the view changes
- */
- public void inputChanged(Object newObject, Object oldObject)
- {
- if (newObject instanceof IAdaptable)
- {
- getTableTree().setVisible(true);
- _objectInput = newObject;
-
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
- provider.getChildren(_objectInput);
-
- computeLayout();
-
- // reset the filter
- setViewFilters(null);
-
- super.inputChanged(newObject, oldObject);
-
- }
- else if (newObject == null)
- {
- getTableTree().setVisible(false);
- _objectInput = null;
- computeLayout();
-
- setViewFilters(null);
- }
- }
-
- public Object getInput()
- {
- return _objectInput;
- }
-
- /**
- * Convenience method for retrieving the view adapter for an object
- */
- protected ISystemViewElementAdapter getViewAdapter(Object obj)
- {
- return SystemAdapterHelpers.getViewAdapter(obj, this);
- }
-
- public SystemTableViewColumnManager getColumnManager()
- {
- return _columnManager;
- }
-
- private IPropertyDescriptor[] getCustomDescriptors(ISystemViewElementAdapter adapter)
- {
- return _columnManager.getVisibleDescriptors(adapter);
- }
-
- public IPropertyDescriptor[] getUniqueDescriptors()
- {
- return _uniqueDescriptors;
- }
-
- /**
- * Used to determine what the columns should be on the table.
- */
- public IPropertyDescriptor[] getVisibleDescriptors(Object object)
- {
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
- Object[] children = provider.getChildren(object);
- return getVisibleDescriptors(children);
- }
-
- private IPropertyDescriptor[] getVisibleDescriptors(Object[] children)
- {
- if (children != null && children.length > 0)
- {
- IAdaptable child = (IAdaptable) children[0];
- ISystemViewElementAdapter adapter = getViewAdapter(child);
- adapter.setPropertySourceInput(child);
- return getCustomDescriptors(adapter);
- }
-
- return new IPropertyDescriptor[0];
- }
-
-
-
- public IPropertyDescriptor getNameDescriptor(Object object)
- {
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
- Object[] children = provider.getChildren(object);
- return getNameDescriptor(children);
- }
-
- private IPropertyDescriptor getNameDescriptor(Object[] children)
- {
- if (children != null && children.length > 0)
- {
- IAdaptable child = (IAdaptable) children[0];
- return getViewAdapter(child).getPropertyDescriptors()[0];
- }
-
- return null;
- }
-
- /**
- * Used to determine the formats of each descriptor.
- */
- private ArrayList getFormatsIn()
- {
- ArrayList results = new ArrayList();
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
- Object[] children = provider.getChildren(_objectInput);
-
- if (children != null && children.length > 0)
- {
- IAdaptable child = (IAdaptable) children[0];
-
- Object adapter = child.getAdapter(ISystemViewElementAdapter.class);
- if (adapter instanceof ISystemViewElementAdapter)
- {
- ISystemViewElementAdapter ad = (ISystemViewElementAdapter) adapter;
- ad.setPropertySourceInput(child);
- IPropertyDescriptor[] descriptors = ad.getUniquePropertyDescriptors();
- for (int i = 0; i < descriptors.length; i++)
- {
- IPropertyDescriptor descriptor = descriptors[i];
-
- try
- {
- Object key = descriptor.getId();
-
- Object propertyValue = ad.getPropertyValue(key, false);
- results.add(propertyValue.getClass());
- }
- catch (Exception e)
- {
- results.add(String.class);
- }
-
- }
- }
- }
-
- return results;
- }
- protected void computeLayout()
- {
- computeLayout(false);
- }
-
- private boolean sameDescriptors(IPropertyDescriptor[] descriptors1, IPropertyDescriptor[] descriptors2)
- {
- if (descriptors1 == null || descriptors2 == null)
- {
- return false;
- }
- if (descriptors1.length == descriptors2.length)
- {
- boolean same = true;
- for (int i = 0; i < descriptors1.length && same; i++)
- {
- same = descriptors1[i] == descriptors2[i];
- }
- return same;
- }
- else
- {
- return false;
- }
- }
-
- private CellEditor getCellEditor(Tree parent, IPropertyDescriptor descriptor)
- {
- CellEditor editor = descriptor.createPropertyEditor(parent);
- if (editor instanceof SystemInheritableTextCellEditor)
- {
- ((SystemInheritableTextCellEditor) editor).getInheritableEntryField().setAllowEditingOfInheritedText(true);
- }
-
- return editor;
- }
-
- /**
- * Determines what columns should be shown in this view. The columns may change
- * anytime the view input changes. The columns in the control are modified and
- * columns may be added or deleted as necessary to make it conform to the
- * new data.
- */
- public void computeLayout(boolean force)
- {
- if (_objectInput == null)
- return;
-
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
- if (provider == null)
- return;
- Object[] children = provider.getChildren(_objectInput);
-
- // if no children, don't update
- if (children == null || children.length == 0 || (children.length == 1 && children[0] instanceof PendingUpdateAdapter))
- {
- return;
- }
-
- IPropertyDescriptor[] descriptors = getVisibleDescriptors(children);
- IPropertyDescriptor nameDescriptor = getNameDescriptor(children);
-
- int n = descriptors.length; // number of columns we need (name column + other columns)
- if (nameDescriptor != null)
- n += 1;
- if (n == 0)
- return; // there is nothing to lay out!
-
-
- if (sameDescriptors(descriptors,_uniqueDescriptors) && !force)
- {
- setLastColumnWidths(getCurrentColumnWidths());
- return;
- }
- _uniqueDescriptors = descriptors;
- Tree tree = getTree();
- if (tree == null || tree.isDisposed())
- return;
-
- // set column attributes, create new columns if necessary
- TreeColumn[] columns = tree.getColumns();
- int numColumns = columns.length; // number of columns in the control
- CellEditor editors[] = new CellEditor[n];
- String headings[] = new String[n];
- String propertyIds[] = new String[n];
- ArrayList formats = getFormatsIn();
-
-
- _layout = new TableLayout();
- for (int i = 0; i < n; i++)
- { // for each column
- String name = null;
- String propertyId = null;
- CellEditor editor = null;
- int alignment = SWT.LEFT;
- int weight = 100;
- if (i == 0)
- {
- // this is the first column -- treat it special
- name = SystemPropertyResources.RESID_PROPERTY_NAME_LABEL;
- if (nameDescriptor != null)
- {
- propertyId = (String) nameDescriptor.getId();
- editor = getCellEditor(tree, nameDescriptor);
- weight = 200;
- }
- }
- else
- { // these columns come from the regular descriptors
- IPropertyDescriptor descriptor = descriptors[i - 1];
-
- Class format = (Class) formats.get(i - 1);
- name = descriptor.getDisplayName();
- propertyId = (String) descriptor.getId();
- editor = getCellEditor(tree, descriptor);
- if (format != String.class)
- alignment = SWT.RIGHT;
- }
- TreeColumn tc = null;
- if (i >= numColumns)
- {
- tc = new TreeColumn(tree, alignment, i);
- tc.addSelectionListener(_columnSelectionListener);
-
- }
- else
- {
- tc = columns[i];
- tc.setAlignment(alignment);
- }
- _layout.addColumnData(new ColumnWeightData(weight));
- tc.setText(name);
- if (i == 0)
- {
- // tc.setImage(_downI);
- }
- headings[i] = name;
- editors[i] = editor;
- propertyIds[i] = propertyId;
- }
- setColumnProperties(propertyIds);
- setCellEditors(editors);
- setCellModifier(cellModifier);
-
- // dispose of any extra columns the tree control may have
- for (int i = n; i < numColumns; i++)
- {
- columns[i].dispose();
- columns[i] = null;
- }
-
- // compute column widths
- columns = tree.getColumns();
- numColumns = columns.length;
- Rectangle clientA = tree.getClientArea();
- int totalWidth = clientA.width - 5;
- if (totalWidth <= 0)
- {
- // find a default
- totalWidth = 500;
- }
-
-
- int[] lastWidths = getLastColumnWidths();
- if (numColumns > 1)
- {
- // check if previous widths can be used
- if (lastWidths != null && lastWidths.length == numColumns)
- {
-
- // use previously established widths
- setCurrentColumnWidths(lastWidths);
- }
- else
- {
- if (totalWidth > 0)
- {
- // no previous widths or number of columns has changed - need to calculate
- int averageWidth = totalWidth / numColumns;
- int firstWidth = Math.max(averageWidth, 150);
- averageWidth = (totalWidth - firstWidth) / (numColumns - 1);
- averageWidth = Math.max(averageWidth, 80);
- columns[0].setWidth(firstWidth);
- for (int i = 1; i < numColumns; i++)
- {
-
- columns[i].setWidth(averageWidth);
- }
- setLastColumnWidths(getCurrentColumnWidths());
- }
- }
- tree.setHeaderVisible(true);
- }
- else
- {
-
- if (numColumns == 1)
- {
- int width = totalWidth;
- if (lastWidths != null && lastWidths.length == 1)
- {
- width = (totalWidth > lastWidths[0]) ? totalWidth : lastWidths[0];
- }
-
-
- int maxWidth = provider.getMaxCharsInColumnZero() * _charWidth;
- if (maxWidth > width)
- {
- width = maxWidth;
- }
-
- if (width > 0)
- {
- columns[0].setWidth(width);
- }
- tree.setHeaderVisible(false);
- }
- }
- }
-
- public int[] getCurrentColumnWidths()
- {
- return new int[0];
- }
-
- public void setCurrentColumnWidths(int[] widths)
- {
- }
-
- public int[] getLastColumnWidths()
- {
- return _lastWidths;
- }
-
- public void setLastColumnWidths(int[] widths)
- {
- _lastWidths = widths;
- }
-
-
- protected void initDragAndDrop()
- {
- int ops = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] dragtransfers = new Transfer[] { PluginTransfer.getInstance(), TextTransfer.getInstance(), FileTransfer.getInstance(), EditorInputTransfer.getInstance()};
- Transfer[] droptransfers = new Transfer[] { PluginTransfer.getInstance(), TextTransfer.getInstance(), FileTransfer.getInstance(), EditorInputTransfer.getInstance()};
-
- addDragSupport(ops, dragtransfers, new SystemViewDataDragAdapter(this));
- addDropSupport(ops | DND.DROP_DEFAULT, droptransfers, new SystemViewDataDropAdapter(this));
- }
- /**
- * Used to asynchronously update the view whenever properties change.
- */
- public void systemResourceChanged(ISystemResourceChangeEvent event)
- {
- try
- {
- Tree tree = getTree();
- boolean isDisposed = tree.isDisposed();
- if (isDisposed)
- {
- dispose();
- return;
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- boolean madeChange = false;
- Object parent = event.getParent();
- Object child = event.getSource();
- int eventType = event.getType();
- switch (eventType)
- {
- case ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE :
- case ISystemResourceChangeEvents.EVENT_PROPERTYSHEET_UPDATE :
- {
- Widget w = findItem(child);
-
- if (w != null)
- {
- updateItem(w, child);
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_ADD :
- case ISystemResourceChangeEvents.EVENT_ADD_RELATIVE :
- {
- boolean addingConnection = (child instanceof IHost);
- if (_objectInput instanceof ISystemRegistry && addingConnection)
- {
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
-
- if (provider != null)
- {
- if (!madeChange)
- {
- provider.flushCache();
- madeChange = true;
- }
-
- computeLayout();
- internalRefresh(_objectInput);
- }
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_REFRESH:
- {
- Widget w = findItem(parent);
- if (w != null)
- {
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
- if (!madeChange)
- {
- provider.flushCache();
- madeChange = true;
- }
- internalRefresh(parent);
- }
- }
- break;
- default :
- break;
-
- }
-
- if (child == _objectInput || parent == _objectInput)
- {
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
-
- if (provider != null)
- {
- if (!madeChange)
- {
- //provider.flushCache();
- madeChange = true;
- }
-
- computeLayout();
- try
- {
- internalRefresh(_objectInput);
- }
- catch (Exception e)
- {
- SystemBasePlugin.logError(e.getMessage());
- }
- }
- }
- }
-
- /**
- * 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.
- * @see org.eclipse.rse.core.events.ISystemRemoteChangeEvent
- */
- public void systemRemoteResourceChanged(ISystemRemoteChangeEvent event)
- {
- boolean madeChange = false;
- int eventType = event.getEventType();
- Object remoteResourceParent = event.getResourceParent();
- Object remoteResource = event.getResource();
- //boolean originatedHere = (event.getOriginatingViewer() == this);
- List remoteResourceNames = null;
- if (remoteResource instanceof List)
- {
- remoteResourceNames = (List) remoteResource;
- remoteResource = remoteResourceNames.get(0);
- }
- String remoteResourceParentName = getRemoteResourceAbsoluteName(remoteResourceParent);
- String remoteResourceName = getRemoteResourceAbsoluteName(remoteResource);
- if (remoteResourceName == null)
- return;
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
-
- switch (eventType)
- {
- // --------------------------
- // REMOTE RESOURCE CHANGED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CHANGED :
- {
- if (remoteResourceParent == getInput())
- {
- Widget w = findItem(remoteResource);
- if (w != null)
- {
- updateItem(w, remoteResource);
- }
-
- }
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE CREATED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED :
- {
- String inputResourceName = getRemoteResourceAbsoluteName(getInput());
- if (remoteResourceParentName != null && remoteResourceParentName.equals(inputResourceName))
- {
- if (provider == null)
- {
- return;
- }
- if (!madeChange)
- {
- provider.flushCache();
- madeChange = true;
- }
-
- refresh();
- }
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE DELETED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED :
- {
- {
- Object dchild = remoteResource;
-
- ISystemViewElementAdapter dadapt = getViewAdapter(dchild);
- if (dadapt != null)
- {
- ISubSystem dSubSystem = dadapt.getSubSystem(dchild);
- String dkey = dadapt.getAbsoluteName(dchild);
-
- if (provider != null)
- {
- Object[] children = provider.getChildren(_objectInput);
- for (int i = 0; i < children.length; i++)
- {
- Object existingChild = children[i];
- if (existingChild != null)
- {
- ISystemViewElementAdapter eadapt = getViewAdapter(existingChild);
- ISubSystem eSubSystem = eadapt.getSubSystem(existingChild);
-
- if (dSubSystem == eSubSystem)
- {
- String ekey = eadapt.getAbsoluteName(existingChild);
- if (ekey.equals(dkey))
- {
- if (!madeChange)
- {
- provider.flushCache();
- madeChange = true;
-
- // do a full refresh
- refresh();
- }
- }
- }
-
- }
- }
- }
- }
- }
-
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE RENAMED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED :
- {
- String oldName = event.getOldNames()[0]; // right now we're assuming that a rename event is for a single resource
- Object child = event.getResource();
-
- if (provider != null)
- {
- Object[] previousResults = provider.getCache();
- if (previousResults != null)
- {
- for (int i = 0; i < previousResults.length; i++)
- {
- Object previousResult = previousResults[i];
-
- if (previousResult == child)
- {
- Widget widget = findItem(previousResult);
- if (widget != null)
- {
- widget.setData(child);
- updateItem(widget, child);
- return;
- }
- }
- else
- {
- String previousName = getViewAdapter(previousResult).getAbsoluteName(previousResult);
-
- if (previousName != null && previousName.equals(oldName))
- {
- provider.flushCache();
- internalRefresh(_objectInput);
- return;
- }
- }
- }
-
- }
- }
- }
-
- break;
- }
- }
-
- /**
- * Turn a given remote object reference into a fully qualified absolute name
- */
- private String getRemoteResourceAbsoluteName(Object remoteResource)
- {
- if (remoteResource == null)
- return null;
- String remoteResourceName = null;
- if (remoteResource instanceof String)
- remoteResourceName = (String) remoteResource;
- else
- {
- ISystemViewElementAdapter ra = getViewAdapter(remoteResource);
- if (ra == null)
- return null;
- remoteResourceName = ra.getAbsoluteName(remoteResource);
- }
- return remoteResourceName;
- }
-
- public void selectionChanged(SelectionChangedEvent event)
- {
- _selectionFlagsUpdated = false;
- IStructuredSelection sel = (IStructuredSelection)event.getSelection();
- Object firstSelection = sel.getFirstElement();
- if (firstSelection == null)
- return;
-
- _selectionFlagsUpdated = false;
- ISystemViewElementAdapter adapter = getViewAdapter(firstSelection);
- if (adapter != null)
- {
- displayMessage(adapter.getStatusLineText(firstSelection));
- if ((mouseButtonPressed == LEFT_BUTTON))
- adapter.selectionChanged(firstSelection);
- }
- else
- clearMessage();
- }
-
- public void dispose()
- {
- removeAsListener();
-
- Composite tree = getTableTree();
-
- boolean isDisposed = tree.isDisposed();
-
- // dispose control if not disposed
- if (!isDisposed) {
- tree.dispose();
- }
- }
-
- /**
- * Display a message/status on the message/status line
- */
- public void displayMessage(String msg)
- {
- if (_messageLine != null)
- _messageLine.setMessage(msg);
- }
-
- /**
- * Convenience method for retrieving the view adapter for an object's children
- */
- public ISystemViewElementAdapter getViewAdapterForContents()
- {
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider) getContentProvider();
- if (provider != null)
- {
- Object[] children = provider.getChildren(getInput());
- if (children != null && children.length > 0)
- {
- IAdaptable child = (IAdaptable) children[0];
- return getViewAdapter(child);
- }
- }
- return null;
- }
-
- /**
- * Clear message/status shown on the message/status line
- */
- public void clearMessage()
- {
- if (_messageLine != null)
- _messageLine.clearMessage();
- }
-
- /**
- * Remove as listener.
- */
- public void removeAsListener() {
-
- // remove listeners
- removeSelectionChangedListener(this);
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.removeSystemResourceChangeListener(this);
- sr.removeSystemRemoteChangeListener(this);
-
- // for debugging
- //Composite tree = getTableTree();
- //boolean isDisposed = tree.isDisposed();
- }
-
-
-
- /**
- * Rather than pre-defining this common action we wait until it is first needed,
- * for performance reasons.
- */
- protected PropertyDialogAction getPropertyDialogAction()
- {
- if (_propertyDialogAction == null)
- {
- _propertyDialogAction = new PropertyDialogAction(new SameShellProvider(getShell()), this);
- //propertyDialogAction.setToolTipText(" ");
- }
- _propertyDialogAction.selectionChanged(getSelection());
- return _propertyDialogAction;
- }
-
- /**
- * Return the select All action
- */
- protected IAction getSelectAllAction()
- {
- if (_selectAllAction == null)
- _selectAllAction = new SystemCommonSelectAllAction(getShell(), this, this);
- return _selectAllAction;
- }
-
- /**
- * Rather than pre-defined this common action we wait until it is first needed,
- * for performance reasons.
- */
- protected IAction getRenameAction()
- {
- if (_renameAction == null)
- _renameAction = new SystemCommonRenameAction(getShell(), this);
- return _renameAction;
- }
- /**
- * Rather than pre-defined this common action we wait until it is first needed,
- * for performance reasons.
- */
- protected IAction getDeleteAction()
- {
- if (_deleteAction == null)
- _deleteAction = new SystemCommonDeleteAction(getShell(), this);
- return _deleteAction;
- }
-
- /**
- * Return the refresh action
- */
- protected IAction getRefreshAction()
- {
- if (_refreshAction == null)
- _refreshAction = new SystemRefreshAction(getShell());
- return _refreshAction;
- }
- /*
- * Get the common "Open to->" action for opening a new Remote System Explorer view,
- * scoped to the currently selected object.
- *
- protected SystemCascadingOpenToAction getOpenToAction()
- {
- if (openToAction == null)
- openToAction = new SystemCascadingOpenToAction(getShell(),getWorkbenchWindow());
- return openToAction;
- } NOT USED YET */
- /**
- * Get the common "Open to->" action for opening a new Remote System Explorer view,
- * scoped to the currently selected object.
- */
- protected SystemOpenExplorerPerspectiveAction getOpenToPerspectiveAction()
- {
- if (_openToPerspectiveAction == null)
- {
- IWorkbench desktop = PlatformUI.getWorkbench();
- IWorkbenchWindow win = desktop.getActiveWorkbenchWindow();
-
- _openToPerspectiveAction = new SystemOpenExplorerPerspectiveAction(getShell(), win);
- }
- //getWorkbenchWindow());
- return _openToPerspectiveAction;
- }
-
- protected SystemShowInTableAction getShowInTableAction()
- {
- if (_showInTableAction == null)
- {
- _showInTableAction = new SystemShowInTableAction(getShell());
- }
- //getWorkbenchWindow());
- return _showInTableAction;
- }
-
- public Shell getShell()
- {
- return getTableTree().getShell();
- }
-
- /**
- * Required method from ISystemDeleteTarget.
- * Decides whether to even show the delete menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean showDelete()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionShowDeleteAction;
- }
- /**
- * Required method from ISystemDeleteTarget
- * Decides whether to enable the delete menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean canDelete()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionEnableDeleteAction;
- }
-
- /*
- * Required method from ISystemDeleteTarget
- */
- public boolean doDelete(IProgressMonitor monitor)
- {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
- //int selectedCount = selection.size();
- //Object multiSource[] = new Object[selectedCount];
- //int idx = 0;
- Object element = null;
- //Object parentElement = getSelectedParent();
- ISystemViewElementAdapter adapter = null;
- boolean ok = true;
- boolean anyOk = false;
- Vector deletedVector = new Vector();
- try
- {
- while (ok && elements.hasNext())
- {
- element = elements.next();
- //multiSource[idx++] = element;
- adapter = getViewAdapter(element);
- ok = adapter.doDelete(getShell(), element, monitor);
- if (ok)
- {
- anyOk = true;
- deletedVector.addElement(element);
- }
- }
- }
- catch (SystemMessageException exc)
- {
- SystemMessageDialog.displayErrorMessage(getShell(), exc.getSystemMessage());
- ok = false;
- }
- catch (Exception exc)
- {
- 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));
- ok = false;
- }
- if (anyOk)
- {
- Object[] deleted = new Object[deletedVector.size()];
- for (int idx = 0; idx < deleted.length; idx++)
- deleted[idx] = deletedVector.elementAt(idx);
- if (_selectionIsRemoteObject)
- sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED, deletedVector, null, null, null, this);
- else
- sr.fireEvent(new org.eclipse.rse.core.events.SystemResourceChangeEvent(deleted, ISystemResourceChangeEvents.EVENT_DELETE_MANY, getInput()));
- }
- return ok;
- }
-
- // ---------------------------
- // ISYSTEMRENAMETARGET METHODS
- // ---------------------------
-
- /**
- * Required method from ISystemRenameTarget.
- * Decides whether to even show the rename menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean showRename()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionShowRenameAction;
- }
- /**
- * Required method from ISystemRenameTarget
- * Decides whether to enable the rename menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean canRename()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionEnableRenameAction;
- }
-
- // default implementation
- // in default table, parent is input
- protected Object getParentForContent(Object element)
- {
- return _objectInput;
- }
-
- /**
- * Required method from ISystemRenameTarget
- */
- public boolean doRename(String[] newNames)
- {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
- //int selectedCount = selection.size();
- Object element = null;
-
- ISystemViewElementAdapter adapter = null;
- ISystemRemoteElementAdapter remoteAdapter = null;
- String oldFullName = null;
- boolean ok = true;
- try
- {
- int nameIdx = 0;
- while (ok && elements.hasNext())
- {
- element = elements.next();
- adapter = getViewAdapter(element);
- Object parentElement = getParentForContent(element);
-
- remoteAdapter = getRemoteAdapter(element);
- if (remoteAdapter != null)
- oldFullName = remoteAdapter.getAbsoluteName(element);
- // pre-rename
- ok = adapter.doRename(getShell(), element, newNames[nameIdx++], null);
- if (ok)
- {
- if (remoteAdapter != null) {
- sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED, element, parentElement, remoteAdapter.getSubSystem(element), new String[]{oldFullName}, this);
- }
- else {
- sr.fireEvent(new org.eclipse.rse.core.events.SystemResourceChangeEvent(element, ISystemResourceChangeEvents.EVENT_RENAME, parentElement));
- }
- }
- }
- }
- catch (SystemMessageException exc)
- {
- SystemMessageDialog.displayErrorMessage(getShell(), exc.getSystemMessage());
- ok = false;
- }
- catch (Exception exc)
- {
- //String msg = exc.getMessage();
- //if ((msg == null) || (exc instanceof ClassCastException))
- // msg = exc.getClass().getName();
- SystemMessageDialog.displayErrorMessage(getShell(), RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_RENAMING).makeSubstitution(element, exc),
- //msg),
- exc);
- ok = false;
- }
- return ok;
- }
-
- /**
- * Returns the implementation of ISystemRemoteElementAdapter for the given
- * object. Returns null if this object is not adaptable to this.
- */
- protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
- {
- ISystemRemoteElementAdapter adapter = null;
- if (!(o instanceof IAdaptable))
- adapter = (ISystemRemoteElementAdapter) Platform.getAdapterManager().getAdapter(o, ISystemRemoteElementAdapter.class);
- else
- adapter = (ISystemRemoteElementAdapter) ((IAdaptable) o).getAdapter(ISystemRemoteElementAdapter.class);
- if ((adapter != null) && (adapter instanceof ISystemViewElementAdapter))
- ((ISystemViewElementAdapter) adapter).setViewer(this);
- return adapter;
- }
-
- /**
- * Returns the implementation of IRemoteObjectIdentifier for the given
- * object. Returns null if this object is not adaptable to this.
- *
- * @deprecated should use {@link #getViewAdapter(Object)} since
- * IRemoteObjectIdentifier is not defined in the adapter factories
- */
- protected IRemoteObjectIdentifier getRemoteObjectIdentifier(Object o)
- {
- return (IRemoteObjectIdentifier)((IAdaptable)o).getAdapter(IRemoteObjectIdentifier.class);
- }
-
- /**
- * Return true if select all should be enabled for the given object.
- * For a tree view, you should return true if and only if the selected object has children.
- * You can use the passed in selection or ignore it and query your own selection.
- */
- public boolean enableSelectAll(IStructuredSelection selection)
- {
- return true;
- }
- /**
- * 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
- * of the given selected object. You can use the passed in selected object
- * or ignore it and query the selected object yourself.
- */
- public void doSelectAll(IStructuredSelection selection)
- {
-
- Composite tree = getTableTree();
-
- Tree theTree = (Tree) tree;
- theTree.setSelection(theTree.getItems());
- TreeItem[] items = theTree.getItems();
- Object[] objects = new Object[items.length];
- for (int idx = 0; idx < items.length; idx++)
- objects[idx] = items[idx].getData();
- fireSelectionChanged(new SelectionChangedEvent(this, new StructuredSelection(objects)));
-
- }
-
- public void menuAboutToShow(IMenuManager manager)
- {
- SystemView.createStandardGroups(manager);
-
- if (!menuListenerAdded)
- {
- if (manager instanceof MenuManager)
- {
- Menu m = ((MenuManager)manager).getMenu();
- if (m != null)
- {
- menuListenerAdded = true;
- SystemViewMenuListener ml = new SystemViewMenuListener();
- if (_messageLine != null)
- ml.setShowToolTipText(true, _messageLine);
- m.addMenuListener(ml);
- }
- }
- }
- fillContextMenu(manager);
- }
-
- public ISelection getSelection()
- {
- ISelection selection = super.getSelection();
- if (selection == null || selection.isEmpty())
- {
- // make the selection the parent
- ArrayList list = new ArrayList();
- if (_objectInput != null)
- {
- list.add(_objectInput);
- selection = new StructuredSelection(list);
- }
- }
-
- return selection;
- }
-
- public void fillContextMenu(IMenuManager menu) {
-
- IStructuredSelection selection = (IStructuredSelection) getSelection();
-
- boolean allSelectionsFromSameParent = true;
- int selectionCount = selection.size();
-
-
-
- if (selectionCount == 0) // nothing selected
- {
- return;
- }
- else
- {
-
- if (selectionCount == 1) {
-
- if (selection.getFirstElement() == getInput()) {
- //return;
- }
- }
-
- if (selectionCount > 1)
- {
- allSelectionsFromSameParent = sameParent();
-
- if (!allSelectionsFromSameParent)
- {
- if (selectionHasAncestryRelationship())
- {
- // don't show the menu because actions with
- // multiple select on objects that are ancestors
- // of each other is problematic
- // still create the standard groups
- SystemView.createStandardGroups(menu);
- return;
- }
- }
- }
-
- // Partition into groups...
- SystemView.createStandardGroups(menu);
-
- // ADD COMMON ACTIONS...
-
- // COMMON RENAME ACTION...
- if (canRename())
- {
- if (showRename())
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_REORGANIZE, getRenameAction());
- }
-
- // ADAPTER SPECIFIC ACTIONS
- SystemMenuManager ourMenu = new SystemMenuManager(menu);
-
- Iterator elements = selection.iterator();
- Hashtable adapters = new Hashtable();
- while (elements.hasNext())
- {
- Object element = elements.next();
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- adapters.put(adapter, element); // want only unique adapters
- }
- Enumeration uniqueAdapters = adapters.keys();
- Shell shell = getShell();
- while (uniqueAdapters.hasMoreElements())
- {
- ISystemViewElementAdapter nextAdapter = (ISystemViewElementAdapter) uniqueAdapters.nextElement();
- nextAdapter.addActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADAPTERS);
-
- if (nextAdapter instanceof AbstractSystemViewAdapter)
- {
-
- AbstractSystemViewAdapter aVA = (AbstractSystemViewAdapter)nextAdapter;
- // add remote actions
- aVA.addCommonRemoteActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADAPTERS);
-
- // add dynamic menu popups
- aVA.addDynamicPopupMenuActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADDITIONS);
- }
- }
-
- // wail through all actions, updating shell and selection
- IContributionItem[] items = menu.getItems();
- for (int idx = 0; idx < items.length; idx++)
- {
- if ((items[idx] instanceof ActionContributionItem) && (((ActionContributionItem) items[idx]).getAction() instanceof ISystemAction))
- {
- ISystemAction item = (ISystemAction) (((ActionContributionItem) items[idx]).getAction());
- item.setInputs(getShell(), this, selection);
- }
- else if (items[idx] instanceof SystemSubMenuManager)
- {
- SystemSubMenuManager item = (SystemSubMenuManager) items[idx];
- item.setInputs(getShell(), this, selection);
- }
- }
-
- // COMMON DELETE ACTION...
- if (canDelete() && showDelete())
- {
- //menu.add(getDeleteAction());
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_REORGANIZE, getDeleteAction());
- ((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 pdAction = getPropertyDialogAction();
- if (pdAction.isApplicableForSelection())
- {
-
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_PROPERTIES, pdAction);
- }
- // OPEN IN NEW PERSPECTIVE ACTION... if (fromSystemViewPart && showOpenViewActions())
- if (!_selectionIsRemoteObject)
- {
- //SystemCascadingOpenToAction openToAction = getOpenToAction();
- SystemOpenExplorerPerspectiveAction openToPerspectiveAction = getOpenToPerspectiveAction();
- SystemShowInTableAction showInTableAction = getShowInTableAction();
- openToPerspectiveAction.setSelection(selection);
- showInTableAction.setSelection(selection);
- //menu.appendToGroup(ISystemContextMenuConstants.GROUP_OPEN, openToAction.getSubMenu());
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_OPEN, openToPerspectiveAction);
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_OPEN, showInTableAction);
-
- }
-
-
- }
- }
-
- /**
- * 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.
- * <p>
- * Designed to be as fast as possible by going directly to the SWT widgets
- */
- public boolean sameParent()
- {
- boolean same = true;
-
- Tree tree = getTree();
-
- TreeItem[] items = tree.getSelection();
-
- if ((items == null) || (items.length ==0)) {
- return true;
- }
-
- TreeItem prevParent = null;
- TreeItem currParent = null;
-
- for (int idx = 0; idx < items.length; idx++)
- {
- currParent = items[idx].getParentItem();
-
- if ((idx>0) && (currParent != prevParent)) {
- same = false;
- break;
- }
- else
- {
- prevParent = currParent;
- }
- }
- return same;
- }
-
- private boolean selectionHasAncestryRelationship() {
- Tree tree = getTree();
-
- TreeItem[] items = tree.getSelection();
-
- for (int idx=0; idx<items.length; idx++)
- {
- TreeItem item = items[idx];
-
- for (int c=0; c < items.length; c++)
- {
- if (item != items[c])
- {
- if (isAncestorOf(item, items[c], false))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Returns whether an item is an ancestor of another item. The ancestor can be direct or indirect.
- * @param container the item which might be an ancestor.
- * @param item the child.
- * @param direct <code>true</code> if the container must be a direct ancestor of the child item,
- * <code>false</code> otherwise.
- * @return <code>true</code> if there is an ancestry relationship, <code>false</code> otherwise.
- */
- private boolean isAncestorOf(TreeItem container, TreeItem item, boolean direct)
- {
- TreeItem[] children = null;
-
- // does not have to be a direct ancestor
- if (!direct) {
- // get the children of the container's parent, i.e. the container's siblings
- // as well as itself
- TreeItem parent = container.getParentItem();
-
- // check if parent is null
- // parent is null if the container is a root item
- if (parent != null) {
- children = parent.getItems();
- }
- else {
- children = getTree().getItems();
- }
- }
- // must be a direct ancestor
- else {
- // get the children of the container
- children = container.getItems();
- }
-
- // go through all the children
- for (int i = 0; i < children.length; i++) {
-
- TreeItem child = children[i];
-
- // if one of the children matches the child item, return true
- if (child == item && direct) {
- return true;
- }
- // otherwise, go through children, and see if any of those are ancestors of
- // the child item
- else if (child.getItemCount() > 0) {
-
- // we check for direct ancestry
- if (isAncestorOf(child, item, true)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * --------------------------------------------------------------------------------
- * For many actions we have to walk the selection list and examine each selected
- * object to decide if a given common action is supported or not.
- * <p>
- * Walking this list multiple times while building the popup menu is a performance
- * hit, so we have this common method that does it only once, setting instance
- * variables for all of the decisions we are in interested in.
- * --------------------------------------------------------------------------------
- */
- protected void scanSelections()
- {
- // initial these variables to true. Then if set to false even once, leave as false always...
- _selectionShowRefreshAction = true;
- _selectionShowOpenViewActions = true;
- _selectionShowDeleteAction = true;
- _selectionShowRenameAction = true;
- _selectionEnableDeleteAction = true;
- _selectionEnableRenameAction = true;
- _selectionIsRemoteObject = true;
- _selectionFlagsUpdated = true;
-
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
- while (elements.hasNext())
- {
- Object element = elements.next();
- ISystemViewElementAdapter adapter = getViewAdapter(element);
-
- if (_selectionShowRefreshAction)
- _selectionShowRefreshAction = adapter.showRefresh(element);
-
- if (_selectionShowOpenViewActions)
- _selectionShowOpenViewActions = adapter.showOpenViewActions(element);
-
- if (_selectionShowDeleteAction)
- _selectionShowDeleteAction = adapter.showDelete(element);
-
- if (_selectionShowRenameAction)
- _selectionShowRenameAction = adapter.showRename(element);
-
- if (_selectionEnableDeleteAction)
- _selectionEnableDeleteAction = _selectionShowDeleteAction && adapter.canDelete(element);
- //System.out.println("ENABLE DELETE SET TO " + selectionEnableDeleteAction);
-
- if (_selectionEnableRenameAction)
- _selectionEnableRenameAction = _selectionShowRenameAction && adapter.canRename(element);
-
- if (_selectionIsRemoteObject)
- _selectionIsRemoteObject = (getRemoteAdapter(element) != null);
- }
-
- }
-
-
- public void positionTo(String name)
- {
- ArrayList selectedItems = new ArrayList();
- Tree tree = getTree();
- TreeItem topItem = null;
- for (int i = 0; i < tree.getItemCount(); i++)
- {
- TreeItem item = tree.getItem(i);
- Object data = item.getData();
- if (data instanceof IAdaptable)
- {
- ISystemViewElementAdapter adapter = getViewAdapter(data);
- String itemName = adapter.getName(data);
-
- if (StringCompare.compare(name, itemName, false))
- {
- if (topItem == null)
- {
- topItem = item;
- }
- selectedItems.add(item);
- }
- }
- }
-
- if (selectedItems.size() > 0)
- {
- TreeItem[] tItems = new TreeItem[selectedItems.size()];
- for (int i = 0; i < selectedItems.size(); i++)
- {
- tItems[i] = (TreeItem) selectedItems.get(i);
- }
-
- tree.setSelection(tItems);
- tree.setTopItem(topItem);
- setSelection(getSelection(), true);
- }
- }
-
-
- protected void handleKeyPressed(KeyEvent event)
- {
- if ((event.character == SWT.DEL) && (event.stateMask == 0) && (((IStructuredSelection) getSelection()).size() > 0))
- {
- scanSelections();
- if (showDelete() && canDelete())
- {
- SystemCommonDeleteAction dltAction = (SystemCommonDeleteAction) getDeleteAction();
- dltAction.setShell(getShell());
- dltAction.setSelection(getSelection());
- dltAction.setViewer(this);
- dltAction.run();
- }
- }
- }
-
- /**
- * Overridden so that we can pass a wrapper IContextObject into the provider to get children instead
- * of the model object, itself
- */
- protected void createChildren(final Widget widget)
- {
- if (widget instanceof TreeItem)
- {
- final Item[] tis = getChildren(widget);
- if (tis != null && tis.length > 0) {
- Object data = tis[0].getData();
- if (data != null) {
- return; // children already there!
- }
- }
-
- BusyIndicator.showWhile(widget.getDisplay(), new Runnable() {
- public void run() {
- // fix for PR 1FW89L7:
- // don't complain and remove all "dummies" ...
- if (tis != null) {
- for (int i = 0; i < tis.length; i++) {
- if (tis[i].getData() != null) {
- disassociate(tis[i]);
- Assert.isTrue(tis[i].getData() == null,
- "Second or later child is non -null");//$NON-NLS-1$
-
- }
- tis[i].dispose();
- }
- }
- Object d = widget.getData();
- if (d != null)
- {
- Object parentElement = getContextObject((TreeItem)widget);
- Object[] children = getSortedChildren(parentElement);
- if (children != null)
- {
- for (int i = 0; i < children.length; i++)
- {
- createTreeItem(widget, children[i], -1);
- }
- }
- }
- }
-
- });
- }
- else
- {
- super.createChildren(widget);
- }
- }
-
-
- /**
- * Get the containing filter reference for an item
- * @param item the item to get the filter reference for
- * @return the filter reference
- */
- public ISystemFilterReference getContainingFilterReference(TreeItem item)
- {
- Object data = item.getData();
- if (data instanceof ISystemFilterReference)
- {
- return (ISystemFilterReference)data;
- }
- else
- {
- TreeItem parent = item.getParentItem();
- if (parent != null)
- {
- return getContainingFilterReference(parent);
- }
- else
- {
- Object input = getInput();
- if (input instanceof ISystemFilterReference)
- {
- return (ISystemFilterReference)input;
- }
- else
- {
- return null;
- }
- }
- }
- }
-
- /**
- * Get the containing subsystem from an item
- * @param item the item to get the subsystem for
- * @return the subsystem
- */
- public ISubSystem getContainingSubSystem(TreeItem item)
- {
- Object data = item.getData();
- if (data instanceof ISubSystem)
- {
- return (ISubSystem)data;
- }
- else
- {
- TreeItem parent = item.getParentItem();
- if (parent != null)
- {
- return getContainingSubSystem(parent);
- }
- else
- {
- Object input = getInput();
- if (input instanceof ISubSystem)
- {
- return (ISubSystem)input;
- }
- else
- {
- return null;
- }
- }
- }
- }
-
- /**
- * Get the context object from a tree item
- * @param item the item to get the context for
- * @return the context object
- */
- public IContextObject getContextObject(TreeItem item)
- {
- Object data = item.getData();
- ISystemFilterReference filterReference = getContainingFilterReference(item);
- if (filterReference != null)
- {
- return new ContextObject(data, filterReference.getSubSystem(), filterReference);
- }
- else
- {
- ISubSystem subSystem = getContainingSubSystem(item);
- if (subSystem != null)
- {
- return new ContextObject(data, subSystem);
- }
- else
- {
- return new ContextObject(data);
- }
- }
- }
-
- /**
- * Overrides the standard viewer method to get the model object from the context object
- */
- public void add(Object parentElementOrTreePath, Object[] childElements) {
- Assert.isNotNull(parentElementOrTreePath);
- assertElementsNotNull(childElements);
-
- if (parentElementOrTreePath instanceof IContextObject)
- {
- parentElementOrTreePath = ((IContextObject)parentElementOrTreePath).getModelObject();
- }
- super.add(parentElementOrTreePath, childElements);
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeViewProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeViewProvider.java
deleted file mode 100644
index bd0b1d177..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeViewProvider.java
+++ /dev/null
@@ -1,473 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.model.ISystemContainer;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-
-/**
- * This is the content and label provider for the SystemTableTreeView.
- * This class is used both to populate the SystemTableTreeView but also
- * to resolve the icon and labels for the cells in the table/tree.
- *
- */
-public class SystemTableTreeViewProvider implements ILabelProvider, ITableLabelProvider, ITreeContentProvider
-{
-
-
- private ListenerList listeners = new ListenerList(1);
-
- protected Object[] _lastResults = null;
- protected Object _lastObject = null;
- protected SimpleDateFormat _dateFormat = new SimpleDateFormat();
- protected Viewer _viewer = null;
- protected int _maxCharsInColumnZero = 0;
- private SystemDeferredTableTreeContentManager manager;
- private boolean _disableDeferredQueries = false;
-
- /**
- * The cache of images that have been dispensed by this provider.
- * Maps ImageDescriptor->Image.
- */
- private Map imageTable = new Hashtable(40);
- private SystemTableViewColumnManager _columnManager;
- private HashMap cache;
- /**
- * Constructor for table view provider where a column manager is present.
- * In this case, the columns are customizable by the user.
- * @param columnManager
- */
- public SystemTableTreeViewProvider(SystemTableViewColumnManager columnManager)
- {
- super();
- _columnManager= columnManager;
- cache = new HashMap();
- }
-
- public void inputChanged(Viewer visualPart, Object oldInput, Object newInput)
- {
- _viewer = visualPart;
- if (_viewer instanceof AbstractTreeViewer)
- {
- manager = new SystemDeferredTableTreeContentManager(this, (SystemTableTreeView)_viewer);
- }
- }
-
- public void setCache(Object[] newCache)
- {
- _lastResults = newCache;
- }
-
- public Object[] getCache()
- {
- return _lastResults;
- }
-
- public boolean flushCache()
- {
- if (_lastResults == null)
- {
- return false;
- }
- if (_lastObject instanceof ISystemContainer)
- {
- ((ISystemContainer)_lastObject).markStale(true);
- }
-
- _lastResults = null;
- return true;
- }
-
- public boolean isDeleted(Object element)
- {
- return false;
- }
-
- public Object[] getChildren(Object object)
- {
-
- return getElements(object);
- }
-
- public Object getParent(Object object)
- {
- ISystemViewElementAdapter adapter = getAdapterFor(object);
- if (adapter != null)
- {
- return adapter.getParent(object);
- }
- else
- {
- return null;
- }
- }
-
- public boolean hasChildren(Object object)
- {
- ISystemViewElementAdapter adapter = getAdapterFor(object);
- if (adapter != null)
- {
- return adapter.hasChildren((IAdaptable)object);
- }
- if (manager != null) {
- if (manager.isDeferredAdapter(object))
- return manager.mayHaveChildren(object);
- }
- return false;
- }
-
- public Object getElementAt(Object object, int i)
- {
-
- return null;
- }
-
-
-
- protected ISystemViewElementAdapter getAdapterFor(Object object)
- {
- ISystemViewElementAdapter result = null;
- if (_viewer != null)
- {
- result = SystemAdapterHelpers.getViewAdapter(object, _viewer);
- }
- else
- {
- result = SystemAdapterHelpers.getViewAdapter(object);
- }
- if (result == null)
- {
- return null;
- }
- result.setPropertySourceInput(object);
- return result;
- }
-
- public Object[] getElements(Object object)
- {
-
-
- Object[] results = null;
- if (object == _lastObject && _lastResults != null)
- {
- return _lastResults;
- }
- else
- {
- Object element = object;
- // object could either be a model object or a wrapper IContextObject
- if (object instanceof IContextObject)
- {
- element = ((IContextObject)object).getModelObject();
- }
- {
-
- ISystemViewElementAdapter adapter = getAdapterFor(element);
- adapter.setViewer(_viewer);
-
-
-
- if (adapter.hasChildren((IAdaptable)element))
- {
- if (supportsDeferredQueries())
- {
- if (manager != null)
- {
- ISubSystem ss = adapter.getSubSystem(object);
- if (ss != null && adapter.supportsDeferredQueries(ss))
- {
- // if (ss.isConnected())
- {
-
- results = manager.getChildren(object);
- }
- }
- }
- }
- else
- {
- if (object instanceof IContextObject)
- {
- results = adapter.getChildren((IContextObject)object, new NullProgressMonitor());
- }
- else
- {
- results = adapter.getChildren((IAdaptable)object, new NullProgressMonitor());
- }
- }
- if (adapter instanceof SystemViewRootInputAdapter && results != null)
- {
- ArrayList filterredResults = new ArrayList();
- for (int i = 0; i < results.length; i++)
- {
- Object result = results[i];
- ISystemViewElementAdapter cadapter = getAdapterFor(result);
- if (!(cadapter instanceof SystemViewPromptableAdapter))
- {
- filterredResults.add(result);
- }
- }
- results = filterredResults.toArray();
- }
-
- _lastResults = results;
- _lastObject = object;
- }
- }
- }
- if (results == null)
- {
- return new Object[0];
- }
-
- return results;
- }
-
-
- public String getText(Object object)
- {
- String result = null;
- ISystemViewElementAdapter adapter = getAdapterFor(object);
- if (adapter != null)
- {
- result = adapter.getText(object);
- }
- else
- {
- IWorkbenchAdapter wadapter = (IWorkbenchAdapter)((IAdaptable) object).getAdapter(IWorkbenchAdapter.class);
-
- if (wadapter == null)
- {
- return object.toString();
- }
- return wadapter.getLabel(object);
- }
- if (result != null)
- {
- int len = result.length();
- if (len > _maxCharsInColumnZero)
- {
- _maxCharsInColumnZero = len;
- }
- }
- else
- {
- result = ""; //$NON-NLS-1$
- }
- return result;
- }
-
- public int getMaxCharsInColumnZero()
- {
- return _maxCharsInColumnZero;
- }
-
- public Image getImage(Object object)
- {
- ImageDescriptor descriptor = null;
- ISystemViewElementAdapter adapter = getAdapterFor(object);
- if (adapter != null)
- {
- descriptor = adapter.getImageDescriptor(object);
- }
- else
- {
- IWorkbenchAdapter wadapter = (IWorkbenchAdapter)((IAdaptable) object).getAdapter(IWorkbenchAdapter.class);
- if (wadapter == null)
- {
- return null;
- }
- else
- {
- descriptor = wadapter.getImageDescriptor(object);
- }
- }
-
- Image image = null;
- if (descriptor != null)
- {
- Object iobj = imageTable.get(descriptor);
- if (iobj == null)
- {
- image = descriptor.createImage();
- imageTable.put(descriptor, image);
- }
- else
- {
- image = (Image) iobj;
- }
- }
-
- return image;
- }
-
-
- public String getColumnText(Object obj, int index)
- {
- if (index == 0)
- {
- // get the first descriptor
- return getText(obj);
- }
- else
- {
-
- index = index - 1;
- ISystemViewElementAdapter adapter = getAdapterFor(obj);
- if (adapter == null)
- {
- return null;
- }
-
-
- IPropertyDescriptor[] descriptors = null;
- if (_columnManager != null)
- {
- descriptors = _columnManager.getVisibleDescriptors(adapter);
- }
- else
- {
- descriptors = adapter.getUniquePropertyDescriptors();
- }
-
- if (descriptors.length > index)
- {
- IPropertyDescriptor descriptor = descriptors[index];
-
- try
- {
- Object key = descriptor.getId();
-
- Object propertyValue = adapter.getPropertyValue(key);
-
- if (propertyValue instanceof String)
- {
- return (String) propertyValue;
- }
- else if (propertyValue instanceof Date)
- {
- return _dateFormat.format((Date)propertyValue);
- }
- else
- if (propertyValue != null)
- {
- return propertyValue.toString();
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- return ""; //$NON-NLS-1$
- }
-
- }
-
- public Image getColumnImage(Object obj, int i)
- {
- if (i == 0)
- {
- return getImage(obj);
- }
- else
- {
- return null;
- }
- }
-
- public void addListener(ILabelProviderListener listener)
- {
- listeners.add(listener);
- }
-
- public boolean isLabelProperty(Object element, String property)
- {
- return true;
- }
-
- public void removeListener(ILabelProviderListener listener)
- {
- listeners.remove(listener);
- }
-
- /**
- * Cache the objects for the given parent.
- * @param parent the parent object.
- * @param children the children to cache.
- */
- public void setCachedObjects(Object parent, Object[] children) {
- cache.put(parent, children);
- _lastObject = parent;
- _lastResults = children;
- }
-
- /**
- * Returns the cached objects for the given parent.
- * @param parent the parent object.
- * @return the cached children.
- */
- public Object[] getCachedObjects(Object parent) {
- return (Object[])(cache.get(parent));
- }
-
- /**
- * The visual part that is using this content provider is about
- * to be disposed. Deallocate all allocated SWT resources.
- */
- public void dispose() {
- }
-
- public void disableDeferredQueries(boolean disable)
- {
- _disableDeferredQueries = disable;
- }
-
- protected boolean supportsDeferredQueries()
- {
- if (_disableDeferredQueries)
- return false;
- //IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
- //return store.getBoolean(ISystemPreferencesConstants.USE_DEFERRED_QUERIES);
- return true; // DKM now enforcing deferred queries
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewColumnManager.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewColumnManager.java
deleted file mode 100644
index 7f875bfd3..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewColumnManager.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David Dykstal (IBM) - moved SystemPreferencesManager to a new package
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import java.util.HashMap;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.ui.SystemPreferencesManager;
-import org.eclipse.rse.ui.view.ISystemTableViewColumnManager;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-
-public class SystemTableViewColumnManager implements ISystemTableViewColumnManager
-{
- private Viewer _viewer;
- protected HashMap _descriptorCache;
- public SystemTableViewColumnManager(Viewer viewer)
- {
- _viewer = viewer;
- _descriptorCache = new HashMap();
- }
-
- protected IPropertyDescriptor[] getCachedDescriptors(ISystemViewElementAdapter adapter)
- {
- Object descriptors = _descriptorCache.get(adapter);
- if (descriptors != null && descriptors instanceof IPropertyDescriptor[])
- {
- return (IPropertyDescriptor[])descriptors;
- }
- return null;
- }
-
- protected void putCachedDescriptors(ISystemViewElementAdapter adapter, IPropertyDescriptor[] descriptors)
- {
- _descriptorCache.put(adapter, descriptors);
- }
-
- public void setCustomDescriptors(ISystemViewElementAdapter adapter, IPropertyDescriptor[] descriptors)
- {
- putCachedDescriptors(adapter, descriptors);
- String historyKey = getHistoryKey(adapter);
- String[] history = new String[descriptors.length];
- for (int i = 0; i < descriptors.length; i++)
- {
- history[i] = descriptors[i].getId().toString();
- }
-
- SystemPreferencesManager.setWidgetHistory(historyKey, history);
- }
-
- /**
- * Gets the property descriptors to display as columns in the table
- * The set of descriptors and their order may change depending on user customizations
- * @param adapter
- * @return the visible descriptors
- */
- public IPropertyDescriptor[] getVisibleDescriptors(ISystemViewElementAdapter adapter)
- {
- if (adapter != null)
- {
- IPropertyDescriptor[] descriptors = getCachedDescriptors(adapter);
- if (descriptors == null)
- {
- return getCustomDescriptors(adapter);
- }
- else
- {
- return descriptors;
- }
- }
-
- return new IPropertyDescriptor[0];
- }
-
- private String getHistoryKey(ISystemViewElementAdapter adapter)
- {
- String adapterName = adapter.getClass().getName();
- String viewName = _viewer.getClass().getName();
- return adapterName + ":" + viewName; //$NON-NLS-1$
- }
-
- protected IPropertyDescriptor[] getCustomDescriptors(ISystemViewElementAdapter adapter)
- {
- IPropertyDescriptor[] uniqueDescriptors = adapter.getUniquePropertyDescriptors();
-
- String historyKey = getHistoryKey(adapter);
- String[] history = SystemPreferencesManager.getWidgetHistory(historyKey);
-
- // determine the order and which of the uniqueDescriptors to use based on the history
- if (history != null && history.length > 0)
- {
- int len = history.length;
- if (uniqueDescriptors != null && uniqueDescriptors.length < len)
- {
- len = uniqueDescriptors.length;
- }
- IPropertyDescriptor[] customDescriptors = new IPropertyDescriptor[len];
- if (uniqueDescriptors != null)
- {
- for (int i = 0; i < len; i++)
- {
- String propertyName = history[i];
- // find the associated descriptor
- boolean found = false;
- for (int d = 0; d < uniqueDescriptors.length && !found; d++)
- {
- IPropertyDescriptor descriptor = uniqueDescriptors[d];
- if (propertyName.equals(descriptor.getId().toString()))
- {
- customDescriptors[i] = descriptor;
- found = true;
- }
- }
- // DKM - problem here - no such descriptor exists anymore
- if (found == false)
- {
- // invalidate the current history
- setCustomDescriptors(adapter, uniqueDescriptors);
- return uniqueDescriptors;
- }
- }
- }
- return customDescriptors;
- }
- else
- {
- setCustomDescriptors(adapter, uniqueDescriptors);
- }
-
- return uniqueDescriptors;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewFilter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewFilter.java
deleted file mode 100644
index 28017c115..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewFilter.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.rse.services.clientserver.StringCompare;
-
-
-/**
- * This class is used for filtering in the SystemTableView. The filter
- * determines what objects to show in the view.
- *
- */
-public class SystemTableViewFilter extends ViewerFilter
-{
-
- private String[] _filters;
-
- public SystemTableViewFilter()
- {
- super();
-
- }
-
- public void setFilters(String[] filters)
- {
- _filters = filters;
- }
-
- public String[] getFilters()
- {
- return _filters;
- }
-
- public boolean select(Viewer viewer, Object parent, Object element)
- {
- boolean result = true;
- if (viewer instanceof TableViewer)
- {
- if (_filters != null)
- {
- TableViewer tviewer = (TableViewer) viewer;
- ITableLabelProvider labelProvider = (ITableLabelProvider) tviewer.getLabelProvider();
-
- for (int i = 0; i < _filters.length && result; i++)
- {
- String filter = _filters[i];
-
- if (filter != null && filter.length() > 0)
- {
- String text = labelProvider.getColumnText(element, i);
- if (!StringCompare.compare(filter, text, true))
- {
- result = false;
- }
- }
- }
- }
- }
- else if (viewer instanceof TreeViewer)
- {
- if (_filters != null)
- {
- TreeViewer tviewer = (TreeViewer) viewer;
- ITableLabelProvider labelProvider = (ITableLabelProvider) tviewer.getLabelProvider();
-
- for (int i = 0; i < _filters.length && result; i++)
- {
- String filter = _filters[i];
-
- if (filter != null && filter.length() > 0)
- {
- String text = labelProvider.getColumnText(element, i);
- if (!StringCompare.compare(filter, text, true))
- {
- result = false;
- }
- }
- }
- }
- }
-
- return result;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java
deleted file mode 100644
index ec1c5d1d1..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java
+++ /dev/null
@@ -1,1993 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Michael Berger (IBM) - 146339 Added refresh action graphic.
- * David Dykstal (IBM) - moved SystemsPreferencesManager to a new package
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Kevin Doyle (IBM) - [189005] Changed setFocus() to setInput to SystemRegistryUI
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * David McKnight (IBM) - [191288] Up To Action doesn't go all the way back to the connections
- * Xuan Chen (IBM) - [192716] Refresh Error in Table View after Renaming folder shown in table
- * Xuan Chen (IBM) - [194838] Move the code for comparing two objects by absolute name to a common location
- * Kevin Doyle (IBM) - [193394] After Deleting the folder shown in Table get an error
- * Kevin Doyle (IBM) - [197971] NPE when table has no input and doing commands in Systems View
- * Martin Oberhuber (Wind River) - [199585] Fix NPE during testConnectionRemoval unit test
- * David McKnight (IBM) - [187543] use view filter to only show containers for set input dialog
- * David McKnight (IBM) - [210229] table refresh needs unique table-specific tooltip-text
- * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
- * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
- * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- * Xuan Chen (IBM) - [225685] NPE when running archive testcases
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API type
- * Martin Oberhuber (Wind River) - [228774] Improve ElementComparer Performance
- * David McKnight (IBM) - [229116] NPE in when editing remote file in new workspace
- * David McKnight (IBM) - [231867] TVT34:TCT196: PLK: "Subset" window too narrow
- * David Dykstal (IBM) - [231867] TVT34:TCT196: PLK: "Subset" window too narrow
- * David Dykstal (IBM) - [188150] adding "go up one level" tooltip
- * David McKnight (IBM) - [232320] remote system details view restore problem
- * David McKnight (IBM) - [233578] Promptable Filter Displayed 3 times when clicking cancel
- * David Dykstal (IBM) - [233678] title string is constructed by concatenation, should be substituted
-*******************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvent;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
-import org.eclipse.rse.core.events.ISystemRemoteChangeListener;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.IRSECallback;
-import org.eclipse.rse.core.model.ISystemContainer;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
-import org.eclipse.rse.internal.core.model.SystemRegistry;
-import org.eclipse.rse.internal.ui.SystemPropertyResources;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemActionViewerFilter;
-import org.eclipse.rse.ui.SystemPreferencesManager;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction;
-import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction;
-import org.eclipse.rse.ui.actions.SystemRefreshAction;
-import org.eclipse.rse.ui.actions.SystemTablePrintAction;
-import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
-import org.eclipse.rse.ui.dialogs.SystemSelectAnythingDialog;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.IRSEViewPart;
-import org.eclipse.rse.ui.view.ISystemTableViewColumnManager;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemTableView;
-import org.eclipse.rse.ui.view.SystemTableViewProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.osgi.framework.Bundle;
-
-import com.ibm.icu.text.MessageFormat;
-
-/**
- * Comment goes here
- */
-public class SystemTableViewPart extends ViewPart
- implements ISelectionListener, ISelectionChangedListener,
- ISystemMessageLine, ISystemShellProvider,
- ISystemResourceChangeListener, ISystemRemoteChangeListener,
- IRSEViewPart
-{
-
- class BrowseAction extends Action
- {
-
- public BrowseAction()
- {
- }
-
- public BrowseAction(String label, ImageDescriptor des)
- {
- super(label, des);
-
- setToolTipText(label);
- }
-
- public void checkEnabledState()
- {
- if (_viewer != null && _viewer.getInput() != null)
- {
- setEnabled(true);
- }
- else
- {
- setEnabled(false);
- }
- }
-
- public void run()
- {
- }
- }
-
- class ForwardAction extends BrowseAction
- {
- public ForwardAction()
- {
- super(SystemResources.ACTION_HISTORY_MOVEFORWARD_LABEL, getEclipseImageDescriptor("elcl16/forward_nav.gif")); //$NON-NLS-1$
-
- setTitleToolTip(SystemResources.ACTION_HISTORY_MOVEFORWARD_TOOLTIP);
- setDisabledImageDescriptor(getEclipseImageDescriptor("dlcl16/forward_nav.gif")); //$NON-NLS-1$
- }
-
- public void checkEnabledState()
- {
- if (_isLocked && _browseHistory != null && _browseHistory.size() > 0)
- {
- if (_browsePosition < _browseHistory.size() - 1)
- {
- setEnabled(true);
- return;
- }
- }
-
- setEnabled(false);
- }
-
- public void run()
- {
- _browsePosition++;
-
- HistoryItem historyItem = (HistoryItem) _browseHistory.get(_browsePosition);
- setInput(historyItem);
- }
- }
-
- class BackwardAction extends BrowseAction
- {
- public BackwardAction()
- {
- super(SystemResources.ACTION_HISTORY_MOVEBACKWARD_LABEL, getEclipseImageDescriptor("elcl16/backward_nav.gif")); //$NON-NLS-1$
- setTitleToolTip(SystemResources.ACTION_HISTORY_MOVEBACKWARD_TOOLTIP);
- setDisabledImageDescriptor(getEclipseImageDescriptor("dlcl16/backward_nav.gif")); //$NON-NLS-1$
- }
-
- public void checkEnabledState()
- {
- if (_isLocked && _browseHistory != null && _browseHistory.size() > 0)
- {
- if (_browsePosition > 0)
- {
- setEnabled(true);
- return;
- }
- }
-
- setEnabled(false);
- }
-
- public void run()
- {
- _browsePosition--;
-
- HistoryItem historyItem = (HistoryItem) _browseHistory.get(_browsePosition);
- setInput(historyItem);
- }
- }
-
- class UpAction extends BrowseAction
- {
- private IAdaptable _parent;
- public UpAction()
- {
- super(SystemResources.ACTION_GOUPLEVEL_TOOLTIP, getEclipseImageDescriptor("elcl16/up_nav.gif")); //$NON-NLS-1$
- setDisabledImageDescriptor(getEclipseImageDescriptor("dlcl16/up_nav.gif")); //$NON-NLS-1$
- }
-
- public void checkEnabledState()
- {
- if (_viewer.getInput() != null)
- {
- SystemTableViewProvider provider = (SystemTableViewProvider) _viewer.getContentProvider();
-
- // assume there is a parent
- if (provider != null)
- {
- Object parent = provider.getParent(_viewer.getInput());
- if (parent instanceof IAdaptable)
- {
- _parent = (IAdaptable) parent;
- setEnabled(true);
- }
- else
- {
- _parent = null;
- setEnabled(false);
- }
- }
- else
- {
- _parent = null;
- setEnabled(false);
- }
- }
- else
- {
- _parent = null;
- setEnabled(false);
- }
- }
-
- public void run()
- {
- if (_parent != null)
- {
- setInput(_parent);
- }
- }
- }
-
- class LockAction extends BrowseAction
- {
- public LockAction()
- {
- super();
- setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_LOCK_ID));
- String label = determineLabel();
- setText(label);
- setToolTipText(label);
- }
-
- /**
- * Sets as checked or unchecked, depending on the lock state. Also changes the text and tooltip.
- */
- public void checkEnabledState()
- {
- setChecked(_isLocked);
- String label = determineLabel();
- setText(label);
- setToolTipText(label);
- }
-
- public void run()
- {
- _isLocked = !_isLocked;
- showLock();
- }
-
- /**
- * Returns the label depending on lock state.
- * @return the label.
- */
- public String determineLabel() {
-
- if (!_isLocked) {
- return SystemResources.ACTION_LOCK_LABEL;
- }
- else {
- return SystemResources.ACTION_UNLOCK_LABEL;
- }
- }
-
- /**
- * Returns the tooltip depending on lock state.
- * @return the tooltip.
- */
- public String determineTooltip() {
-
- if (!_isLocked) {
- return SystemResources.ACTION_LOCK_TOOLTIP;
- }
- else {
- return SystemResources.ACTION_UNLOCK_TOOLTIP;
- }
- }
- }
-
- class RefreshAction extends BrowseAction
- {
- public RefreshAction()
- {
- super(SystemResources.ACTION_REFRESH_TABLE_LABLE,
- //RSEUIPlugin.getDefault().getImageDescriptor(ICON_SYSTEM_REFRESH_ID));
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_REFRESH_ID));
- setToolTipText(SystemResources.ACTION_REFRESH_TABLE_TOOLTIP);
- }
-
- public void run()
- {
- Object inputObject = _viewer.getInput();
- if (inputObject instanceof ISystemContainer)
- {
- ((ISystemContainer)inputObject).markStale(true);
- }
- ((SystemTableViewProvider) _viewer.getContentProvider()).flushCache();
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- registry.fireEvent(new SystemResourceChangeEvent(inputObject, ISystemResourceChangeEvents.EVENT_REFRESH, inputObject));
-
- //_viewer.refresh();
-
- // refresh layout too
- //_viewer.computeLayout(true);
-
- }
- }
-
- class SelectAllAction extends BrowseAction
- {
- public SelectAllAction()
- {
- super(SystemResources.ACTION_SELECT_ALL_LABEL, null);
- setToolTipText(SystemResources.ACTION_SELECT_ALL_TOOLTIP);
- }
-
- public void checkEnabledState()
- {
- if (_viewer != null && _viewer.getInput() != null)
- {
- setEnabled(true);
- }
- else
- {
- setEnabled(false);
- }
- }
- public void run()
- {
- _viewer.getTable().selectAll();
- // force viewer selection change
- _viewer.setSelection(_viewer.getSelection());
- }
- }
-
- class SelectInputAction extends BrowseAction
- {
- public SelectInputAction()
- {
- super(SystemResources.ACTION_SELECT_INPUT_LABEL, null);
- setToolTipText(SystemResources.ACTION_SELECT_INPUT_TOOLTIP);
- }
-
- public void checkEnabledState()
- {
- setEnabled(true);
- }
-
- public void run()
- {
-
- SystemSelectAnythingDialog dlg = new SystemSelectAnythingDialog(_viewer.getShell(), SystemResources.ACTION_SELECT_INPUT_DLG);
-
- SystemActionViewerFilter filter = new SystemActionViewerFilter();
- Class[] types = {Object.class};
- filter.addFilterCriterion(types, "hasChildren", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- dlg.setViewerFilter(filter);
-
- Object inputObject = _viewer.getInput();
- if (inputObject == null)
- {
- inputObject = RSECorePlugin.getTheSystemRegistry();
- }
- dlg.setInputObject(inputObject);
- if (dlg.open() == Window.OK)
- {
- Object selected = dlg.getSelectedObject();
- if (selected != null && selected instanceof IAdaptable)
- {
- IAdaptable adaptable = (IAdaptable)selected;
- ((ISystemViewElementAdapter)adaptable.getAdapter(ISystemViewElementAdapter.class)).setViewer(_viewer);
- setInput(adaptable);
- }
- }
- }
- }
-
- class PositionToAction extends BrowseAction
- {
- class PositionToDialog extends SystemPromptDialog
- {
- private String _name;
- private Combo _cbName;
- public PositionToDialog(Shell shell, String title, HistoryItem historyItem)
- {
- super(shell, title);
- }
-
- public String getPositionName()
- {
- return _name;
- }
-
- protected void buttonPressed(int buttonId)
- {
- setReturnCode(buttonId);
- _name = _cbName.getText();
- close();
- }
-
- protected Control getInitialFocusControl()
- {
- return _cbName;
- }
-
- public Control createInner(Composite parent)
- {
- Composite c = SystemWidgetHelpers.createComposite(parent, 2);
-
- Label aLabel = new Label(c, SWT.NONE);
- aLabel.setText(SystemPropertyResources.RESID_PROPERTY_NAME_LABEL);
-
- _cbName = SystemWidgetHelpers.createCombo(c, null);
- GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- _cbName.setLayoutData(textData);
- _cbName.setText("*"); //$NON-NLS-1$
- _cbName.setToolTipText(SystemResources.RESID_TABLE_POSITIONTO_ENTRY_TOOLTIP);
-
- this.getShell().setText(SystemResources.RESID_TABLE_POSITIONTO_LABEL);
- setHelp();
- return c;
- }
-
- private void setHelp()
- {
- setHelp(RSEUIPlugin.HELPPREFIX + "gnpt0000"); //$NON-NLS-1$
- }
- }
-
- public PositionToAction()
- {
- super(SystemResources.ACTION_POSITIONTO_LABEL, null);
- setToolTipText(SystemResources.ACTION_POSITIONTO_TOOLTIP);
- }
-
- public void run()
- {
-
- PositionToDialog posDialog = new PositionToDialog(getViewer().getShell(), getTitle(), _currentItem);
- if (posDialog.open() == Window.OK)
- {
- String name = posDialog.getPositionName();
-
- _viewer.positionTo(name);
- }
- }
- }
-
- class SubSetAction extends BrowseAction
- {
- class SubSetDialog extends SystemPromptDialog
- {
- private String[] _filters;
- private Text[] _controls;
- private IPropertyDescriptor[] _uniqueDescriptors;
- private HistoryItem _historyItem;
-
- public SubSetDialog(Shell shell, IPropertyDescriptor[] uniqueDescriptors, HistoryItem historyItem)
- {
- super(shell, SystemResources.RESID_TABLE_SUBSET_LABEL);
- _uniqueDescriptors = uniqueDescriptors;
- _historyItem = historyItem;
- }
-
- public String[] getFilters()
- {
- return _filters;
- }
-
- protected void buttonPressed(int buttonId)
- {
- setReturnCode(buttonId);
-
- for (int i = 0; i < _controls.length; i++)
- {
- _filters[i] = _controls[i].getText();
- }
-
- close();
- }
-
- protected Control getInitialFocusControl()
- {
- return _controls[0];
- }
-
- public Control createInner(Composite parent)
- {
- Composite c = SystemWidgetHelpers.createComposite(parent, 2);
-
- int numberOfFields = _uniqueDescriptors.length;
- _controls = new Text[numberOfFields + 1];
- _filters = new String[numberOfFields + 1];
-
- Label nLabel = new Label(c, SWT.NONE);
- nLabel.setText(SystemPropertyResources.RESID_PROPERTY_NAME_LABEL);
-
- String[] histFilters = null;
- if (_historyItem != null)
- {
- histFilters = _historyItem.getFilters();
- }
-
- _controls[0] = SystemWidgetHelpers.createTextField(c, null);
- GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- _controls[0].setLayoutData(textData);
- _controls[0].setText("*"); //$NON-NLS-1$
- _controls[0].setToolTipText(SystemResources.RESID_TABLE_SUBSET_ENTRY_TOOLTIP);
-
- if (histFilters != null)
- {
- _controls[0].setText(histFilters[0]);
- }
-
- for (int i = 0; i < numberOfFields; i++)
- {
- IPropertyDescriptor des = _uniqueDescriptors[i];
-
- Label aLabel = new Label(c, SWT.NONE);
- aLabel.setText(des.getDisplayName());
-
- _controls[i + 1] = SystemWidgetHelpers.createTextField(c, null);
- GridData textData3 = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- textData3.widthHint = 150;
- _controls[i + 1].setLayoutData(textData3);
- _controls[i + 1].setText("*"); //$NON-NLS-1$
-
- if (histFilters != null)
- {
- _controls[i + 1].setText(histFilters[i + 1]);
- _controls[i + 1].setToolTipText(SystemResources.RESID_TABLE_SUBSET_ENTRY_TOOLTIP);
- }
- }
-
- setHelp();
- return c;
- }
-
- private void setHelp()
- {
- setHelp(RSEUIPlugin.HELPPREFIX + "gnss0000"); //$NON-NLS-1$
- }
- }
-
- public SubSetAction()
- {
- super(SystemResources.ACTION_SUBSET_LABEL, null);
- setToolTipText(SystemResources.ACTION_SUBSET_TOOLTIP);
- }
-
- public void run()
- {
- SubSetDialog subsetDialog = new SubSetDialog(getViewer().getShell(), _viewer.getVisibleDescriptors(_viewer.getInput()), _currentItem);
- if (subsetDialog.open() == Window.OK)
- {
- String[] filters = subsetDialog.getFilters();
- _currentItem.setFilters(filters);
- _viewer.setViewFilters(filters);
- }
- }
- }
-
- class HistoryItem
- {
- private String[] _filters;
- private IAdaptable _object;
-
- public HistoryItem(IAdaptable object, String[] filters)
- {
- _object = object;
- _filters = filters;
- }
-
- public IAdaptable getObject()
- {
- return _object;
- }
-
- public String[] getFilters()
- {
- return _filters;
- }
-
- public void setFilters(String[] filters)
- {
- _filters = filters;
- }
- }
-
- class RestoreStateRunnable extends Job
- {
- private IMemento _rmemento;
- public RestoreStateRunnable(IMemento memento)
- {
- super("Restore RSE Table"); //$NON-NLS-1$
- _rmemento = memento;
- }
-
- public IStatus run(final IProgressMonitor monitor)
- {
- try {
- IStatus wstatus = RSECorePlugin.waitForInitCompletion();
- if (!wstatus.isOK()){
- return wstatus;
- }
- }
- catch (InterruptedException e){
- return Status.CANCEL_STATUS;
- }
-
-
- final IMemento memento = _rmemento;
- String profileId = memento.getString(TAG_TABLE_VIEW_PROFILE_ID);
- String connectionId = memento.getString(TAG_TABLE_VIEW_CONNECTION_ID);
- String subsystemId = memento.getString(TAG_TABLE_VIEW_SUBSYSTEM_ID);
- final String filterID = memento.getString(TAG_TABLE_VIEW_FILTER_ID);
- final String objectID = memento.getString(TAG_TABLE_VIEW_OBJECT_ID);
-
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
-
- Object input = null;
- if (subsystemId == null)
- {
- if (connectionId != null)
- {
-
- ISystemProfile profile = registry.getSystemProfile(profileId);
- input = registry.getHost(profile, connectionId);
- }
- else
- {
- // 191288 we now use registry instead of registry ui as input
- input = registry;
- }
- }
- else
- {
- // from the subsystem ID determine the profile, system and subsystem
- final ISubSystem subsystem = registry.getSubSystem(subsystemId);
-
- if (subsystem != null) {
- if (filterID == null && objectID == null) {
- input = subsystem;
- }
- else {
- if (!subsystem.isConnected()) {
- try {
- final Object finInput = input;
- subsystem.connect(false, new IRSECallback() {
- public void done(IStatus status, Object result) {
- // this needs to be done on the main thread
- // so doing an asynchExec()
- Display.getDefault().asyncExec(new RunOnceConnectedOnMainThread(memento, finInput, subsystem, filterID, objectID));
- }
- });
- return Status.OK_STATUS;
- }
- catch (Exception e) {
- return Status.CANCEL_STATUS;
- }
- }
- return runOnceConnected(monitor, memento, input, subsystem, filterID, objectID);
- } // end else
- } // end if (subsystem != null)
- } // end else
- return runWithInput(monitor, input, memento);
- }
-
- private class RunOnceConnectedOnMainThread implements Runnable
- {
- private IMemento _inmemento;
- private Object _input;
- private ISubSystem _subSystem;
- private String _filterID;
- private String _objectID;
- public RunOnceConnectedOnMainThread(IMemento memento, Object input, ISubSystem subSystem, String filterID, String objectID)
- {
- _inmemento = memento;
- _input = input;
- _subSystem = subSystem;
- _filterID = filterID;
- _objectID = objectID;
- }
-
- public void run()
- {
- runOnceConnected(new NullProgressMonitor(), _inmemento, _input, _subSystem, _filterID, _objectID);
- }
- }
-
- public IStatus runOnceConnected(IProgressMonitor monitor, IMemento memento, Object input, ISubSystem subsystem, String filterID, String objectID)
- {
- if (subsystem.isConnected()) {
- if (filterID != null) {
- try {
- input = subsystem.getObjectWithAbsoluteName(filterID, monitor);
- }
- catch (Exception e) {
- //ignore
- }
- }
- else {
- if (objectID != null) {
- try {
- input = subsystem.getObjectWithAbsoluteName(objectID, monitor);
- }
- catch (Exception e) {
- return Status.CANCEL_STATUS;
- }
- }
- } // end else
- } // end if (subsystem.isConnected)
- return runWithInput(monitor, input, memento);
- }
-
- public IStatus runWithInput(IProgressMonitor monitor, Object input, IMemento memento)
- {
- if (input != null && input instanceof IAdaptable)
- {
- _mementoInput = (IAdaptable) input;
- if (_mementoInput != null && _viewer != null)
- {
- String columnWidths = memento.getString(TAG_TABLE_VIEW_COLUMN_WIDTHS_ID);
- if (columnWidths != null)
- {
- StringTokenizer tok = new StringTokenizer(columnWidths, ","); //$NON-NLS-1$
- int[] colWidths = new int[tok.countTokens()];
- int t = 0;
- while (tok.hasMoreTokens())
- {
- String columnStr = tok.nextToken();
- colWidths[t] = Integer.parseInt(columnStr);
- t++;
- }
-
- _viewer.setLastColumnWidths(colWidths);
- }
-
- // set input needs to be run on the main thread
- Display.getDefault().asyncExec(new Runnable()
- {
- public void run(){
- setInput(_mementoInput);
- }
- });
- }
- }
- return Status.OK_STATUS;
- }
-
- }
-
-
-
- private class SelectColumnsAction extends BrowseAction
- {
-
- class SelectColumnsDialog extends SystemPromptDialog
- {
- private ISystemViewElementAdapter _adapter;
- private ISystemTableViewColumnManager _columnManager;
- private IPropertyDescriptor[] _uniqueDescriptors;
- private ArrayList _currentDisplayedDescriptors;
- private ArrayList _availableDescriptors;
-
- private List _availableList;
- private List _displayedList;
-
- private Button _addButton;
- private Button _removeButton;
- private Button _upButton;
- private Button _downButton;
-
-
- public SelectColumnsDialog(Shell shell, ISystemViewElementAdapter viewAdapter, ISystemTableViewColumnManager columnManager)
- {
- super(shell, SystemResources.RESID_TABLE_SELECT_COLUMNS_LABEL);
- setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_TOOLTIP);
- _adapter = viewAdapter;
- _columnManager = columnManager;
- _uniqueDescriptors = viewAdapter.getUniquePropertyDescriptors();
- IPropertyDescriptor[] initialDisplayedDescriptors = _columnManager.getVisibleDescriptors(_adapter);
- _currentDisplayedDescriptors = new ArrayList(initialDisplayedDescriptors.length);
- for (int i = 0; i < initialDisplayedDescriptors.length;i++)
- {
- if (!_currentDisplayedDescriptors.contains(initialDisplayedDescriptors[i]))
- _currentDisplayedDescriptors.add(initialDisplayedDescriptors[i]);
- }
- _availableDescriptors = new ArrayList(_uniqueDescriptors.length);
- for (int i = 0; i < _uniqueDescriptors.length;i++)
- {
- if (!_currentDisplayedDescriptors.contains(_uniqueDescriptors[i]))
- {
- _availableDescriptors.add(_uniqueDescriptors[i]);
- }
- }
- }
-
-
- public void handleEvent(Event e)
- {
- Widget source = e.widget;
- if (source == _addButton)
- {
- int[] toAdd = _availableList.getSelectionIndices();
- addToDisplay(toAdd);
- }
- else if (source == _removeButton)
- {
- int[] toAdd = _displayedList.getSelectionIndices();
- removeFromDisplay(toAdd);
- }
- else if (source == _upButton)
- {
- int index = _displayedList.getSelectionIndex();
- moveUp(index);
- _displayedList.select(index - 1);
- }
- else if (source == _downButton)
- {
- int index = _displayedList.getSelectionIndex();
- moveDown(index);
- _displayedList.select(index + 1);
- }
-
- // update button enable states
- updateEnableStates();
- }
-
- public IPropertyDescriptor[] getDisplayedColumns()
- {
- IPropertyDescriptor[] displayedColumns = new IPropertyDescriptor[_currentDisplayedDescriptors.size()];
- for (int i = 0; i< _currentDisplayedDescriptors.size();i++)
- {
- displayedColumns[i]= (IPropertyDescriptor)_currentDisplayedDescriptors.get(i);
- }
- return displayedColumns;
- }
-
- private void updateEnableStates()
- {
- boolean enableAdd = false;
- boolean enableRemove = false;
- boolean enableUp = false;
- boolean enableDown = false;
-
- int[] availableSelected = _availableList.getSelectionIndices();
- for (int i = 0; i < availableSelected.length; i++)
- {
- int index = availableSelected[i];
- IPropertyDescriptor descriptor = (IPropertyDescriptor)_availableDescriptors.get(index);
- if (!_currentDisplayedDescriptors.contains(descriptor))
- {
- enableAdd = true;
- }
- }
-
- if (_displayedList.getSelectionCount()>0)
- {
- enableRemove = true;
-
- int index = _displayedList.getSelectionIndex();
- if (index > 0)
- {
- enableUp = true;
- }
- if (index < _displayedList.getItemCount()-1)
- {
- enableDown = true;
- }
- }
-
- _addButton.setEnabled(enableAdd);
- _removeButton.setEnabled(enableRemove);
- _upButton.setEnabled(enableUp);
- _downButton.setEnabled(enableDown);
-
- }
-
- private void moveUp(int index)
- {
- Object obj = _currentDisplayedDescriptors.remove(index);
- _currentDisplayedDescriptors.add(index - 1, obj);
- refreshDisplayedList();
- }
-
- private void moveDown(int index)
- {
- Object obj = _currentDisplayedDescriptors.remove(index);
- _currentDisplayedDescriptors.add(index + 1, obj);
-
- refreshDisplayedList();
- }
-
- private void addToDisplay(int[] toAdd)
- {
- ArrayList added = new ArrayList();
- for (int i = 0; i < toAdd.length; i++)
- {
- int index = toAdd[i];
-
- IPropertyDescriptor descriptor = (IPropertyDescriptor)_availableDescriptors.get(index);
-
- if (!_currentDisplayedDescriptors.contains(descriptor))
- {
- _currentDisplayedDescriptors.add(descriptor);
- added.add(descriptor);
- }
- }
-
- for (int i = 0; i < added.size(); i++)
- {
- _availableDescriptors.remove(added.get(i));
- }
-
-
- refreshAvailableList();
- refreshDisplayedList();
-
- }
-
- private void removeFromDisplay(int[] toRemove)
- {
- for (int i = 0; i < toRemove.length; i++)
- {
- int index = toRemove[i];
- IPropertyDescriptor descriptor = (IPropertyDescriptor)_currentDisplayedDescriptors.get(index);
- _currentDisplayedDescriptors.remove(index);
- _availableDescriptors.add(descriptor);
- }
- refreshDisplayedList();
- refreshAvailableList();
- }
-
- protected void buttonPressed(int buttonId)
- {
- setReturnCode(buttonId);
-
- close();
- }
-
- protected Control getInitialFocusControl()
- {
- return _availableList;
- }
-
- public Control createInner(Composite parent)
- {
- Composite main = SystemWidgetHelpers.createComposite(parent, 1);
-
-
- Composite c = SystemWidgetHelpers.createComposite(main, 4);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
- _availableList = SystemWidgetHelpers.createListBox(c, SystemResources.RESID_TABLE_SELECT_COLUMNS_AVAILABLE_LABEL, this, true);
-
- Composite addRemoveComposite = SystemWidgetHelpers.createComposite(c, 1);
- addRemoveComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
- _addButton = SystemWidgetHelpers.createPushButton(addRemoveComposite,
- SystemResources.RESID_TABLE_SELECT_COLUMNS_ADD_LABEL,
- this);
- _addButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_ADD_TOOLTIP);
-
- _removeButton = SystemWidgetHelpers.createPushButton(addRemoveComposite,
- SystemResources.RESID_TABLE_SELECT_COLUMNS_REMOVE_LABEL,
- this);
- _removeButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_REMOVE_TOOLTIP);
-
- _displayedList = SystemWidgetHelpers.createListBox(c, SystemResources.RESID_TABLE_SELECT_COLUMNS_DISPLAYED_LABEL, this, false);
-
- Composite upDownComposite = SystemWidgetHelpers.createComposite(c, 1);
- upDownComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
- _upButton = SystemWidgetHelpers.createPushButton(upDownComposite,
- SystemResources.RESID_TABLE_SELECT_COLUMNS_UP_LABEL,
- this);
- _upButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_UP_TOOLTIP);
-
- _downButton = SystemWidgetHelpers.createPushButton(upDownComposite,
- SystemResources.RESID_TABLE_SELECT_COLUMNS_DOWN_LABEL,
- this);
- _downButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_DOWN_TOOLTIP);
-
- initLists();
-
- setHelp();
- return c;
- }
-
- private void initLists()
- {
- refreshAvailableList();
- refreshDisplayedList();
- updateEnableStates();
- }
-
- private void refreshAvailableList()
- {
- _availableList.removeAll();
- // initialize available list
- for (int i = 0; i < _availableDescriptors.size(); i++)
- {
- IPropertyDescriptor descriptor = (IPropertyDescriptor)_availableDescriptors.get(i);
- _availableList.add(descriptor.getDisplayName());
- }
- }
-
- private void refreshDisplayedList()
- {
- _displayedList.removeAll();
- // initialize display list
- for (int i = 0; i < _currentDisplayedDescriptors.size(); i++)
- {
-
- Object obj = _currentDisplayedDescriptors.get(i);
- if (obj != null && obj instanceof IPropertyDescriptor)
- {
- _displayedList.add(((IPropertyDescriptor)obj).getDisplayName());
- }
- }
- }
-
- private void setHelp()
- {
- setHelp(RSEUIPlugin.HELPPREFIX + "gntc0000"); //$NON-NLS-1$
- }
- }
-
- public SelectColumnsAction()
- {
- super(SystemResources.ACTION_SELECTCOLUMNS_LABEL, null);
- setToolTipText(SystemResources.ACTION_SELECTCOLUMNS_TOOLTIP);
- setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTER_ID));
- }
-
- public void checkEnabledState()
- {
- if (_viewer != null && _viewer.getInput() != null)
- {
- setEnabled(true);
- }
- else
- {
- setEnabled(false);
- }
- }
- public void run()
- {
- ISystemTableViewColumnManager mgr = _viewer.getColumnManager();
- ISystemViewElementAdapter adapter = _viewer.getAdapterForContents();
- SelectColumnsDialog dlg = new SelectColumnsDialog(getShell(), adapter, mgr);
- if (dlg.open() == Window.OK)
- {
- mgr.setCustomDescriptors(adapter, dlg.getDisplayedColumns());
- _viewer.computeLayout(true);
- _viewer.refresh();
- }
- }
- }
-
- private HistoryItem _currentItem;
-
- private SystemTableView _viewer;
-
- protected ArrayList _browseHistory;
- protected int _browsePosition;
-
- private ForwardAction _forwardAction = null;
- private BackwardAction _backwardAction = null;
- private UpAction _upAction = null;
-
- private LockAction _lockAction = null;
- private RefreshAction _refreshAction = null;
- private SystemRefreshAction _refreshSelectionAction = null;
-
- private SelectInputAction _selectInputAction = null;
- private PositionToAction _positionToAction = null;
- private SubSetAction _subsetAction = null;
- private SystemTablePrintAction _printTableAction = null;
- private SelectColumnsAction _selectColumnsAction = null;
-
- // common actions
- private SystemCopyToClipboardAction _copyAction;
- private SystemPasteFromClipboardAction _pasteAction;
- private SystemCommonDeleteAction _deleteAction;
- private SystemCommonRenameAction _renameAction;
-
- private IMemento _memento = null;
- private IAdaptable _mementoInput = null;
- private Object _lastSelection = null;
-
- private boolean _isLocked = false;
-
- // for ISystemMessageLine
- private String _message, _errorMessage;
- private SystemMessage sysErrorMessage;
- private IStatusLineManager _statusLine = null;
-
- // constants
- public static final String ID = "org.eclipse.rse.ui.view.systemTableView"; // matches id in plugin.xml, view tag //$NON-NLS-1$
-
- // Restore memento tags
- public static final String TAG_TABLE_VIEW_PROFILE_ID = "tableViewProfileID"; //$NON-NLS-1$
- public static final String TAG_TABLE_VIEW_CONNECTION_ID = "tableViewConnectionID"; //$NON-NLS-1$
- public static final String TAG_TABLE_VIEW_SUBSYSTEM_ID = "tableViewSubsystemID"; //$NON-NLS-1$
- public static final String TAG_TABLE_VIEW_OBJECT_ID = "tableViewObjectID"; //$NON-NLS-1$
- public static final String TAG_TABLE_VIEW_FILTER_ID = "tableViewFilterID"; //$NON-NLS-1$
-
- // Subset memento tags
- public static final String TAG_TABLE_VIEW_SUBSET = "subset"; //$NON-NLS-1$
-
- // layout memento tags
- public static final String TAG_TABLE_VIEW_COLUMN_WIDTHS_ID = "columnWidths"; //$NON-NLS-1$
-
- public void setFocus()
- {
- if (_viewer.getInput() == null)
- {
- if (_memento != null)
- {
- restoreState(_memento);
- }
- else
- {
- setInput(RSECorePlugin.getTheSystemRegistry());
- }
- }
-
- _viewer.getControl().setFocus();
- }
-
- public SystemTableView getViewer()
- {
- return _viewer;
- }
-
- public Viewer getRSEViewer()
- {
- return _viewer;
- }
-
- public void createPartControl(Composite parent)
- {
- //Want to register SystemTableViewPart as resouce change listener first, since it may update the _inputObject
- //of the SystemTableView, which will affect the behaviour of the resource change event handling of SystemTableView.
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- registry.addSystemResourceChangeListener(this);
- registry.addSystemRemoteChangeListener(this);
-
- Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
- _viewer = new SystemTableView(table, this);
-
- table.setLinesVisible(true);
-
- ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService();
- selectionService.addSelectionListener(this);
- _viewer.addSelectionChangedListener(this);
- getSite().setSelectionProvider(_viewer);
-
- _viewer.addDoubleClickListener(new IDoubleClickListener()
- {
- public void doubleClick(DoubleClickEvent event)
- {
- handleDoubleClick(event);
- }
- });
-
- _isLocked = true;
- fillLocalToolBar();
-
- _browseHistory = new ArrayList();
- _browsePosition = 0;
-
- // register global edit actions
- Clipboard clipboard = RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard();
-
- CellEditorActionHandler editorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
-
- _copyAction = new SystemCopyToClipboardAction(_viewer.getShell(), clipboard);
- _pasteAction = new SystemPasteFromClipboardAction(_viewer.getShell(), clipboard);
- _deleteAction = new SystemCommonDeleteAction(_viewer.getShell(), _viewer);
- _renameAction = new SystemCommonRenameAction(_viewer.getShell(), _viewer);
-
- editorActionHandler.setCopyAction(_copyAction);
- editorActionHandler.setPasteAction(_pasteAction);
- editorActionHandler.setDeleteAction(_deleteAction);
- editorActionHandler.setSelectAllAction(new SelectAllAction());
-
- // register rename action as a global handler
- getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.RENAME.getId(), _renameAction);
-
-
- SystemWidgetHelpers.setHelp(_viewer.getControl(), RSEUIPlugin.HELPPREFIX + "sysd0000"); //$NON-NLS-1$
-
- getSite().registerContextMenu(_viewer.getContextMenuManager(), _viewer);
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection sel)
- {
- if (part != this && (part instanceof SystemViewPart))
- {
- if (!_isLocked)
- {
- if (sel instanceof IStructuredSelection)
- {
- Object first = ((IStructuredSelection) sel).getFirstElement();
- if (_lastSelection != first)
- {
- _lastSelection = first;
- if (first instanceof IAdaptable)
- {
- {
- IAdaptable adapt = (IAdaptable) first;
- ISystemViewElementAdapter va = (ISystemViewElementAdapter) adapt.getAdapter(ISystemViewElementAdapter.class);
- if (va != null && !(va instanceof SystemViewPromptableAdapter))
- {
- if (va.hasChildren(adapt) && adapt != _viewer.getInput())
- {
- setInput(adapt);
- }
- }
- }
- }
- }
- }
- }
- }
- else
- if (part == this)
- {
- updateActionStates();
- }
- }
-
- public void dispose()
- {
- ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService();
- selectionService.removeSelectionListener(this);
- _viewer.removeSelectionChangedListener(this);
-
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- registry.removeSystemRemoteChangeListener(this);
- registry.removeSystemResourceChangeListener(this);
-
- if (_viewer != null)
- {
- _viewer.dispose();
- }
-
- super.dispose();
- }
-
- private void handleDoubleClick(DoubleClickEvent event)
- {
- IStructuredSelection s = (IStructuredSelection) event.getSelection();
- Object element = s.getFirstElement();
- if (element == null)
- return;
-
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) element).getAdapter(ISystemViewElementAdapter.class);
- boolean alreadyHandled = false;
- if (adapter != null)
- {
- alreadyHandled = adapter.handleDoubleClick(element);
- if (!alreadyHandled)
- {
- if (adapter.isPromptable(element))
- {
- adapter.getChildren((IAdaptable)element, new NullProgressMonitor());
- }
- else if (adapter.hasChildren((IAdaptable)element))
- {
- setInput((IAdaptable) element);
- }
- }
- }
- }
-
- public void updateActionStates()
- {
- if (_refreshAction == null)
- fillLocalToolBar();
-
- _backwardAction.checkEnabledState();
- _forwardAction.checkEnabledState();
- _upAction.checkEnabledState();
- _lockAction.checkEnabledState();
- _refreshAction.checkEnabledState();
-
- _selectInputAction.checkEnabledState();
- _positionToAction.checkEnabledState();
- _subsetAction.checkEnabledState();
-
- _printTableAction.checkEnabledState();
- _selectColumnsAction.checkEnabledState();
- }
-
- private ImageDescriptor getEclipseImageDescriptor(String relativePath)
- {
- String iconPath = "icons/full/"; //$NON-NLS-1$
- try
- {
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- URL installURL = bundle.getEntry("/"); //$NON-NLS-1$
- URL url = new URL(installURL, iconPath + relativePath);
- return ImageDescriptor.createFromURL(url);
- }
- catch (MalformedURLException e)
- {
- return null;
- }
- }
-
- public void fillLocalToolBar()
- {
-
- if (_refreshAction == null)
- {
- // refresh action
- _refreshAction = new RefreshAction();
-
- // history actions
- _backwardAction = new BackwardAction();
- _forwardAction = new ForwardAction();
-
- // parent/child actions
- _upAction = new UpAction();
-
- // lock action
- _lockAction = new LockAction();
-
- _selectInputAction = new SelectInputAction();
- _positionToAction = new PositionToAction();
- _subsetAction = new SubSetAction();
-
- _printTableAction = new SystemTablePrintAction(getTitle(), _viewer);
- _selectColumnsAction = new SelectColumnsAction();
- }
-
- updateActionStates();
-
- IActionBars actionBars = getViewSite().getActionBars();
- IToolBarManager toolBarManager = actionBars.getToolBarManager();
- IMenuManager menuMgr = actionBars.getMenuManager();
-
-
- _refreshSelectionAction = new SystemRefreshAction(getShell());
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), _refreshSelectionAction);
- _refreshSelectionAction.setSelectionProvider(_viewer);
-
- _statusLine = actionBars.getStatusLineManager();
-
- addToolBarItems(toolBarManager);
- addToolBarMenuItems(menuMgr);
- }
-
- private void addToolBarMenuItems(IMenuManager menuManager)
- {
- menuManager.removeAll();
- menuManager.add(_selectColumnsAction);
- menuManager.add(new Separator("View")); //$NON-NLS-1$
- menuManager.add(_selectInputAction);
- menuManager.add(new Separator("Filter")); //$NON-NLS-1$
- menuManager.add(_positionToAction);
- menuManager.add(_subsetAction);
-
- //DKM - this action is useless - remove it
- // menuManager.add(new Separator("Print"));
- // menuManager.add(_printTableAction);
-
- }
-
- private void addToolBarItems(IToolBarManager toolBarManager)
- {
- toolBarManager.removeAll();
-
- _lockAction.setChecked(_isLocked);
-
- toolBarManager.add(_lockAction);
- toolBarManager.add(_refreshAction);
-
-
- toolBarManager.add(new Separator("Navigate")); //$NON-NLS-1$
- // only support history when we're locked
- if (_isLocked)
- {
- toolBarManager.add(_backwardAction);
- toolBarManager.add(_forwardAction);
- }
-
- toolBarManager.add(_upAction);
-
- toolBarManager.add(new Separator("View")); //$NON-NLS-1$
- toolBarManager.add(_selectColumnsAction);
- }
-
- public void showLock()
- {
- if (_upAction != null)
- {
- IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
- toolBarManager.removeAll();
-
- updateActionStates();
-
- addToolBarItems(toolBarManager);
- }
- }
-
- public void selectionChanged(SelectionChangedEvent e)
- {
- // listener for this view
- updateActionStates();
-
- IStructuredSelection sel = (IStructuredSelection) e.getSelection();
- _copyAction.setEnabled(_copyAction.updateSelection(sel));
- _pasteAction.setEnabled(_pasteAction.updateSelection(sel));
- _deleteAction.setEnabled(_deleteAction.updateSelection(sel));
- }
-
- public void setInput(IAdaptable object)
- {
- String[] filters = null;
- if (_currentItem != null)
- {
- IAdaptable item = _currentItem.getObject();
-
- ISystemViewElementAdapter adapter1 = (ISystemViewElementAdapter)object.getAdapter(ISystemViewElementAdapter.class);
- ISystemViewElementAdapter adapter2 = (ISystemViewElementAdapter)item.getAdapter(ISystemViewElementAdapter.class);
- if (adapter1 == adapter2)
- {
- filters = _currentItem.getFilters();
- }
- else
- {
- _viewer.setViewFilters(null);
- }
- }
- setInput(object, filters, _isLocked);
-
- if (!_isLocked)
- {
- _currentItem = new HistoryItem(object, null);
- }
- }
-
- public void setInput(HistoryItem historyItem)
- {
- setInput(historyItem.getObject(), historyItem.getFilters(), false);
-
- _currentItem = historyItem;
-
- }
-
- public void setInput(IAdaptable object, String[] filters, boolean updateHistory)
- {
- if (_viewer != null /*&& object != null*/)
- {
- setTitle(object);
- _viewer.setInput(object);
-
- if (_refreshSelectionAction != null)
- {
- _refreshSelectionAction.updateSelection(new StructuredSelection(object));
- }
- if (filters != null)
- {
- _viewer.setViewFilters(filters);
- }
-
- if (updateHistory)
- {
- while (_browsePosition < _browseHistory.size() - 1)
- {
- _browseHistory.remove(_browseHistory.get(_browseHistory.size() - 1));
- }
-
- _currentItem = new HistoryItem(object, filters);
-
-
- _browseHistory.add(_currentItem);
- _browsePosition = _browseHistory.lastIndexOf(_currentItem);
- }
-
- updateActionStates();
-
- }
- }
-
- public void setTitle(IAdaptable object)
- {
- if (object == null)
- {
- setContentDescription(""); //$NON-NLS-1$
- }
- else
- {
- ISystemViewElementAdapter va = (ISystemViewElementAdapter) object.getAdapter(ISystemViewElementAdapter.class);
- if (va != null)
- {
- String type = va.getType(object);
- String name = va.getName(object);
- String title = MessageFormat.format(SystemResources.SystemTableViewPart_title, new String[] {type, name});
- setContentDescription(title);
- }
- }
- }
-
- /**
- * Used to asynchronously update the view whenever properties change.
- */
- public void systemResourceChanged(ISystemResourceChangeEvent event)
- {
- Object child = event.getSource();
- Object input = _viewer.getInput();
- switch (event.getType())
- {
- case ISystemResourceChangeEvents.EVENT_RENAME:
- if (child == input)
- {
- setTitle((IAdaptable) child);
- }
- break;
- case ISystemResourceChangeEvents.EVENT_DELETE:
- removeFromHistory(event.getSource());
- break;
- case ISystemResourceChangeEvents.EVENT_DELETE_MANY:
- Object[] multi = event.getMultiSource();
- for (int i = 0; i < multi.length; i++) {
- // Update the history to remove all references to object
- removeFromHistory(multi[i]);
- }
- break;
- default:
- break;
- }
- }
-
- protected void removeFromHistory(Object c)
- {
- // if the object is in history, remove it since it's been deleted
- // and remove all objects whose parent is the deleted object
- for (int i = 0; i < _browseHistory.size(); i++)
- {
- HistoryItem hist = (HistoryItem)_browseHistory.get(i);
- Object historyObj = hist.getObject();
- if (historyObj == c || historyObj.equals(c) || isParentOf(c,historyObj))
- {
- _browseHistory.remove(hist);
- if (_browsePosition >= i)
- {
- _browsePosition--;
- if (_browsePosition < 0)
- {
- _browsePosition = 0;
- }
- }
- // 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
- i--;
- }
- }
-
- if (_currentItem != null) {
- Object currentObject = _currentItem.getObject();
-
- // Update the input of the viewer to the closest item in the history
- // that still exists if the current viewer item has been deleted.
- if (c == currentObject || c.equals(currentObject) || isParentOf(c,currentObject))
- {
- if (_browseHistory.size() > 0)
- {
- _currentItem = (HistoryItem)_browseHistory.get(_browsePosition);
- setInput(_currentItem.getObject(), null, false);
- }
- else
- {
- _currentItem = null;
- setInput(RSECorePlugin.getTheSystemRegistry(), null, true);
- }
- }
- }
- }
-
- protected boolean isParentOf(Object parent, Object child) {
- if (parent instanceof IAdaptable && child instanceof IAdaptable) {
- ISystemDragDropAdapter adapterParent = (ISystemDragDropAdapter) ((IAdaptable)parent).getAdapter(ISystemDragDropAdapter.class);
- ISystemDragDropAdapter adapterChild = (ISystemDragDropAdapter) ((IAdaptable)child).getAdapter(ISystemDragDropAdapter.class);
- // Check that both parent and child are from the same SubSystem
- if (adapterParent != null && adapterChild != null &&
- adapterParent.getSubSystem(parent) == adapterChild.getSubSystem(child)) {
- String parentAbsoluteName = adapterParent.getAbsoluteName(parent);
- String childAbsoluteName = adapterChild.getAbsoluteName(child);
- // Check if the child's absolute name starts with the parents absolute name
- // if it does then parent is the parent of child.
- if(childAbsoluteName != null && childAbsoluteName.startsWith(parentAbsoluteName)) {
- return true;
- }
- }
- }
- return false;
- }
-
-
- /**
- * 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.
- * @see org.eclipse.rse.core.events.ISystemRemoteChangeEvent
- */
- public void systemRemoteResourceChanged(ISystemRemoteChangeEvent event)
- {
- int eventType = event.getEventType();
- Object remoteResource = event.getResource();
- java.util.List remoteResourceNames = null;
- if (remoteResource instanceof java.util.List)
- {
- remoteResourceNames = (java.util.List) remoteResource;
- remoteResource = remoteResourceNames.get(0);
- }
-
- Object child = event.getResource();
-
-
- Object input = _viewer.getInput();
-
- String[] oldNames = event.getOldNames();
- // right now assuming only one resource
- String oldName = (oldNames == null) ? null : oldNames[0];
- boolean referToSameObject = false;
- if (input != null && oldName != null){
- referToSameObject = SystemRegistry.isSameObjectByAbsoluteName(input, null, child, oldName);
- }
-
- if (input == child || child instanceof java.util.List || referToSameObject)
- {
- switch (eventType)
- {
- // --------------------------
- // REMOTE RESOURCE CHANGED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CHANGED :
- break;
-
- // --------------------------
- // REMOTE RESOURCE CREATED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED :
- break;
-
- // --------------------------
- // REMOTE RESOURCE DELETED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED :
- {
- if (child instanceof java.util.List)
- {
- java.util.List list = (java.util.List)child;
- for (int v = 0; v < list.size(); v++)
- {
- Object c = list.get(v);
-
- removeFromHistory(c);
- /*
- if (c == input)
- {
- setInput((IAdaptable)null, null, false);
-
- return;
- }
- */
- }
- }
- else
- {
- removeFromHistory(child);
- //setInput((IAdaptable)null);
-
- return;
- }
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE RENAMED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED :
- {
- setInput((IAdaptable)child);
- }
-
- break;
- }
- }
- }
-
- public Shell getShell()
- {
- return _viewer.getShell();
- }
-
- private void restoreState(IMemento memento)
- {
- RestoreStateRunnable rsr = new RestoreStateRunnable(memento);
- rsr.setRule(RSECorePlugin.getTheSystemRegistry());
- rsr.setSystem(true);
- rsr.schedule();
-
- }
-
- /**
- * Initializes this view with the given view site. A memento is passed to
- * the view which contains a snapshot of the views state from a previous
- * session. Where possible, the view should try to recreate that state
- * within the part controls.
- * <p>
- * The parent's default implementation will ignore the memento and initialize
- * the view in a fresh state. Subclasses may override the implementation to
- * perform any state restoration as needed.
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException
- {
- super.init(site, memento);
-
- if (memento != null && SystemPreferencesManager.getRememberState())
- {
- _memento = memento;
-
- }
- }
-
- /**
- * Method declared on IViewPart.
- */
- public void saveState(IMemento memento)
- {
- super.saveState(memento);
-
- if (!SystemPreferencesManager.getRememberState())
- return;
-
- if (_viewer != null)
- {
- Object input = _viewer.getInput();
-
- if (input != null)
- {
- if (input instanceof ISystemRegistry)
- {
-
- }
- else if (input instanceof IHost)
- {
- IHost connection = (IHost) input;
- String connectionID = connection.getAliasName();
- String profileID = connection.getSystemProfileName();
- memento.putString(TAG_TABLE_VIEW_CONNECTION_ID, connectionID);
- memento.putString(TAG_TABLE_VIEW_PROFILE_ID, profileID);
- }
- else
- {
- ISystemViewElementAdapter va = (ISystemViewElementAdapter) ((IAdaptable) input).getAdapter(ISystemViewElementAdapter.class);
-
- ISubSystem subsystem = va.getSubSystem(input);
- if (subsystem != null)
- {
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- String subsystemID = registry.getAbsoluteNameForSubSystem(subsystem);
- String profileID = subsystem.getHost().getSystemProfileName();
- String connectionID = subsystem.getHost().getAliasName();
- String objectID = va.getAbsoluteName(input);
-
- memento.putString(TAG_TABLE_VIEW_PROFILE_ID, profileID);
- memento.putString(TAG_TABLE_VIEW_CONNECTION_ID, connectionID);
- memento.putString(TAG_TABLE_VIEW_SUBSYSTEM_ID, subsystemID);
-
- if (input instanceof ISystemFilterReference)
- {
- memento.putString(TAG_TABLE_VIEW_FILTER_ID, objectID);
- memento.putString(TAG_TABLE_VIEW_OBJECT_ID, null);
- }
- else
- if (input instanceof ISubSystem)
- {
- memento.putString(TAG_TABLE_VIEW_OBJECT_ID, null);
- memento.putString(TAG_TABLE_VIEW_FILTER_ID, null);
- }
- else
- {
- memento.putString(TAG_TABLE_VIEW_OBJECT_ID, objectID);
- memento.putString(TAG_TABLE_VIEW_FILTER_ID, null);
- }
- }
- }
-
- Table table = _viewer.getTable();
- if (table != null && !table.isDisposed())
- {
- String columnWidths = new String();
- TableColumn[] columns = table.getColumns();
- for (int i = 0; i < columns.length; i++)
- {
- TableColumn column = columns[i];
- int width = column.getWidth();
- if (i == columns.length - 1)
- {
- columnWidths += width;
- }
- else
- {
- columnWidths += width + ","; //$NON-NLS-1$
- }
- }
- memento.putString(TAG_TABLE_VIEW_COLUMN_WIDTHS_ID, columnWidths);
- }
- }
- }
- }
-
-
-// -------------------------------
- // ISystemMessageLine interface...
- // -------------------------------
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage()
- {
- _errorMessage = null;
- sysErrorMessage = null;
- if (_statusLine != null)
- _statusLine.setErrorMessage(_errorMessage);
- }
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage()
- {
- _message = null;
- if (_statusLine != null)
- _statusLine.setMessage(_message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage()
- {
- return _errorMessage;
- }
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null<code> is returned.
- */
- public String getMessage()
- {
- return _message;
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message)
- {
- this._errorMessage = message;
- if (_statusLine != null)
- _statusLine.setErrorMessage(message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public SystemMessage getSystemErrorMessage()
- {
- return sysErrorMessage;
- }
-
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(SystemMessage message)
- {
- sysErrorMessage = message;
- setErrorMessage(message.getLevelOneText());
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(Throwable exc)
- {
- setErrorMessage(exc.getMessage());
- }
-
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message)
- {
- this._message = message;
- if (_statusLine != null)
- _statusLine.setMessage(message);
- }
- /**
- *If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(SystemMessage message)
- {
- setMessage(message.getLevelOneText());
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewSorter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewSorter.java
deleted file mode 100644
index beb554584..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewSorter.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.Date;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-/**
- * This class is used for sorting in the SystemTableView. The sorter
- * determines what and how to sort based on property descriptors.
- *
- */
-public class SystemTableViewSorter extends ViewerSorter
-{
-
-
- private boolean _reverseSort;
-
- private int _columnNumber;
-
- private StructuredViewer _view;
- private SystemTableViewColumnManager _columnManager;
-
- public SystemTableViewSorter(int columnNumber, StructuredViewer view, SystemTableViewColumnManager columnManager)
- {
- super();
- _reverseSort = false;
- _columnNumber = columnNumber;
- _view = view;
- _columnManager = columnManager;
- }
-
- public boolean isSorterProperty(java.lang.Object element, java.lang.Object property)
- {
- return true;
- }
-
- public int category(Object element)
- {
- return 0;
- }
-
- public int getColumnNumber()
- {
- return _columnNumber;
- }
-
- public boolean isReversed()
- {
- return _reverseSort;
- }
-
- public void setReversed(boolean newReversed)
- {
- _reverseSort = newReversed;
- }
-
- public int compare(Viewer v, Object e1, Object e2)
- {
- Object name1 = getValueFor(e1, _columnNumber);
- Object name2 = getValueFor(e2, _columnNumber);
-
- try
- {
- Object n1 = name1;
- Object n2 = name2;
-
- if (n1.toString().length() == 0)
- return 1;
-
- if (isReversed())
- {
- n1 = name2;
- n2 = name1;
- }
-
- if (n1 instanceof String)
- {
- return ((String) n1).compareTo((String) n2);
- }
- else if (n1 instanceof Date)
- {
- return ((Date) n1).compareTo((Date) n2);
- }
- else if (n1 instanceof Long)
- {
- return ((Long) n1).compareTo((Long) n2);
- }
- else if (n1 instanceof Integer)
- {
- return ((Integer) n1).compareTo((Integer) n2);
- }
- else
- {
- return collator.compare(n1, n2);
- }
- }
- catch (Exception e)
- {
- return 0;
- }
-
- }
-
- private Object getValueFor(Object obj, int index)
- {
- ISystemViewElementAdapter adapter = getAdapterFor(obj);
- if (index == 0)
- {
- return adapter.getText(obj);
- }
-
- Widget widget = _view.testFindItem(obj);
- if (widget != null)
- {
-
- }
-
- index = index - 1;
- IPropertyDescriptor[] descriptors = null;
- if (_columnManager != null)
- {
- descriptors = _columnManager.getVisibleDescriptors(adapter);
- }
- else
- {
- descriptors = adapter.getUniquePropertyDescriptors();
- }
- if (descriptors.length > index)
- {
- IPropertyDescriptor descriptor = descriptors[index];
-
- try
- {
- Object key = descriptor.getId();
-
- Object propertyValue = adapter.getPropertyValue(key, false);
- return propertyValue;
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- return ""; //$NON-NLS-1$
- }
-
- private ISystemViewElementAdapter getAdapterFor(Object object)
- {
- IAdaptable adapt = (IAdaptable) object;
- if (adapt != null)
- {
- ISystemViewElementAdapter result = (ISystemViewElementAdapter) adapt.getAdapter(ISystemViewElementAdapter.class);
- result.setPropertySourceInput(object);
-
- return result;
- }
-
- return null;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTestFilterStringAPIProviderImpl.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTestFilterStringAPIProviderImpl.java
deleted file mode 100644
index d1ba7aed3..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTestFilterStringAPIProviderImpl.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- * David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * It is used when the contents are used to show the resolution of a single filter string.
- */
-public class SystemTestFilterStringAPIProviderImpl
- extends SystemAbstractAPIProvider
-{
-
-
- protected String filterString = null;
- protected ISubSystem subsystem = null;
-
- /**
- * Constructor
- * @param subsystem The subsystem that will resolve the filter string
- * @param filterString The filter string to test
- */
- public SystemTestFilterStringAPIProviderImpl(ISubSystem subsystem, String filterString)
- {
- super();
- this.subsystem = subsystem;
- this.filterString = filterString;
- }
-
- /**
- * Change the input subsystem
- */
- public void setSubSystem(ISubSystem subsystem)
- {
- this.subsystem = subsystem;
- }
- /**
- * Change the input filter string
- */
- public void setFilterString(String filterString)
- {
- this.filterString = filterString;
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
- /**
- * Return the children objects to consistute the root elements in the system view tree.
- * We return the result of asking the subsystem to resolve the filter string.
- */
- public Object[] getSystemViewRoots()
- {
- Object[] children = emptyList;
- if (subsystem == null)
- return children;
- try
- {
- children = subsystem.resolveFilterString(filterString, new NullProgressMonitor());
- children = checkForEmptyList(children, null, true);
- } catch (InterruptedException exc)
- {
- children = getCancelledMessageObject();
- } catch (Exception exc)
- {
- children = getFailedMessageObject();
- SystemBasePlugin.logError("Error in SystemTestFilterStringAPIProviderImpl#getSystemViewRoots()",exc); //$NON-NLS-1$
- }
- return children;
- }
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- * We return true on the assumption the filter string will resolve to something.
- */
- public boolean hasSystemViewRoots()
- {
- return true;
- }
- /**
- * This method is called by the connection adapter when the user expands
- * a connection. This method must return the child objects to show for that
- * connection.
- * <p>NOT APPLICABLE TO US
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- return null; //
- }
- /**
- * This method is called by the connection adapter when deciding to show a plus-sign
- * or not beside a connection. Return true if this connection has children to be shown.
- * <p>NOT APPLICABLE TO US
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- return true;
- }
-
-
- // ----------------------------------
- // OUR OWN METHODS...
- // ----------------------------------
-
-} \ No newline at end of file
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
deleted file mode 100644
index 0f8a3b7ab..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java
+++ /dev/null
@@ -1,6625 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * 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.
- * Tobias Schwarz (Wind River) - Fix 166343 getChildCount() counts invalid items
- * Martin Oberhuber (Wind River) - Improve fix for 166343 getChildCount()
- * Uwe Stieber (Wind River) - [172492] Use SafeTreeViewer
- * - [177537] [api] Dynamic system type provider need a hook to add dynamic system type specific menu groups
- * - Several bugfixes.
- * David Dykstal (IBM) - moved SystemPreferencesManager to a new package
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * 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) - [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.
- * Kevin Doyle - [193380] Deleting connection Refresh's Entire Remote Systems view
- * Kevin Doyle - [195537] Move ElementComparer to Separate File
- * Martin Oberhuber (Wind River) - [196936] Hide disabled system types
- * David McKnight (IBM) - [187205] Prevented expansion of non-expanded on remote refresh
- * David McKnight (IBM) - [196930] Don't add the connection when it's not supposed to be shown
- * Tobias Schwarz (Wind River) - [197484] Provide ContextObject for queries on all levels
- * David McKnight (IBM) - [196662] Avoid main thread query to check exists when remote refreshing
- * Kevin Doyle (IBM) - [198576] Renaming a folder directly under a Filter doesn't update children
- * Kevin Doyle (IBM) - [196582] Deprecated getRemoteObjectIdentifier
- * Martin Oberhuber (Wind River) - [198650] Fix assertion when restoring workbench state
- * Martin Oberhuber (Wind River) - [183176] Fix "widget is disposed" during Platform shutdown
- * David McKnight (IBM) - [204684] CheckExistsJob used for determining if a remote object exists after a query of it's children
- * David McKnight (IBM) - [205592] CheckExistsJob should use the context model object to get adapter
- * David McKnight (IBM) - [205819] Need to use input stream copy when EFS files are the src
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * David McKnight (IBM) - [199424] api to create tree items after query complete
- * David McKnight (IBM) - [187711] expandTo to handle filters specially
- * Martin Oberhuber (Wind River) - [218524][api] Remove deprecated ISystemViewInputProvider#getShell()
- * David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile
- * David McKnight (IBM) - [224380] system view should only fire property sheet update event when in focus
- * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
- * David Dykstal (IBM) - [225911] Exception received after deleting a profile containing a connection
- * David Dykstal (IBM) - [216858] Need the ability to Import/Export RSE connections for sharing
- * David McKnight (IBM) - [231903] TVT34:TCT198: PLK: problems with "Show prompt" checkbox and "New connection prompt"
- * David McKnight (IBM) - [233530] Not Prompted on Promptable Filters after using once by double click
- * David McKnight (IBM) - [233570] ClassCastException when moving filter after "go into" action
- * David Dykstal (IBM) - [233530] Backing out previous change for this bug
- * David McKnight (IBM) - [223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter
- * David McKnight (IBM) - [236874] NPE upon selecting an item that is not associated with subsystem
- * David McKnight (IBM) - [238363] Performance improvement for refresh in system view.
- * David McKnight (IBM) - [241722] New -> File doesn't select the newly created file
- * David McKnight (IBM) - [187739] [refresh] Sub Directories are collapsed when Parent Directory is Refreshed on Remote Systems
- * David Dykstal (IBM) - [233530] Not Prompted on Promptable Filters after using once by double click
- * David McKnight (IBM) - [249245] not showing inappropriate popup actions for: Refresh, Show In Table, Go Into, etc.
- * David McKnight (IBM) - [251851] Backport Widget disposed exception when renaming/pasting a folder
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-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.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeExpansionEvent;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.SameShellProvider;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvent;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
-import org.eclipse.rse.core.events.ISystemRemoteChangeListener;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.events.SystemRemoteChangeEvent;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterContainer;
-import org.eclipse.rse.core.filters.ISystemFilterContainerReference;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManager;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.filters.ISystemFilterString;
-import org.eclipse.rse.core.filters.ISystemFilterStringReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.IRSECallback;
-import org.eclipse.rse.core.model.ISystemContainer;
-import org.eclipse.rse.core.model.ISystemMessageObject;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.model.SystemMessageObject;
-import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
-import org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.actions.SystemCascadingGoToAction;
-import org.eclipse.rse.internal.ui.actions.SystemCollapseAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonSelectAllAction;
-import org.eclipse.rse.internal.ui.actions.SystemExpandAction;
-import org.eclipse.rse.internal.ui.actions.SystemImportConnectionAction;
-import org.eclipse.rse.internal.ui.actions.SystemOpenExplorerPerspectiveAction;
-import org.eclipse.rse.internal.ui.actions.SystemShowInMonitorAction;
-import org.eclipse.rse.internal.ui.actions.SystemShowInTableAction;
-import org.eclipse.rse.internal.ui.actions.SystemSubMenuManager;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemDeleteTarget;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.ISystemRenameTarget;
-import org.eclipse.rse.ui.RSESystemTypeAdapter;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.SystemPreferencesManager;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.actions.ISystemAction;
-import org.eclipse.rse.ui.actions.SystemNewConnectionAction;
-import org.eclipse.rse.ui.actions.SystemRefreshAction;
-import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.rse.ui.model.ISystemPromptableObject;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.model.SystemRemoteElementResourceSet;
-import org.eclipse.rse.ui.model.SystemResourceChangeEventUI;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.rse.ui.view.ISystemSelectAllTarget;
-import org.eclipse.rse.ui.view.ISystemTree;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.TreeEvent;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.internal.progress.ProgressMessages;
-import org.eclipse.ui.part.EditorInputTransfer;
-import org.eclipse.ui.part.PluginTransfer;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.progress.PendingUpdateAdapter;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-import org.eclipse.ui.views.framelist.GoIntoAction;
-
-/**
- * This subclass of the standard JFace tree viewer is used to show a tree
- * view of connections to remote systems, which can be manipulated and expanded
- * to access remote objects in the remote system.
- */
-/*
- * At one time implemented the following as well: MenuListener, IDoubleClickListener, ArmListener, IWireEventTarget
- */
-public class SystemView extends SafeTreeViewer
- implements ISystemTree, ISystemShellProvider,
- ISystemResourceChangeListener, ISystemRemoteChangeListener,
- IMenuListener, IPostSelectionProvider,
- ISystemDeleteTarget, ISystemRenameTarget, ISystemSelectAllTarget,
- ISelectionChangedListener, ITreeViewerListener
-{
-
- // for deferred queries
- class ExpandRemoteObjects implements IRSECallback {
- private List _toExpand;
-
- public ExpandRemoteObjects(List toExpand){
- _toExpand = toExpand;
- }
-
- public void done(IStatus status, Object result) {
-
- if (Display.getCurrent() != null){ // on main thread
- execute();
- }
- else {
- // need to run this code on main thread
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
- {
- public void run() {
- execute();
- }
- });
- }
- }
-
- private void execute()
- {
- // expand each previously expanded sub-node, recursively
- for (int idx = 0; idx < _toExpand.size(); idx++) {
- ExpandedItem itemToExpand = (ExpandedItem) _toExpand.get(idx);
- if (itemToExpand.isRemote()) {
- // find remote item based on its original name and unchanged root parent
- Item item = null;
- item = findFirstRemoteItemReference(itemToExpand.remoteName, itemToExpand.subsystem, itemToExpand.parentItem);
-
- // if found, re-expand it
- if (item != null && !item.isDisposed()) {
- IRSECallback callback = getCallbackForSubChildren(itemToExpand, _toExpand);
- createChildren(item, callback);
- ((TreeItem) item).setExpanded(true);
- }
- } else if (itemToExpand.data!=null) {
- setExpandedState(itemToExpand.data, true);
- }
- }
- }
-
- private IRSECallback getCallbackForSubChildren(ExpandedItem remoteParent, List itemsToExpand){
- List subChildren = new ArrayList();
-
-
- String parentName = remoteParent.remoteName;
- Object parent = remoteParent.data;
- String absoluteParentName = remoteParent.remoteAdapter.getAbsoluteName(parent);
-
- for (int i = 0; i < itemsToExpand.size(); i++){
- ExpandedItem itemToExpand = (ExpandedItem) itemsToExpand.get(i);
- if (parentName.equals(itemToExpand.remoteName)){
- // same item
- }
- else if (itemToExpand.remoteName != null && itemToExpand.remoteName.startsWith(parentName)){
- // child item
- subChildren.add(itemToExpand);
- }
- else {
- // some objects might need explicit comparison
- Object object = itemToExpand.data;
- ISystemRemoteElementAdapter adapter = itemToExpand.remoteAdapter;
- String childParentName = adapter.getAbsoluteParentName(object);
- if (absoluteParentName.equals(childParentName)){
- subChildren.add(itemToExpand);
- }
- }
- }
-
- if (subChildren.size() > 0){
- return new ExpandRemoteObjects(subChildren);
- }
- else {
- return null;
- }
- }
- }
- protected Shell shell; // shell hosting this viewer: TODO can be removed
- protected ISystemViewInputProvider inputProvider; // who is supplying our tree root elements?
- protected ISystemViewInputProvider previousInputProvider; // who is supplying our tree root elements?
- protected Object previousInput;
- protected IHost previousInputConnection;
- // protected actions initialized on demand:
- // should be accessed by getters only
- private SystemNewConnectionAction _newConnectionAction;
- private SystemImportConnectionAction _importConnectionAction;
- private SystemRefreshAction _refreshAction;
- private PropertyDialogAction _propertyDialogAction;
- private SystemCollapseAction _collapseAction; // defect 41203
- private SystemExpandAction _expandAction; // defect 41203
- private SystemOpenExplorerPerspectiveAction _openToPerspectiveAction;
-
- private SystemShowInTableAction _showInTableAction;
- private SystemShowInMonitorAction _showInMonitorAction;
- private GoIntoAction _goIntoAction;
- private SystemCascadingGoToAction _gotoActions;
- // 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 SystemCommonSelectAllAction _selectAllAction; // for common Ctrl+A select-all
- // special flags needed when building popup menu, set after examining selections
- protected boolean selectionShowPropertiesAction;
- protected boolean selectionShowRefreshAction;
- protected boolean selectionShowOpenViewActions;
- protected boolean selectionShowGenericShowInTableAction;
- protected boolean selectionShowDeleteAction;
- protected boolean selectionShowRenameAction;
- protected boolean selectionEnableDeleteAction;
- protected boolean selectionEnableRenameAction;
- protected boolean selectionIsRemoteObject;
- protected boolean selectionHasAncestorRelation;
- protected boolean selectionFlagsUpdated = false;
- // misc
- protected MenuManager menuMgr;
- protected boolean showActions = true;
- protected boolean hardCodedConnectionSelected = false;
- protected boolean mixedSelection = false;
- protected boolean specialMode = false;
- protected boolean menuListenerAdded = false;
- protected boolean fromSystemViewPart = false;
- protected boolean areAnyRemote = false;
- protected boolean enabledMode = true;
- protected Widget previousItem = null;
- protected int searchDepth = 0;
- //protected Vector remoteItemsToSkip = null;
- protected Cursor busyCursor;
- protected TreeItem inputTreeItem = null;
- protected static final int SEARCH_INFINITE = 10; // that's far enough down to search!
- public boolean debug = false;
- public boolean debugRemote = false;
- public boolean debugProperties = debug && false;
- // for support of Expand To actions ... transient filters really.
- // we need to record these per tree node they are applied to.
- protected Hashtable expandToFiltersByObject; // most efficient way to find these is by binary object
- protected Hashtable expandToFiltersByTreePath; // however, we lose that after a refresh so we also record by tree path
-
- // message line
- protected ISystemMessageLine messageLine = null;
- // button pressed
- protected static final int LEFT_BUTTON = 1;
- protected int mouseButtonPressed = LEFT_BUTTON; //d40615
- protected boolean expandingTreeOnly = false; //d40615
- protected ViewerFilter[] initViewerFilters = null;
-
- protected List _setList;
-
- /**
- * Constructor
- * @param shell The shell hosting this tree viewer widget
- * @param parent The composite widget into which to place this widget
- * @param inputProvider The input object which will supply the initial root objects in the tree.
- * Can be null initially, but be sure to call #setInputProvider(ISystemViewInputProvider) later.
- * @param msgLine Where to display messages and tooltip text
- */
- public SystemView(Shell shell, Composite parent, ISystemViewInputProvider inputProvider, ISystemMessageLine msgLine) {
- super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); // DKM - putting style here to avoid SWT.BORDER (defect 168972)
- assert shell == parent.getShell();
- this.shell = shell;
- this.inputProvider = inputProvider;
- this.messageLine = msgLine;
- init();
- }
-
- /**
- * Constructor to use when you want to specify styles for the tree widget
- * @param shell The shell hosting this tree viewer widget
- * @param parent The composite widget into which to place this widget
- * @param style The style to give the tree widget
- * @param inputProvider The input object which will supply the initial root objects in the tree.
- * Can be null initially, but be sure to call #setInputProvider(ISystemViewInputProvider) later.
- * @param msgLine Where to display messages and tooltip text
- */
- public SystemView(Shell shell, Composite parent, int style, ISystemViewInputProvider inputProvider, ISystemMessageLine msgLine) {
- super(parent, style);
- assert shell == parent.getShell();
- this.shell = shell;
- this.inputProvider = inputProvider;
- this.messageLine = msgLine;
- init();
- }
-
- /**
- * Constructor to use when you want to specify styles for the tree widget
- * @param shell The shell hosting this tree viewer widget
- * @param parent The composite widget into which to place this widget
- * @param style The style to give the tree widget
- * @param inputProvider The input object which will supply the initial root objects in the tree.
- * Can be null initially, but be sure to call #setInputProvider(ISystemViewInputProvider) later.
- * @param msgLine Where to display messages and tooltip text
- * @param initViewerFilters the initial viewer filters to apply.
- */
- public SystemView(Shell shell, Composite parent, int style, ISystemViewInputProvider inputProvider, ISystemMessageLine msgLine, ViewerFilter[] initViewerFilters) {
- super(parent, style);
- assert shell == parent.getShell();
- this.shell = shell;
- this.inputProvider = inputProvider;
- this.messageLine = msgLine;
- this.initViewerFilters = initViewerFilters;
- init();
- }
-
- /**
- * 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.
- * Can be null initially, but be sure to call #setInputProvider(ISystemViewInputProvider) later.
- * @param msgLine Where to display messages and tooltip text
- */
- public SystemView(Shell shell, Tree tree, ISystemViewInputProvider inputProvider, ISystemMessageLine msgLine) {
- super(tree);
- assert shell == tree.getShell();
- this.shell = shell;
- this.inputProvider = inputProvider;
- this.messageLine = msgLine;
- init();
- }
-
- /**
- * Set the input provider. Sometimes this is delayed, or can change.
- * @param inputProvider the input provider for this view.
- */
- public void setInputProvider(ISystemViewInputProvider inputProvider) {
- this.inputProvider = inputProvider;
- inputProvider.setViewer(this);
- setInput(inputProvider);
- }
-
- /**
- * Get the SystemViewPart that encapsulates us.
- * Will be null unless fromSystemViewPart is true.
- */
- public SystemViewPart getSystemViewPart() {
- if (fromSystemViewPart)
- return ((SystemViewPart) messageLine);
- else
- return null;
- }
-
- /**
- * Get the workbench window containing this view part. Will only be non-null for the explorer view part,
- * not when used within, say, a dialog
- */
- protected IWorkbenchWindow getWorkbenchWindow() {
- if (fromSystemViewPart)
- return getSystemViewPart().getSite().getWorkbenchWindow();
- else
- return null;
- }
-
- /**
- * Get the workbench part containing this view. Will only be non-null for the explorer view part,
- * not when used within, say, a dialog
- */
- protected IWorkbenchPart getWorkbenchPart() {
- return getSystemViewPart();
- }
-
- /**
- * Disable/Enable the viewer. We do this by blocking keystrokes without visually greying out
- */
- public void setEnabled(boolean enabled) {
- enabledMode = enabled;
- }
-
- /**
- * Sets the label and content provider for the system view.
- * This can be called externally if a custom RSE label and content provider is desired
- * @param lcProvider the provider
- */
- public void setLabelAndContentProvider(SystemViewLabelAndContentProvider lcProvider) {
- ILabelDecorator decorator = null;
- if (PlatformUI.isWorkbenchRunning()) {
- IWorkbench wb = PlatformUI.getWorkbench();
- decorator = wb.getDecoratorManager().getLabelDecorator();
- }
- setLabelProvider(new DecoratingLabelProvider(lcProvider, decorator));
- setContentProvider(lcProvider);
- }
-
- 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());
-
-
-
- // set content provider
- SystemViewLabelAndContentProvider lcProvider = new SystemViewLabelAndContentProvider();
- setLabelAndContentProvider(lcProvider);
-
- // set initial viewer filters
- if (initViewerFilters != null) {
-
- for (int i = 0; i < initViewerFilters.length; i++) {
- addFilter(initViewerFilters[i]);
- }
- }
-
- fromSystemViewPart = ((messageLine != null) && (messageLine instanceof SystemViewPart));
-
- // set the tree's input. Provides initial roots.
- if (inputProvider != null) {
- inputProvider.setViewer(this);
- setInput(inputProvider);
- if (fromSystemViewPart) {
- previousInputConnection = getInputConnection(getWorkbenchPart().getSite().getPage().getInput());
- }
- }
- //addDoubleClickListener(this);
- addSelectionChangedListener(this);
- addTreeListener(this);
- // ----------------------------------------
- // register with system registry for events
- // ----------------------------------------
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.addSystemResourceChangeListener(this);
- sr.addSystemRemoteChangeListener(this);
- // -----------------------------
- // Enable right-click popup menu
- // -----------------------------
- menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(this);
- Menu menu = menuMgr.createContextMenu(getTree());
- getTree().setMenu(menu);
- // -------------------------------------------
- // Enable specific keys: dbl-click, Delete, F5
- // -------------------------------------------
- addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- handleDoubleClick(event);
- }
- });
- getControl().addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- handleKeyPressed(e);
- }
- });
- getControl().addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- mouseButtonPressed = e.button; //d40615
- if (!enabledMode) {
- //e.doit = false;
- return;
- }
- }
- });
-
- initRefreshKey();
-
- // initialize drag and drop
- initDragAndDrop();
- }
-
- /**
- * Create the KeyListener for doing the refresh on the viewer.
- */
- protected void initRefreshKey() {
- /* DKM - no need for explicit key listener since we
- * have global action
- getControl().addKeyListener(new KeyAdapter()
- {
- public void keyReleased(KeyEvent event)
- {
- if (!enabledMode)
- return;
- if (event.keyCode == SWT.F5)
- {
- //if (debug)
- // System.out.println("F5 pressed");
- refreshAll();
- }
- }
- });
- */
- }
-
- /**
- * Handles double clicks in viewer.
- * Expands/Collapses selected item if it can be expanded/collapsed
- */
- protected void handleDoubleClick(DoubleClickEvent event) {
- if (!enabledMode) {
- //event.doit = false;
- return;
- }
- ITreeSelection s = (ITreeSelection) event.getSelection();
- Object element = s.getFirstElement();
- if (element == null) return;
- // Get the path for the element and use it for setting expanded state,
- // so the proper TreeItem is expanded/collapsed
- TreePath[] paths = s.getPathsFor(element);
- if (paths == null || paths.length == 0 || paths[0] == null) return;
- TreePath elementPath = paths[0];
- if (isExpandable(elementPath)) {
- boolean expandedState = getExpandedState(elementPath);
- setExpandedState(elementPath, !expandedState);
- // DWD: fire collapse / expand event
- Event baseEvent = new Event();
- baseEvent.item = findItem(element);
- baseEvent.widget = baseEvent.item;
- TreeEvent treeEvent = new TreeEvent(baseEvent);
- if (expandedState) {
- handleTreeCollapse(treeEvent);
- } else {
- handleTreeExpand(treeEvent);
- }
- return;
- }
- }
-
- /**
- * Handles key events in viewer.
- */
- void handleKeyPressed(KeyEvent event) {
- if ((event.character == SWT.DEL) && (event.stateMask == 0) && (((IStructuredSelection) getSelection()).size() > 0)) {
- scanSelections("handleKeyPressed"); //$NON-NLS-1$
- /* 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)) {
- collapseAll();
- } else if ((event.character == 1) && // for some reason Ctrl+A comes in as Ctrl plus the number 1!
- (event.stateMask == SWT.CTRL) && !fromSystemViewPart) {
- //System.out.println("Inside Ctrl+A processing");
- if (enableSelectAll(null)) doSelectAll(null);
- } else if ((event.character == '-') && (((IStructuredSelection) getSelection()).size() > 0)) {
- //System.out.println("Inside Ctrl+- processing");
- collapseSelected();
- } else if ((event.character == '+') && (((IStructuredSelection) getSelection()).size() > 0)) {
- //System.out.println("Inside Ctrl++ processing");
- expandSelected();
- }
-
- }
-
- /**
- * Handles a collapse-selected request
- */
- public void collapseSelected() {
- TreeItem[] selectedItems = ((Tree) getControl()).getSelection();
- if ((selectedItems != null) && (selectedItems.length > 0)) {
- for (int idx = 0; idx < selectedItems.length; idx++)
- selectedItems[idx].setExpanded(false);
- }
- }
-
- /**
- * Handles an expand-selected request
- */
- public void expandSelected() {
- TreeItem[] selectedItems = ((Tree) getControl()).getSelection();
- if ((selectedItems != null) && (selectedItems.length > 0)) {
- for (int idx = 0; idx < selectedItems.length; idx++) {
- if (!selectedItems[idx].getExpanded()) {
- createChildren(selectedItems[idx]);
- }
- selectedItems[idx].setExpanded(true);
- }
- }
- }
-
- /**
- * Display a message/status on the message/status line
- */
- public void displayMessage(String msg) {
- if (messageLine != null) messageLine.setMessage(msg);
- }
-
- /**
- * Clear message/status shown on the message/status line
- */
- public void clearMessage() {
- if (messageLine != null) messageLine.clearMessage();
- }
-
- /**
- * Turn off right-click actions
- */
- public void setShowActions(boolean show) {
- this.showActions = show;
- }
-
- /**
- * Return the input provider
- */
- public ISystemViewInputProvider getInputProvider() {
- inputProvider.setViewer(this); // just in case. Added by Phil in V5.0
- return inputProvider;
- }
-
- /**
- * Return the popup menu for the tree
- */
- public Menu getContextMenu() {
- return getTree().getMenu();
- }
-
- /**
- * Return the popup menu for the tree
- */
- public MenuManager getContextMenuManager() {
- return menuMgr;
- }
-
- /**
- * Rather than pre-defining this common action we wait until it is first needed,
- * for performance reasons.
- */
- public IAction getNewConnectionAction() {
- if (_newConnectionAction == null) _newConnectionAction = new SystemNewConnectionAction(getShell(), true, this); // true=>from popup menu
- return _newConnectionAction;
- }
-
- /**
- * Rather than pre-defining this common action we wait until it is first needed,
- * for performance reasons.
- */
- private IAction getImportConnectionAction() {
- if (_importConnectionAction == null) {
- _importConnectionAction = new SystemImportConnectionAction(); // true=>from popup menu
- _importConnectionAction.setShell(getShell());
- _importConnectionAction.setText(SystemResources.RESID_IMPORT_CONNECTION_LABEL_LONG);
- }
- return _importConnectionAction;
- }
-
- /**
- * Return the refresh action
- */
- public IAction getRefreshAction() {
- if (_refreshAction == null) _refreshAction = new SystemRefreshAction(getShell());
- _refreshAction.setId(ActionFactory.REFRESH.getId());
- _refreshAction.setActionDefinitionId("org.eclipse.ui.file.refresh"); //$NON-NLS-1$
- return _refreshAction;
- }
-
- /**
- * @return the collapse action. Lazily creates it.
- */
- public IAction getCollapseAction() {
- if (_collapseAction == null) _collapseAction = new SystemCollapseAction(getShell());
- return _collapseAction;
- }
-
- /**
- * @return the expand action. Lazily creates it.
- */
- public IAction getExpandAction() {
- if (_expandAction == null) _expandAction = new SystemExpandAction(getShell());
- return _expandAction;
- }
-
- /**
- * Rather than pre-defining this common action we wait until it is first needed,
- * for performance reasons.
- */
- public PropertyDialogAction getPropertyDialogAction() {
- if (_propertyDialogAction == null) {
- _propertyDialogAction = new PropertyDialogAction(new SameShellProvider(getShell()), this);
- _propertyDialogAction.setId(ActionFactory.PROPERTIES.getId());
- _propertyDialogAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.PROPERTIES);
- }
-
-
- _propertyDialogAction.selectionChanged(getSelection());
-
- return _propertyDialogAction;
- }
-
-
- /**
- * Return the select All action
- */
- public IAction getSelectAllAction() {
- if (_selectAllAction == null) _selectAllAction = new SystemCommonSelectAllAction(getShell(), this, this);
- return _selectAllAction;
- }
-
- /**
- * Rather than pre-defined this common action we wait until it is first needed,
- * for performance reasons.
- */
- public IAction getRenameAction() {
- if (_renameAction == null) _renameAction = new SystemCommonRenameAction(getShell(), this);
- _renameAction.setId(ActionFactory.RENAME.getId());
- _renameAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.RENAME);
- return _renameAction;
- }
-
- /**
- * Rather than pre-defined this common action we wait until it is first needed,
- * for performance reasons.
- */
- public IAction getDeleteAction() {
- if (_deleteAction == null) _deleteAction = new SystemCommonDeleteAction(getShell(), this);
- _deleteAction.setId(ActionFactory.DELETE.getId());
- _deleteAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.DELETE);
- return _deleteAction;
- }
-
- /*
- * Get the common "Open to->" action for opening a new Remote System Explorer view,
- * scoped to the currently selected object.
- *
- protected SystemCascadingOpenToAction getOpenToAction()
- {
- if (openToAction == null)
- openToAction = new SystemCascadingOpenToAction(getShell(),getWorkbenchWindow());
- return openToAction;
- } NOT USED YET */
-
- /**
- * Get the common "Open to->" action for opening a new Remote System Explorer view,
- * scoped to the currently selected object.
- */
- public SystemOpenExplorerPerspectiveAction getOpenToPerspectiveAction() {
- if (_openToPerspectiveAction == null) _openToPerspectiveAction = new SystemOpenExplorerPerspectiveAction(getShell(), getWorkbenchWindow());
- return _openToPerspectiveAction;
- }
-
- public SystemShowInTableAction getShowInTableAction() {
- if (_showInTableAction == null) _showInTableAction = new SystemShowInTableAction(getShell());
- return _showInTableAction;
- }
-
- public SystemShowInMonitorAction getShowInMonitorAction() {
- if (_showInMonitorAction == null) _showInMonitorAction = new SystemShowInMonitorAction(getShell());
- return _showInMonitorAction;
- }
-
- /**
- * Get the common "Go Into" action for drilling down in the Remote System Explorer view,
- * scoped to the currently selected object.
- */
- public GoIntoAction getGoIntoAction() {
- if (_goIntoAction == null) {
- _goIntoAction = new GoIntoAction(getSystemViewPart().getFrameList());
- _goIntoAction.setText(SystemResources.ACTION_CASCADING_GOINTO_LABEL);
- _goIntoAction.setToolTipText(SystemResources.ACTION_CASCADING_GOINTO_TOOLTIP);
- }
- return _goIntoAction;
- }
-
- /**
- * Get the common "Go To->" cascading menu action for navigating the frame list.
- */
- public SystemCascadingGoToAction getGoToActions() {
- if (_gotoActions == null) _gotoActions = new SystemCascadingGoToAction(getShell(), getSystemViewPart());
- return _gotoActions;
- }
-
- /**
- * Helper method to collapse a node in the tree.
- * Called when a currently expanded subsystem is disconnected.
- * @param forceRefresh true if children should be deleted from memory so re-expand forces refresh.
- */
- public void collapseNode(Object element, boolean forceRefresh) {
- // First, collapse this element and all its children.
- collapseToLevel(element, ALL_LEVELS);
-
- // Collapsed just changes expanded state but leaves existing child
- // widgets in memory so they are re-shown on next expansion.
- // To force the next expand to re-get the children, we have to delete the
- // children.
- if (forceRefresh) {
- refresh(element); // look at AbstractTreeViewer.updateChildren which this
- // will call. If the element is collapsed (which we just
- // did) then its children are simply disposed of, and
- // not re-queried. Just what we want!
- }
- }
-
- /**
- * 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();
- boolean allSelectionsFromSameParent = true;
- int selectionCount = selection.size();
-
- if (selectionCount == 0) // nothing selected
- {
- menu.add(getNewConnectionAction());
- menu.add(getImportConnectionAction());
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_ADDITIONS)); // user or BP/ISV additions
- } else {
- if (selectionCount > 1) {
- allSelectionsFromSameParent = sameParent();
- if (!allSelectionsFromSameParent) {
- if (selectionHasAncestryRelationship()) {
- // don't show the menu because actions with
- // multiple select on objects that are ancestors
- // of each other is problematic
- // still create the standard groups
- createStandardGroups(menu);
- return;
- }
- }
- }
- // Partition into groups...
- createStandardGroups(menu);
-
- // PRESET INSTANCE VARIABLES ABOUT WHAT COMMON ACTIONS ARE TO BE SHOWN...
- // PERFORMANCE TWEAK: OUR GLOBAL DELETE ACTION LISTENS FOR SELECTION CHANGES, AND
- // WHEN THAT CHANGES, WILL CALL CANDELETE() HERE. THAT IN TURN WILL CALL SCANSELECTIONS.
- // THIS MEANS SCAN SELECTIONS GETS CALL TWICE ON MOST RIGHT CLICK ACTIONS.
- if (!selectionFlagsUpdated) // might already be called by the global delete action wh
- scanSelections("fillContextMenu"); //$NON-NLS-1$
-
- // ADD COMMON ACTIONS...
-
- // COMMON REFRESH ACTION...
- if (showRefresh()) {
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_BUILD, getRefreshAction());
-
- // MJB: Removed as per bugzilla entry # 145843
- //menu.appendToGroup(ISystemContextMenuConstants.GROUP_BUILD, getExpandAction()); // defect 41203
- //menu.appendToGroup(ISystemContextMenuConstants.GROUP_BUILD, getCollapseAction()); // defect 41203
- }
-
- // COMMON RENAME ACTION...
- if (showRename()) {
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_REORGANIZE, getRenameAction());
- ((ISystemAction) getRenameAction()).setInputs(getShell(), this, selection);
- }
-
- // COMMON DELETE ACTION...
- if (showDelete()) {
- //menu.add(getDeleteAction());
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_REORGANIZE, getDeleteAction());
- ((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);
- 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);
- if (!selectionIsRemoteObject)
- {
- GoIntoAction goIntoAction = getGoIntoAction();
- boolean singleSelection = selection.size() == 1;
- goIntoAction.setEnabled(singleSelection);
- if (singleSelection) {
- // dkm - first find out if the selection will have children
- // only add this action if there are children
- if (hasChildren && showOpenViewActions())
- {
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_GOTO, goIntoAction);
- }
- }
-
-
- if (showOpenViewActions()) {
- SystemOpenExplorerPerspectiveAction opa = getOpenToPerspectiveAction();
- opa.setSelection(selection);
- menu.appendToGroup(opa.getContextMenuGroup(), opa);
- }
- }
-
- if (showGenericShowInTableAction() && hasChildren) {
- SystemShowInTableAction showInTableAction = getShowInTableAction();
- showInTableAction.setSelection(selection);
- menu.appendToGroup(getOpenToPerspectiveAction().getContextMenuGroup(), showInTableAction);
-
- SystemShowInMonitorAction showInMonitorAction = getShowInMonitorAction();
- showInMonitorAction.setSelection(selection);
- menu.appendToGroup(getOpenToPerspectiveAction().getContextMenuGroup(), showInMonitorAction);
-
- }
- }
-
- // GO TO CASCADING ACTIONS...
- if (fromSystemViewPart && (selectionIsRemoteObject || showOpenViewActions())) {
- SystemCascadingGoToAction gotoActions = getGoToActions();
- gotoActions.setSelection(selection);
- menu.appendToGroup(gotoActions.getContextMenuGroup(), gotoActions.getSubMenu());
- }
-
- // 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
- // more selected elements that have different adapters
- Iterator elements = selection.iterator();
- //Hashtable adapters = new Hashtable();
- ISystemViewElementAdapter adapter = null;
- boolean skipAdapterActions = false;
-
- // can we ask adapters to contribute menu items?
- // This can be done consistently only if all elements
- // in the (multi) selection adapt to the same adapter instance.
- // otherwise, adapters will not be allowed to contribute.
- while (elements.hasNext() && !skipAdapterActions) {
- Object element = elements.next();
- if (adapter == null) {
- adapter = getViewAdapter(element);
- } else if (adapter != getViewAdapter(element)) {
- // selected elements have different adapters
- skipAdapterActions = true;
- }
- //if (adapter != null)
- // adapters.put(adapter,element); // want only unique adapters
- }
-
- //Enumeration uniqueAdapters = adapters.keys();
- if (adapter != null && !skipAdapterActions) {
- Shell shell = getShell();
-
- //while (uniqueAdapters.hasMoreElements())
- //{
- // 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();
- for (int idx = 0; idx < items.length; idx++) {
- if ((items[idx] instanceof ActionContributionItem) && (((ActionContributionItem) items[idx]).getAction() instanceof ISystemAction)) {
- ISystemAction item = (ISystemAction) (((ActionContributionItem) items[idx]).getAction());
- try {
- item.setInputs(getShell(), this, selection);
- } catch (Exception e) {
- SystemBasePlugin.logError("Error configuring action " + item.getClass().getName(), e); //$NON-NLS-1$
- }
- } else if (items[idx] instanceof SystemSubMenuManager) {
- SystemSubMenuManager item = (SystemSubMenuManager) items[idx];
- item.setInputs(getShell(), this, selection);
- }
- }
-
- // ***** DO NOT ADD ANY ACTIONS AFTER HERE *****
-
- }
-
- }
-
-
- /**
- * Called when the context menu is about to open.
- * Calls {@link #fillContextMenu(IMenuManager)}
- */
- public void menuAboutToShow(IMenuManager menu) {
- if (!enabledMode) return;
- fillContextMenu(menu);
- if (!menuListenerAdded) {
- if (menu instanceof MenuManager) {
- Menu m = ((MenuManager) menu).getMenu();
- if (m != null) {
- menuListenerAdded = true;
- SystemViewMenuListener ml = new SystemViewMenuListener();
- if (messageLine != null) ml.setShowToolTipText(true, messageLine);
- m.addMenuListener(ml);
- }
- }
- }
- //System.out.println("Inside menuAboutToShow: menu null? "+( ((MenuManager)menu).getMenu()==null));
- }
-
- /**
- * Creates the Systems plugin standard groups in a context menu.
- */
- public static IMenuManager createStandardGroups(IMenuManager menu) {
- if (!menu.isEmpty()) return menu;
- // simply sets partitions in the menu, into which actions can be directed.
- // Each partition can be delimited by a separator (new Separator) or not (new GroupMarker).
- // Deleted groups are not used yet.
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_NEW)); // new->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_GOTO)); // goto into, go->
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_EXPANDTO)); // expand to->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_EXPAND)); // expand, collapse
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_OPEN)); // open xxx
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_OPENWITH)); // open with->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_BROWSEWITH)); // open with->
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_WORKWITH)); // work with->
- //menu.add(new Separator(ISystemContextMenuConstants.GROUP_SHOW)); // show->type hierarchy, in-navigator
- 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 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
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_STARTSERVER)); // start/stop remote server actions
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_IMPORTEXPORT)); // get or put actions
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_ADAPTERS)); // actions queried from adapters
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_ADDITIONS)); // user or BP/ISV additions
- //menu.add(new Separator(ISystemContextMenuConstants.GROUP_VIEWER_SETUP)); // ? Probably View->by xxx, yyy
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_TEAM)); // Team
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_COMPAREWITH));
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_REPLACEWITH));
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_PROPERTIES)); // Properties
-
- // [177537] [api] Dynamic system type provider need a hook to add dynamic system type specific menu groups.
- IRSESystemType[] systemTypes = SystemWidgetHelpers.getValidSystemTypes(null);
- for (int i = 0; i < systemTypes.length; i++) {
- IRSESystemType systemType = systemTypes[i];
- Object adapter = systemType.getAdapter(RSESystemTypeAdapter.class);
- if (adapter instanceof RSESystemTypeAdapter) {
- ((RSESystemTypeAdapter)adapter).addCustomMenuGroups(menu);
- }
- }
-
- return menu;
- }
-
- /**
- * protected helper method to add an Action to a given menu.
- * To give the action the opportunity to grey out, we call selectionChanged, but
- * only if the action implements ISelectionChangedListener
- */
- protected void menuAdd(MenuManager menu, IAction action) {
- if (action instanceof ISelectionChangedListener) ((ISelectionChangedListener) action).selectionChanged(new SelectionChangedEvent(this, getSelection()));
- }
-
- /**
- * 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.
- * @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];
- //for (int j = 0; j < elements.length; j++) {
- //if (j != i) {
- if (isAncestorOf(parentItem, elements))
- {
- return true;
- }
- //}
- // }
- }
- return false;
- */
- }
-
- /**
- * Handles selection changed in viewer.
- * Updates global actions.
- * Links to editor (if option enabled)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- selectionFlagsUpdated = false;
- _setList = new ArrayList();
- IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- Object firstSelection = sel.getFirstElement();
- if (firstSelection == null) return;
-
- // added by Phil. Noticed Edit->Delete not enabled when it should be
- boolean enableDelete = true;
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
-
- while (enableDelete && elements.hasNext()) {
- Object element = elements.next();
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (adapter == null) continue;
- if (enableDelete) enableDelete = adapter.showDelete(element) && adapter.canDelete(element);
- }
- //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
-
- ISystemViewElementAdapter adapter = getViewAdapter(firstSelection);
- if (adapter != null) {
- displayMessage(adapter.getStatusLineText(firstSelection));
- if ((mouseButtonPressed == LEFT_BUTTON) && (!expandingTreeOnly)) //d40615
- adapter.selectionChanged(firstSelection); //d40615
- } else
- clearMessage();
- //System.out.println("Inside selectionChanged in SystemView");
- expandingTreeOnly = false; //d40615
- }
-
- protected void logMyDebugMessage(String prefix, String msg) {
- if (!debugProperties) return;
- //RSEUIPlugin.logDebugMessage(prefix, msg);
- System.out.println(prefix + " " + msg); //$NON-NLS-1$
- }
-
- /**
- * Convenience method for returning the shell of this viewer.
- */
- public Shell getShell() {
- //getShell() can lead to "widget is disposed" errors, but avoiding them here does not really help
- if (!getTree().isDisposed()) {
- return getTree().getShell();
- }
- return shell;
- }
-
- /**
- * Helper method to determine if a given object is currently selected.
- * Does not consider if a child node of the given object is currently selected.
- */
- protected boolean isSelected(Object element) {
- return isSelected(element, (IStructuredSelection) getSelection());
- }
-
- /**
- * Helper method to determine if a given tree item is currently selected.
- * Does not consider if a child node of the given object is currently selected.
- */
- protected boolean isTreeItemSelected(Widget w) {
- boolean match = false;
- TreeItem[] items = getTree().getSelection();
- if ((items != null) && (items.length > 0)) {
- for (int idx = 0; !match && (idx < items.length); idx++)
- if (items[idx] == w) match = true;
- }
- return match;
- }
-
- /**
- * Helper method to determine if any of a given array of objects is currently selected
- * Does not consider if a child node of the given object is currently selected.
- */
- protected boolean isSelected(Object[] elementArray) {
- return isSelected(elementArray, (IStructuredSelection) getSelection());
- }
-
- /**
- * Helper method to determine if a given object is in given selection
- * Does not consider if a child node of the given object is currently selected.
- */
- protected boolean isSelected(Object element, IStructuredSelection selection) {
- boolean isSelected = false;
- Iterator elements = selection.iterator();
- while (!isSelected && elements.hasNext()) {
- if (element.equals(elements.next())) isSelected = true;
- }
- return isSelected;
- }
-
- /**
- * Helper method to determine if any of a given array of objects is in given selection
- * Does not consider if a child node of the given object is currently selected.
- */
- protected boolean isSelected(Object[] elementArray, IStructuredSelection selection) {
- boolean isSelected = false;
- Iterator elements = selection.iterator();
- while (!isSelected && elements.hasNext()) {
- Object nextSelection = elements.next();
- for (int idx = 0; !isSelected && (idx < elementArray.length); idx++) {
- if (elementArray[idx].equals(nextSelection)) isSelected = true;
- }
- }
- return isSelected;
- }
-
- /**
- * Helper method to determine if a given object is currently selected.
- * Does consider if a child node of the given object is currently selected.
- */
- protected boolean isSelectedOrChildSelected(Object[] parentElements) {
- boolean isSelected = false;
- if ((parentElements == null) || (parentElements.length == 0)) return false;
- for (int idx = 0; !isSelected && (idx < parentElements.length); idx++)
- isSelected = isSelectedOrChildSelected(parentElements[idx]);
- return isSelected;
- }
-
- protected boolean searchToRoot(TreeItem selectedItem, TreeItem searchItem) {
- boolean found = false;
- boolean done = false;
- while (!found && !done) {
- if (selectedItem == searchItem)
- found = true;
- else {
- if (selectedItem != null)
- {
- selectedItem = selectedItem.getParentItem();
- if (selectedItem == null) done = true;
- }
- }
- }
- return found;
- }
-
- /**
- * Called after tree item collapsed. Updates the children of the tree item being
- * collapsed by removing the widgets associated with any transient message objects
- * that were in the tree.
- * @param event the event that caused the collapse. The event data will include the
- * tree element being collapsed.
- */
- public void treeCollapsed(TreeExpansionEvent event) {
- final Object element = event.getElement(); // get parent node being collapsed
- // we always allow adapters opportunity to show a different icon depending on collapsed state
- 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
- }
- });
- }
-
- /**
- * Called after tree item expanded.
- * We need this hook to potentially undo user expand request.
- * @param event the SWT TreeExpansionEvent that caused the expansion.
- */
- public void treeExpanded(TreeExpansionEvent event) {
- expandingTreeOnly = true;
- final Object element = event.getElement();
- // we always allow adapters opportunity to show a different icon depending on expanded state
- getShell().getDisplay().asyncExec(new Runnable() {
- 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
- }
- });
- }
-
- /* (non-Javadoc)
- * Here only for observability.
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#handleTreeCollapse(org.eclipse.swt.events.TreeEvent)
- */
- protected void handleTreeCollapse(TreeEvent event) {
- super.handleTreeCollapse(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#handleTreeExpand(org.eclipse.swt.events.TreeEvent)
- */
- protected void handleTreeExpand(TreeEvent event) {
- TreeItem item = (TreeItem) event.item;
- removeTransientMessages(item);
- Shell shell = getShell();
- Object data = item.getData();
- boolean showBusy = (data instanceof IHost) && ((IHost)data).isOffline();
- if (showBusy) SystemPromptDialog.setDisplayCursor(shell, busyCursor);
- super.handleTreeExpand(event);
- if (showBusy) SystemPromptDialog.setDisplayCursor(shell, null);
- }
-
- /**
- * Remove the transient messages from this item.
- * @param item The tree item whose children should be examined for transient messages.
- */
- private void removeTransientMessages(TreeItem item) {
- // Remove any transient messages prior to finding children. They will be regenerated if they are needed.
- Item[] children = getItems(item);
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- Item child = children[i];
- Object data = child.getData();
- if (data instanceof ISystemMessageObject) {
- ISystemMessageObject message = (ISystemMessageObject) data;
- if (message.isTransient()) {
- remove(message);
- }
- }
- }
- }
- }
-
-
- /**
- * Clear current selection. Ignore widget disposed message.
- */
- protected void clearSelection() {
- try {
- setSelection((ISelection) null);
- } catch (Exception exc) {
- }
- }
-
-
-
- /**
- * Returns the implementation of ISystemViewElementAdapter for the given
- * object. Returns null if the adapter is not defined or the
- * object is not adaptable.
- */
- protected ISystemViewElementAdapter getViewAdapter(Object o) {
-
- ISystemViewInputProvider provider = getInputProvider();
-
- // should never be null, but we check just to be safe
- // the input provider should be set because for things like connections, the select
- // dialogs may set a different input provider for the connection adapter which is subsequently
- // not updated when selecting a connection in the Remote Systems view.
- // This ensures that the input provider for the Remote Systems view is set for the adapter.
- if (provider != null) {
- return SystemAdapterHelpers.getViewAdapter(o, this, provider);
- } else {
- return SystemAdapterHelpers.getViewAdapter(o, this);
- }
- }
-
- /**
- * Returns the implementation of IRemoteObjectIdentifier for the given
- * object. Returns null if this object is not adaptable to this.
- *
- * @deprecated should use {@link #getViewAdapter(Object)} since IRemoteObjectIdentifier
- * is not defined in the adapter factories
- */
- 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)
- {
- if (o instanceof IAdaptable)
- {
- return (ISystemRemoteElementAdapter)((IAdaptable)o).getAdapter(ISystemRemoteElementAdapter.class);
- }
- return null;
- }
-
-
- /**
- *
- */
- public void handleDispose(DisposeEvent event) {
- //if (debug)
- //RSEUIPlugin.logDebugMessage(this.getClass().getName(),"Inside handleDispose for SystemView");
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.removeSystemResourceChangeListener(this);
- sr.removeSystemRemoteChangeListener(this);
- busyCursor.dispose();
- super.handleDispose(event);
- }
-
- /**
- * Return the connection of the selected object, whatever it is.
- */
- public IHost getSelectedConnection() {
- Object firstSelection = ((StructuredSelection) getSelection()).getFirstElement();
- if (firstSelection == null)
- return null;
- else if (firstSelection instanceof IHost)
- return (IHost) firstSelection;
- else if (firstSelection instanceof ISubSystem)
- return ((ISubSystem) firstSelection).getHost();
- else if (firstSelection instanceof ISystemFilterPoolReference)
- return ((ISubSystem) (((ISystemFilterPoolReference) firstSelection).getProvider())).getHost();
- else if (firstSelection instanceof ISystemFilterReference)
- return ((ISubSystem) (((ISystemFilterReference) firstSelection).getProvider())).getHost();
- else if (getViewAdapter(firstSelection) != null) {
- ISubSystem ss = getViewAdapter(firstSelection).getSubSystem(firstSelection);
- if (ss != null)
- return ss.getHost();
- else
- return null;
- } else
- return null;
- }
-
- /**
- * We override getSelection(Control) so that a list of items
- * under the same parent always gets returned in the order in which
- * they appear in the tree view. Otherwise, after a "move up" or
- * "move down", the order of selection can come back wrong.
- */
- protected Item[] getSelection(Control widget) {
- Tree tree = (Tree) widget;
- Item[] oldResult = tree.getSelection();
- if (oldResult != null && oldResult.length > 0) {
- if (oldResult[0] instanceof TreeItem) {
- Widget parentItem = ((TreeItem) oldResult[0]).getParentItem();
- if (parentItem == null) {
- parentItem = tree;
- }
- if (itemsShareParent(parentItem, oldResult)) {
- Item[] newResult = sortSelection(parentItem, oldResult);
- return newResult;
- }
- }
- }
- return oldResult;
- }
-
- protected boolean itemsShareParent(Widget parentItem, Item[] items) {
- for (int i = 0; i < items.length; i++) {
- Widget itemParent = ((TreeItem) items[i]).getParentItem();
- if (parentItem instanceof TreeItem) {
- if (itemParent != parentItem) {
- return false;
- }
- } else if (itemParent != null) {
- return false;
- }
- }
-
- return true;
- }
-
- protected Item[] sortSelection(Widget parentItem, Item[] oldResult) {
- Item[] children = null;
- Item[] newResult = new Item[oldResult.length];
- if (parentItem instanceof Item) {
- children = oldResult;
- } else
- children = getChildren(parentItem);
-
- for (int i = 0; i < oldResult.length; i++)
- {
- Item first = removeFirstItem(oldResult, children);
- newResult[i] = first;
- }
-
- return newResult;
-
- }
-
-
- protected Item removeFirstItem(Item[] items, Item[] children)
- {
- if (items != null)
- {
- for (int i = 0; i < items.length; i++)
- {
- if (items[i] != null)
- {
- Item current = items[i];
- items[i] = null;
- return current;
- }
- }
- }
- return null;
- }
-
-
-
- /**
- * Move one tree item to a new location
- */
- protected void moveTreeItem(Widget parentItem, Item item, Object src, int newPosition) {
- if (item==null) {
- //Null items during RSECombinedTestSuite - put debugBreak here to investigate
- assert item!=null;
- return;
- }
- if (getExpanded(item)) {
- setExpanded(item, false);
- refresh(src); // flush items from memory
- }
-
- createTreeItem(parentItem, src, newPosition);
-
- //createTreeItem(parentItem, (new String("New")), newPosition);
- //remove(src);
-
- disassociate(item);
- item.dispose();
- // TODO: make this work so the selection order doesn't get screwed up!
- }
-
- /**
- * 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
- * positive, they are all moved down by the given amount.<p>
- */
- protected void moveTreeItems(Widget parentItem, Object[] src, int delta) {
- int[] oldPositions = new int[src.length];
- Item[] oldItems = new Item[src.length];
-
- 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++)
- {
- oldPositions[idx] = getTreeItemPosition(oldItems[idx], children) + 1;
- }
-
- if (delta > 0) // moving down, process backwards
- {
- for (int idx = src.length - 1; idx >= 0; idx--) {
- moveTreeItem(parentItem, oldItems[idx], src[idx], oldPositions[idx] + delta);
- }
- } else // moving up, process forewards
- {
- for (int idx = 0; idx < src.length; idx++) {
- moveTreeItem(parentItem, oldItems[idx], src[idx], oldPositions[idx] + delta - 1);
- }
- }
- }
-
-
-
- /**
- * Get the position of a tree item within its parent
- */
- /*
- protected int getTreeItemPosition(Widget parentItem, Item childItem, Item[] items) {
- int pos = -1;
- Item[] children = null;
- if (parentItem instanceof Item) {
- if (items == null)
- children = getItems((Item) parentItem);
- else
- children = items;
- } else
- children = getChildren(parentItem);
- for (int idx = 0; (pos == -1) && (idx < children.length); idx++) {
- if (children[idx] == childItem) pos = idx;
- }
- return pos;
- }
- */
-
-
- /**
- * Get the position of a tree item within its parent
- */
- protected int getTreeItemPosition(Item childItem, Item[] children) {
- int pos = -1;
- for (int idx = 0; (pos == -1) && (idx < children.length); idx++) {
- if (children[idx] == childItem) pos = idx;
- }
- 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
- * within the object's in this tree, so can be used in the viewer methods to affect this particular
- * node.
- */
- public ISystemFilterReference revealAndExpand(ISubSystem parentSubSystem, ISystemFilter filter) {
- setExpandedState(parentSubSystem.getHost(), true); // expand the connection
- setExpandedState(parentSubSystem, true); // expand the subsystem
- Object filterParentInTree = parentSubSystem; // will be case unless in show filter pool mode
- // if showing filter pools, expand parent filter pool reference...
- if (SystemPreferencesManager.getShowFilterPools()) {
- ISystemFilterPoolReference poolRef = parentSubSystem.getFilterPoolReferenceManager().getReferenceToSystemFilterPool(filter.getParentFilterPool());
- setExpandedState(poolRef, true);
- filterParentInTree = poolRef;
- }
- // now, find the filter reference, and expand it...
- Widget parentItem = findItem(filterParentInTree); // find tree widget of parent
- if ((parentItem == null) || !(parentItem instanceof Item)) return null;
- TreeItem child = (TreeItem) internalFindReferencedItem(parentItem, filter, 1);
- if (child == null) return null;
- // found it! Now expand it...
- setExpandedState(child.getData(), true);
- return (ISystemFilterReference) child.getData();
- }
-
- // ------------------------------------
- // ISYSTEMRESOURCEChangeListener METHOD
- // ------------------------------------
-
- /**
- * Called when something changes in the model
- */
- public void systemResourceChanged(ISystemResourceChangeEvent event) {
- if (!getControl().isDisposed()) {
- ResourceChangedJob job = new ResourceChangedJob(event, this);
- job.setPriority(Job.INTERACTIVE);
- //job.setUser(true);
- job.schedule();
- /*
- Display display = Display.getCurrent();
- try {
- while (job.getResult() == null) {
- while (display != null && display.readAndDispatch()) {
- //Process everything on event queue
- }
- if (job.getResult() == null) Thread.sleep(200);
- }
- } catch (InterruptedException e) {
- }
- */
- } else {
- 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 {
- throw new IllegalStateException(str);
- } catch(IllegalStateException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Inner class which extends UIJob to connect this connection
- * on the UI Thread when no Shell is available from
- * the caller
- */
- public class ResourceChangedJob extends UIJob {
-
- protected ISystemResourceChangeEvent _event;
- protected SystemView _originatingViewer;
- //public Exception _originatingThread; //for debugging
-
- public ResourceChangedJob(ISystemResourceChangeEvent event, SystemView originatingViewer) {
- super("Resource Changed..."); //$NON-NLS-1$
- //FIXME Shouldn't the originatingViewer be taken from the event if possible, if it is instanceof ISystemResourceChangeEventUI?
- //See also originatedHere, below
- _originatingViewer = originatingViewer;
- _event = event;
- //_originatingThread = new Exception();
- //_originatingThread.fillInStackTrace();
- ////_originatingThread.printStackTrace();
- ////System.out.println("<<<<<<<<<<<<<");
- }
-
- public IStatus runInUIThread(IProgressMonitor monitor) {
- if (getControl().isDisposed()) {
- trace("SystemView: refresh after disposed"); //$NON-NLS-1$
- return Status.CANCEL_STATUS;
- }
- 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;
- Widget item = null;
- Widget parentItem = null;
- Object[] multiSource = null;
- Object previous = null;
- boolean wasSelected = false;
- boolean originatedHere = true;
- if (_event instanceof SystemResourceChangeEventUI) {
- Viewer viewer = ((SystemResourceChangeEventUI)_event).getOriginatingViewer();
- if (viewer!=null && viewer!=_originatingViewer) {
- originatedHere = false;
- }
- Object viewerItem = ((SystemResourceChangeEventUI)_event).getViewerItem();
- if (viewerItem instanceof TreeItem) {
- inputTreeItem = (TreeItem)viewerItem;
- } else {
- inputTreeItem = null;
- }
- } else {
- inputTreeItem = null;
- }
-
- //logDebugMsg("INSIDE SYSRESCHGD: " + type + ", " + src + ", " + parent);
- switch (type) {
- // SPECIAL CASES: ANYTHING TO DO WITH FILTERS!!
- case ISystemResourceChangeEvents.EVENT_RENAME_FILTER_REFERENCE:
- case ISystemResourceChangeEvents.EVENT_CHANGE_FILTER_REFERENCE:
- findAndUpdateFilter(_event, type);
- break;
- case ISystemResourceChangeEvents.EVENT_CHANGE_FILTERSTRING_REFERENCE:
- findAndUpdateFilterString(_event, type);
- break;
-
- case ISystemResourceChangeEvents.EVENT_ADD_FILTERSTRING_REFERENCE:
- case ISystemResourceChangeEvents.EVENT_DELETE_FILTERSTRING_REFERENCE:
- case ISystemResourceChangeEvents.EVENT_MOVE_FILTERSTRING_REFERENCES:
- //findAndUpdateFilterStringParent(event, type);
- //break;
- case ISystemResourceChangeEvents.EVENT_ADD_FILTER_REFERENCE:
- case ISystemResourceChangeEvents.EVENT_DELETE_FILTER_REFERENCE:
- case ISystemResourceChangeEvents.EVENT_MOVE_FILTER_REFERENCES:
- // are we a secondary perspective, and our input or parent of our input was deleted?
- if ((
- (type == ISystemResourceChangeEvents.EVENT_DELETE_FILTERSTRING_REFERENCE)
- || (type == ISystemResourceChangeEvents.EVENT_DELETE_FILTER_REFERENCE)
- )
- && affectsInput(src)
- ) {
- close();
- return Status.OK_STATUS;
- }
-
- findAndUpdateFilterParent(_event, type);
- break;
-
- case ISystemResourceChangeEvents.EVENT_ADD:
- case ISystemResourceChangeEvents.EVENT_ADD_RELATIVE:
- if (debug) {
- logDebugMsg("SV event: EVENT_ADD "); //$NON-NLS-1$
- }
- clearSelection();
- //refresh(parent);t
- parentItem = findItem(parent);
- if (parentItem == null) return Status.OK_STATUS;
- if ((parentItem instanceof Item) && !getExpanded((Item) parentItem)) {
- refresh(parent); // flush cached stuff so next call will show new item
- } else if ((parentItem instanceof Item) || // regular node
- (parent == inputProvider)) // root node. Hmm, hope this is going to work in all cases
- {
- boolean addingConnection = (src instanceof IHost);
- if (addingConnection)
- {
- // 196930 - don't add the connection when it's not supposed to be shown
- IHost con = (IHost)src;
- IRSESystemType sysType = con.getSystemType();
- if (sysType != null) { // sysType can be null if workspace contains a host that is no longer defined by the workbench
- RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(RSESystemTypeAdapter.class));
-
- if (adapter == null || !adapter.isEnabled(sysType))
- {
- // don't add this if our src is not enabled
- return Status.OK_STATUS;
- }
- }
- else {
- 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()));
- if ((parent == inputProvider) && addingConnection && (_event.getParent() instanceof ISystemRegistry) && !inputProvider.showingConnections()) return Status.OK_STATUS; // only reflect new connections in main perspective. pc42742
- int pos = -1;
- if (type == ISystemResourceChangeEvents.EVENT_ADD_RELATIVE) {
- previous = _event.getRelativePrevious();
- if (previous != null) pos = getItemIndex(parentItem, previous);
- 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;
- // check for src
- for (int i = 0; i < currentItems.length && !exists; i++)
- {
- Item cur = currentItems[i];
- if (cur.getData() == src)
- {
- exists = true;
- }
- }
-
- //logDebugMsg("ADDING CONN? "+ addingConnection + ", position="+pos);
- if (!exists)
- {
- createTreeItem(parentItem, src, pos);
- }
- setSelection(new StructuredSelection(src), true);
- }
- break;
- case ISystemResourceChangeEvents.EVENT_ADD_MANY:
- if (debug) {
- logDebugMsg("SV event: EVENT_ADD_MANY"); //$NON-NLS-1$
- }
- multiSource = _event.getMultiSource();
- clearSelection();
- parentItem = findItem(parent);
- if (parentItem == null) return Status.OK_STATUS;
- if ((parentItem instanceof Item) && !getExpanded((Item) parentItem)) {
- refresh(parent); // flush cached stuff so next call will show new items
- } else if (multiSource.length > 0) {
- boolean addingConnections = (multiSource[0] instanceof IHost);
- // are we restoring connections previously removed due to making a profile inactive,
- // and is one of these connections the one we were opened with?
- if (addingConnections && (_event.getParent() instanceof ISystemRegistry) && (inputProvider instanceof SystemEmptyListAPIProviderImpl)) {
- boolean done = false;
- for (int idx = 0; !done && (idx < multiSource.length); idx++) {
- if (multiSource[idx] == previousInputConnection) {
- done = true;
- setInputProvider(previousInputProvider);
- previousInput = null;
- previousInputProvider = null;
- }
- }
- 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.
- else if (addingConnections && (_event.getParent() instanceof ISystemRegistry) && !inputProvider.showingConnections()) return Status.OK_STATUS;
-
- for (int idx = 0; idx < multiSource.length; idx++) {
- if (debug && addingConnections) logDebugMsg("... new connection " + ((IHost) multiSource[idx]).getAliasName()); //$NON-NLS-1$
- createTreeItem(parentItem, multiSource[idx], -1);
- }
- setSelection(new StructuredSelection(multiSource), true);
- }
- break;
- case ISystemResourceChangeEvents.EVENT_REPLACE_CHILDREN:
- if (debug) {
- logDebugMsg("SV event: EVENT_REPLACE_CHILDREN"); //$NON-NLS-1$
- }
- multiSource = _event.getMultiSource();
- //logDebugMsg("MULTI-SRC LENGTH : " + multiSource.length);
- clearSelection();
- parentItem = findItem(parent);
- 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
- //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?
- if (kids != null) for (int idx = 0; idx < kids.length; idx++)
- kids[idx].dispose();
- //boolean addingConnections = (multiSource[0] instanceof SystemConnection);
- for (int idx = 0; idx < multiSource.length; idx++) {
- //if (debug && addingConnections)
- // logDebugMsg("... new connection " + ((SystemConnection)multiSource[idx]).getAliasName());
- createTreeItem(parentItem, multiSource[idx], -1);
- }
- getControl().setRedraw(true);
- //setSelection(new StructuredSelection(multiSource),true);
- }
- break;
- case ISystemResourceChangeEvents.EVENT_CHANGE_CHILDREN:
- if (debug) {
- logDebugMsg("SV event: EVENT_CHANGE_CHILDREN. src=" + src + ", parent=" + parent); //$NON-NLS-1$ //$NON-NLS-2$
- //Exception e = new Exception();
- //e.fillInStackTrace();
- //e.printStackTrace();
- }
- // I HAVE DECIDED TO CHANGE THE SELECTION ALGO TO ONLY RESELECT IF THE CURRENT
- // SELECTION IS A CHILD OF THE PARENT... PHIL
- boolean wasSrcSelected = false;
- if (src != null) {
- wasSrcSelected = isSelectedOrChildSelected(src);
- //System.out.println("WAS SELECTED? " + wasSrcSelected);
- }
- item = findItem(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
- // WILL TELL ME IF A TREE ITEM IS SHOWING OR NOT!
- if ((item != null) && (item instanceof TreeItem) && ((TreeItem) item).getExpanded()) {
- if (wasSrcSelected) {
- //System.out.println("...Clearing selection");
- clearSelection();
- }
- //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
- setExpandedState(parent, true); // expand the parent
- getControl().setRedraw(true);
- if (wasSrcSelected) {
- //System.out.println("Setting selection to " + src);
- setSelection(new StructuredSelection(src), true);
- }
- } else
- collapseNode(parent, true);
- break;
- case ISystemResourceChangeEvents.EVENT_DELETE:
- if (debug) logDebugMsg("SV event: EVENT_DELETE "); //$NON-NLS-1$
- // are we a secondary perspective, and our input or parent of our input was deleted?
- if (affectsInput(src)) {
- close();
- return Status.OK_STATUS;
- }
- parentItem = findItem(parent);
- if (parentItem == null) return Status.OK_STATUS;
- if ((parentItem instanceof Item) && !getExpanded((Item) parentItem))
- refresh(parent); // flush memory
- else {
- wasSelected = isSelectedOrChildSelected(src);
- if (wasSelected) clearSelection();
- _originatingViewer.remove(src);
- if (wasSelected) setSelection(new StructuredSelection(parent), true);
- }
- break;
-
- case ISystemResourceChangeEvents.EVENT_DELETE_MANY:
- if (debug) {
- logDebugMsg("SV event: EVENT_DELETE_MANY "); //$NON-NLS-1$
- }
- multiSource = _event.getMultiSource();
- // are we a secondary perspective, and our input or parent of our input was deleted?
- if (affectsInput(multiSource)) {
- close();
- return Status.OK_STATUS;
- }
- if (parent != null) {
- parentItem = findItem(parent);
- } else {
- // find first parentItem for source
- if (multiSource != null && multiSource.length > 0) {
- Widget sitem = findItem(multiSource[0]);
- if (sitem instanceof TreeItem) {
- parentItem = ((TreeItem)sitem).getParentItem();
- if (parentItem == null) {
- parentItem = ((TreeItem)sitem).getParent();
- }
- }
- }
- }
- if (parentItem == null) {
- return Status.OK_STATUS;
- }
- if ((parentItem instanceof Item) && !getExpanded((Item) parentItem)) {
- refresh(parent); // flush memory
- } else if (parentItem instanceof Tree) {
- if (_originatingViewer != null) {
- _originatingViewer.remove(multiSource);
- }
- } else {
- wasSelected = isSelectedOrChildSelected(multiSource);
- if (wasSelected) {
- clearSelection();
- }
- if (_originatingViewer != null) {
- _originatingViewer.remove(multiSource);
- }
- if (wasSelected) {
- setSelection(parent != null ? new StructuredSelection(parent) : null, true);
- }
- }
- break;
- /* Now done below in systemRemoteResourceChanged
- case EVENT_DELETE_REMOTE:
- if (debug)
- logDebugMsg("SV event: EVENT_DELETE_REMOTE ");
- deleteRemoteObject(src);
- break;
-
- case EVENT_DELETE_REMOTE_MANY:
- // multi-source: array of objects to delete
- if (debug)
- 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<multiSource.length; idx++)
- deleteRemoteObject(multiSource[idx]);
- break;
- */
- case ISystemResourceChangeEvents.EVENT_RENAME:
- if (debug) logDebugMsg("SV event: EVENT_RENAME "); //$NON-NLS-1$
- properties[0] = IBasicPropertyConstants.P_TEXT;
- update(src, properties); // for refreshing non-structural properties in viewer when model changes
- updatePropertySheet();
- break;
- /* Now done below in systemRemoteResourceChanged
- case EVENT_RENAME_REMOTE:
- // SRC: the updated remote object, after the rename
- // PARENT: the String from calling getAbsoluteName() on the remote adapter BEFORE updating the remote object's name
- if (debug)
- logDebugMsg("SV event: EVENT_RENAME_REMOTE ");
-
- renameRemoteObject(src, (String)parent);
- break;
- */
- case ISystemResourceChangeEvents.EVENT_ICON_CHANGE:
- if (debug) logDebugMsg("SV event: EVENT_ICON_CHANGE "); //$NON-NLS-1$
-
- if (initViewerFilters != null && initViewerFilters.length > 0) {
- Widget w = findItem(src);
- if (w == null) {
- refresh(parent);
- } else {
- properties[0] = IBasicPropertyConstants.P_IMAGE;
- update(src, properties); // for refreshing non-structural properties in viewer when model changes
-
- }
- } else {
- properties[0] = IBasicPropertyConstants.P_IMAGE;
- update(src, properties); // for refreshing non-structural properties in viewer when model changes
- }
-
- //updatePropertySheet();
- break;
- //case EVENT_CHANGE:
- //if (debug)
- //logDebugMsg("SV event: EVENT_CHANGE ");
- //refresh(src); THIS IS AN EVIL OPERATION: CAUSES ALL EXPANDED NODES TO RE-REQUEST THEIR CHILDREN. OUCH!
- //updatePropertySheet();
- //break;
- case ISystemResourceChangeEvents.EVENT_REFRESH:
- if (debug) logDebugMsg("SV event: EVENT_REFRESH "); //$NON-NLS-1$
- //if (src != null)
- // refresh(src); // ONLY VALID WHEN USER TRULY WANTS TO REQUERY CHILDREN FROM HOST
- //else
- // refresh(); // refresh entire tree
- if ((src == null) || (src == RSEUIPlugin.getTheSystemRegistryUI()))
- refreshAll();
- else {
- //FIXME Why do we forceRemote here? EVENT_REFRESH_SELECTED also does not do forceRemote.
- //smartRefresh(src, false);
- smartRefresh(src, true);
- }
- updatePropertySheet();
- break;
- // refresh the parent of the currently selected items.
- // todo: intelligently re-select previous selections
- case ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED_PARENT:
- if (debug) logDebugMsg("SV event: EVENT_REFRESH_SELECTED_PARENT "); //$NON-NLS-1$
- TreeItem[] items = getTree().getSelection();
- if ((items != null) && (items.length > 0) && (items[0] != null)) {
- //System.out.println("Selection not empty");
- parentItem = getParentItem(items[0]); // get parent of first selection. Only allowed to select items of same parent.
- if ((parentItem != null) && (parentItem instanceof Item)) {
- //System.out.println("parent of selection not empty: "+parentItem.getData());
- smartRefresh(new TreeItem[] { (TreeItem) parentItem });
- }
- //else
- //System.out.println("parent of selection is empty");
- }
- //else
- //System.out.println("Selection is empty");
- break;
- case ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED:
- if (debug) logDebugMsg("SV event: EVENT_REFRESH_SELECTED "); //$NON-NLS-1$
- IStructuredSelection selected = (IStructuredSelection) getSelection();
- Iterator i = selected.iterator();
- // the following is a tweak. Refresh only re-queries the children. If the selected item has no
- // childen, then refresh does nothing. Instead of that outcome, we re-define it to mean refresh
- // the parent. The tricky part is to prevent multiple refreshes on multiple selections so we have
- // to pre-scan for this scenario.
- // We also want to re-select any remote objects currently selected. They lose their selection as their
- // memory address changes.
- Item parentElementItem = null;
- List selectedRemoteObjects = new Vector();
- items = getTree().getSelection();
- int itemIdx = 0;
- //System.out.println("Inside EVENT_REFRESH_SELECTED. FIRST SELECTED OBJECT = " + items[0].handle);
- while (i.hasNext()) {
-
- Object element = i.next();
- ISystemViewElementAdapter adapter = _originatingViewer.getViewAdapter(element);
- if ((parentElementItem == null) && (adapter != null) && (!adapter.hasChildren((IAdaptable)element))) {
- //parentItem = getParentItem((Item)findItem(element));
- parentItem = getParentItem(items[itemIdx]);
- if ((parentItem != null) && (parentItem instanceof Item)) parentElementItem = (Item) parentItem; //.getData();
- }
- if (getViewAdapter(element) != null) {
- selectedRemoteObjects.add(element);
- if (ss == null) ss = getViewAdapter(element).getSubSystem(element);
- }
- itemIdx++;
- }
- if (parentElementItem != null) {
- //refresh(parentElement);
- //FIXME IF a multi-select contains elements with a different parent than the one found, they will be ignored.
- smartRefresh(new TreeItem[] { (TreeItem) parentElementItem });
- if (selectedRemoteObjects.size() > 0) {
- selectRemoteObjects(selectedRemoteObjects, ss, parentElementItem);
- }
- }
- // the following is another tweak. If an expanded object is selected for refresh, which has remote children,
- // and any of those children are expanded, then on refresh the resulting list may be in a different
- // order and the silly algorithm inside tree viewer will simply re-expand the children at the previous
- // relative position. If that position has changed, the wrong children are re-expanded!
- // How to fix this? Ugly code to get the query the list of expanded child elements prior to refresh,
- // collapse them, do the refresh, then re-expand them based on absolute name versus tree position.
- // Actually, to do this right we need to test if the children of the selected item are remote objects
- // versus just the selected items because they may have selected a filter!
- // We go straight the TreeItem level for performance and ease of programming.
- else {
- smartRefresh(getTree().getSelection());
- }
- //else
- //{
- //i = selected.iterator();
- //while (i.hasNext())
- //refresh(i.next());
- //}
-
- updatePropertySheet();
- break;
- case ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED_FILTER:
- if (debug) logDebugMsg("SV event: EVENT_REFRESH_SELECTED_FILTER "); //$NON-NLS-1$
- IStructuredSelection selectedItems = (IStructuredSelection) getSelection();
- Iterator j = selectedItems.iterator();
- // We climb up the tree here until we find a SystemFilterReference data member in the tree.
- // If we do find a reference of SystemFilterReference we refresh on it.
- // If we do not find a reference of SystemFilterReference we.....TODO: WHAT DO WE DO???
- // We also want to re-select any remote objects currently selected. They lose their selection as their
- // memory address changes.
- Item parentElemItem = null;
- List selRemoteObjects = new Vector();
- if (j.hasNext()) {
- Object element = j.next();
- ISystemViewElementAdapter adapter = _originatingViewer.getViewAdapter(element);
- if (adapter != null) {
- Item parItem = getParentItem((Item) findItem(element));
-
- if (parItem != null) parentElemItem = parItem; //.getData();
-
- while (parItem != null && !(parItem.getData() instanceof ISystemFilterReference)) {
- parItem = getParentItem(parItem);
-
- if (parItem != null) parentElemItem = parItem; //.getData();
- }
- }
- if (getViewAdapter(element) != null) {
- selRemoteObjects.add(element);
- ss = getViewAdapter(element).getSubSystem(element);
- }
- }
-
- if (parentElemItem != null && (parentElemItem.getData() instanceof ISystemFilterReference)) {
- smartRefresh(new TreeItem[] { (TreeItem) parentElemItem });
- if (selRemoteObjects.size() > 0) {
- selectRemoteObjects(selRemoteObjects, ss, parentElemItem);
- }
-
- updatePropertySheet();
- } else {
- // if we cannot find a parent element that has a system filter reference then we refresh
- // everything since the explorer must be within a filter
- _event.setType(ISystemResourceChangeEvents.EVENT_REFRESH);
- systemResourceChanged(_event);
- }
- break;
- case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE:
- if (debug) logDebugMsg("SV event: EVENT_REFRESH_REMOTE: src = " + src); //$NON-NLS-1$
-
- // Fake expanded is set to the item for the src object if the object is in a collapsed state and
- // resides directly under a filter. The item is artificially expanded in order to allow
- // refreshRemoteObject() to go through with a query of the item. After the query is kicked off,
- // fakeExpanded is contracted in order to retain the original tree expand state.
- TreeItem fakeExpanded = null;
-
- ISystemViewElementAdapter adapter = getViewAdapter(src);
- if (adapter != null)
- {
- // we need to refresh filters
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
-
- // if this is a filter reference, we just need to refresh it
- if (src instanceof ISystemFilterReference)
- {
- refresh(src);
- break;
- }
-
- // need to find filter references contain this object
- List filterReferences = sr.findFilterReferencesFor(src, adapter.getSubSystem(src), false);
-
- // first, find out if src is a container or not
- // if it's a container, just pass into refreshRemoteObject
- // if it's NOT a container, pass in it's parent
- boolean hasChildren = adapter.hasChildren((IAdaptable)src);
- if (!hasChildren && !(src instanceof ISubSystem))
- {
- // make the src the parent of the src
- Object srcParent = adapter.getParent(src);
- if (srcParent != null)
- {
- if (filterReferences.size() > 0){
- for (int r = 0; r < filterReferences.size(); r++){
- ISystemFilterReference ref = (ISystemFilterReference)filterReferences.get(r);
- refresh(ref);
- }
- break;
- }
- else {
- src = srcParent;
- }
-
- }
- }
- else
- {
- // only do this if the object is "remote"
- if (adapter.isRemote(src))
- {
- // get up-to-date version of the container (need to make sure it still exists)
- if (ss == null)
- {
- ss = adapter.getSubSystem(src);
- }
- if (ss != null)
- {
- // for bug 196662
- // if we're refreshing a previously unexpanded node, then a query will not happen
- // so we should refresh it's parent in this case
- Widget w = findItem(src);
- if (w instanceof TreeItem)
- {
- TreeItem titem = (TreeItem)w;
- TreeItem[] titems = titem.getItems();
- if (titems.length > 0 && !titem.getExpanded())
- {
- // the item is artificially expanded in order to allow the query to go through in
- // refreshRemoteObject()
- titem.setExpanded(true);
-
- // we set this so that after calling refreshRemoteObject(), the item can be re-collapsed
- fakeExpanded = titem;
- }
- }
- }
- }
- }
- }
-
- refreshRemoteObject(src, parent, originatedHere);
- if (fakeExpanded != null){
- fakeExpanded.setExpanded(false);
- }
-
- break;
- case ISystemResourceChangeEvents.EVENT_SELECT_REMOTE:
- if (debug) logDebugMsg("SV event: EVENT_SELECT_REMOTE: src = " + src); //$NON-NLS-1$
- //remoteItemsToSkip = null; // reset
- selectRemoteObjects(src, (ISubSystem) null, parent);
- break;
-
- case ISystemResourceChangeEvents.EVENT_MOVE_MANY:
- if (debug) logDebugMsg("SV event: EVENT_MOVE_MANY "); //$NON-NLS-1$
- multiSource = _event.getMultiSource();
- if ((multiSource == null) || (multiSource.length == 0)) return Status.OK_STATUS;
- parentItem = findItem(parent);
- if (parentItem == null) return Status.OK_STATUS;
- if ((parentItem instanceof Item) && !getExpanded((Item) parentItem))
- refresh(parent); // flush memory
- else {
- clearSelection();
- moveTreeItems(parentItem, multiSource, _event.getPosition());
- setSelection(new StructuredSelection(multiSource), true);
- }
- break;
- case ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE:
- if (debug) logDebugMsg("SV event: EVENT_PROPERTY_CHANGE "); //$NON-NLS-1$
- String[] allProps = { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE };
- ISystemRemoteElementAdapter ra = (ISystemRemoteElementAdapter)((IAdaptable)src).getAdapter(ISystemRemoteElementAdapter.class);
- if (ra != null) {
- updateRemoteObjectProperties(src);
- } else
- update(src, allProps); // for refreshing non-structural properties in viewer when model changes
- updatePropertySheet();
- break;
- case ISystemResourceChangeEvents.EVENT_PROPERTYSHEET_UPDATE:
- if (debug) logDebugMsg("SV event: EVENT_PROPERTYSHEET_UPDATE "); //$NON-NLS-1$
- updatePropertySheet();
- break;
- case ISystemResourceChangeEvents.EVENT_MUST_COLLAPSE:
- if (debug) logDebugMsg("SV event: EVENT_MUST_COLLAPSE "); //$NON-NLS-1$
- collapseNode(src, true); // collapse and flush gui widgets from memory
- break;
- case ISystemResourceChangeEvents.EVENT_COLLAPSE_ALL:
- if (debug) logDebugMsg("SV event: EVENT_COLLAPSE_ALL "); //$NON-NLS-1$
- collapseAll(); // collapse all
- if ((src != null) && (src instanceof String) && ((String) src).equals("false")) // defect 41203 //$NON-NLS-1$
- {
- } else
- refresh(); // flush gui widgets from memory
- break;
- case ISystemResourceChangeEvents.EVENT_COLLAPSE_SELECTED: // defect 41203
- if (debug) logDebugMsg("SV event: EVENT_COLLAPSE_SELECTED "); //$NON-NLS-1$
- collapseSelected();
- break;
- case ISystemResourceChangeEvents.EVENT_EXPAND_SELECTED: // defect 41203
- if (debug) logDebugMsg("SV event: EVENT_EXPAND_SELECTED "); //$NON-NLS-1$
- expandSelected();
- break;
-
- case ISystemResourceChangeEvents.EVENT_REVEAL_AND_SELECT:
- if (debug) logDebugMsg("SV event: EVENT_REVEAL_AND_SELECT "); //$NON-NLS-1$
- parentItem = findItem(parent);
- if (parentItem == null) return Status.OK_STATUS;
- if ((parentItem instanceof Item) && !getExpanded((Item) parentItem)) {
- setExpandedState(parent, true);
- Object toSelect = src;
- //if (event.getMultiSource() != null)
- //toSelect = event.getMultiSource();
- //clearSelection();
- if (toSelect != null) {
- if (parent instanceof IRSEBaseReferencingObject) {
- TreeItem child = (TreeItem) internalFindReferencedItem(parentItem, toSelect, 1);
- if (child != null) toSelect = child.getData();
- } else if ((parent instanceof ISystemFilterPoolReferenceManagerProvider) && !(src instanceof IRSEBaseReferencingObject)) {
- // we are in "don't show filter pools" mode and a new filter was created
- // (we get the actual filter, vs on pool ref creation when we get the pool ref)
- TreeItem child = (TreeItem) internalFindReferencedItem(parentItem, toSelect, 1);
- if (child != null) toSelect = child.getData();
- }
- setSelection(new StructuredSelection(toSelect), true);
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_SELECT:
- if (debug) logDebugMsg("SV event: EVENT_SELECT "); //$NON-NLS-1$
- item = findItem(src);
- if (item == null) // if not showing item, this is a no-op
- return Status.OK_STATUS;
- setSelection(new StructuredSelection(src), true);
- break;
- case ISystemResourceChangeEvents.EVENT_SELECT_EXPAND:
- if (debug) logDebugMsg("SV event: EVENT_SELECT_EXPAND "); //$NON-NLS-1$
- item = findItem(src);
- if (item == null) // if not showing item, this is a no-op
- return Status.OK_STATUS;
- if (!getExpanded((Item) item)) setExpandedState(src, true);
- setSelection(new StructuredSelection(src), true);
- break;
-
- }
- return Status.OK_STATUS;
- }
- }
-
- // ------------------------------------
- // ISYSTEMREMOTEChangeListener METHOD
- // ------------------------------------
-
-
- private static class CheckPending implements Runnable
- {
- private boolean _notReady = true;
- private TreeItem _item;
-
- public CheckPending(TreeItem item)
- {
- _item = item;
- }
-
- public void run()
- {
- if (_item.isDisposed()) {
- // Parent was deleted in the meantime
- _notReady = false;
- } else {
- Item[] items = _item.getItems();
- // We know that a child must appear eventualy, because the
- // REMOTE_RESOURCE_CREATED event is only sent in case of
- // successful creation of the element.
- _notReady = (items.length <= 0 || ProgressMessages.PendingUpdateAdapter_PendingLabel.equals(items[0].getText()));
- }
- }
-
- public boolean isNotReady()
- {
- return _notReady;
- }
- }
-
- /**
- * 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.
- * @see org.eclipse.rse.core.events.ISystemRemoteChangeEvent
- */
- public void systemRemoteResourceChanged(ISystemRemoteChangeEvent event) {
- int eventType = event.getEventType();
- Object remoteResourceParent = event.getResourceParent();
- Object remoteResource = event.getResource();
- boolean originatedHere;
-
- if (event instanceof SystemResourceChangeEventUI) {
- Viewer viewer = ((SystemResourceChangeEventUI)event).getOriginatingViewer();
- originatedHere = (viewer==this);
- }
- else if (event instanceof SystemRemoteChangeEvent){
- Object viewer = ((SystemRemoteChangeEvent)event).getOriginatingViewer();
- originatedHere = (viewer==this);
- }
- else {
- originatedHere = false;
- }
-
- List remoteResourceNames = null;
- if (remoteResource instanceof List) {
- remoteResourceNames = (List) remoteResource;
- remoteResource = remoteResourceNames.get(0);
- }
- // getRemoteResourceAbsoluteName(remoteResourceParent); // DWD may not be necessary
- String remoteResourceName = getRemoteResourceAbsoluteName(remoteResource);
- if (remoteResourceName == null) return;
-
- ISubSystem ss = getSubSystem(event, remoteResource, remoteResourceParent);
-
- List filterMatches = null;
-
- switch (eventType) {
- // --------------------------
- // REMOTE RESOURCE CHANGED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CHANGED:
- updatePropertySheet(); // just in case
- break;
- // --------------------------
- // REMOTE RESOURCE CREATED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED:
- // we can easily lose our original selection so we need save and restore it if needed
- List prevSelection = null;
- TreeItem parentSelectionItem = null;
- if (originatedHere) {
- prevSelection = getRemoteSelection();
- parentSelectionItem = getSelectedParentItem();
- }
-
- // when a new remote resource is created, we need to interrogate all filters
- // within connections to the same hostname, to see if the filter results are
- // affected by this change. If so, we refresh the filter.
- filterMatches = findAllRemoteItemFilterReferences(remoteResourceName, ss, null);
- ArrayList selectedFilters = null;
- if (filterMatches != null) {
- for (int idx = 0; idx < filterMatches.size(); idx++) {
- FilterMatch match = (FilterMatch) filterMatches.get(idx);
- TreeItem filterItem = match.getTreeItem();
- if (isTreeItemSelected(filterItem)) // if this filter is currently selected, we will lose that selection!
- {
- if (selectedFilters == null) selectedFilters = new ArrayList();
- selectedFilters.add(filterItem);
- }
- smartRefresh(new TreeItem[] { filterItem }, null, true);
- }
- }
- // now, refresh all occurrences of the remote parent object.
- refreshRemoteObject(remoteResourceParent, null, false);
- // restore selected filters...
- if (selectedFilters != null) setSelection(selectedFilters);
- // if the create event originated here, then expand the selected node and
- // select the new resource under it.
- if (originatedHere){
- // first, restore previous selection...
- if (prevSelection != null) selectRemoteObjects(prevSelection, ss, parentSelectionItem);
- TreeItem selectedItem = getFirstSelectedTreeItem();
- if (selectedItem != null)
- {
- Object data = selectedItem.getData();
- boolean allowExpand = true;
- ISystemViewElementAdapter adapter = getViewAdapter(data);
-
- if (adapter != null && data instanceof IAdaptable)
- {
- allowExpand = adapter.hasChildren((IAdaptable)data);
- }
- if (allowExpand && !selectedItem.getExpanded()) // if the filter is expanded, then we already refreshed it...
- {
- createChildren(selectedItem);
- selectedItem.setExpanded(true);
- }
- if (adapter.supportsDeferredQueries(ss))
- {
- final List names = remoteResourceNames;
- final String name = remoteResourceName;
- final ISubSystem subsys = ss;
- final TreeItem item = selectedItem;
- final IWorkbench wb = RSEUIPlugin.getDefault().getWorkbench();
-
- // do the selection after the query triggered via refreshRemoteObject() completes
- Job job = new Job("select resource") //$NON-NLS-1$
- {
- public IStatus run(IProgressMonitor monitor) {
-
- boolean notReady = true;
- while (notReady && !wb.isClosing())
- {
- try {
- Thread.sleep(100);
- }
- catch (InterruptedException e){}
-
- CheckPending checkRunnable = new CheckPending(item);
- wb.getDisplay().syncExec(checkRunnable);
- notReady = checkRunnable.isNotReady();
- }
-
- wb.getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- if (!wb.isClosing() && !item.isDisposed()) {
- if (names != null)
- selectRemoteObjects(names, subsys, item);
- else
- selectRemoteObjects(name, subsys, item);
- }
- }
- });
-
- return Status.OK_STATUS;
- }
- };
- job.setSystem(true);
- job.schedule();
- }
- else {
- if (remoteResourceNames != null)
- selectRemoteObjects(remoteResourceNames, ss, selectedItem);
- else
- selectRemoteObjects(remoteResourceName, ss, selectedItem);
- }
- }
- //else
- //System.out.println("Hmm, nothing selected");
- }
- break;
- // --------------------------
- // REMOTE RESOURCE DELETED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED:
- // delete all existing references to the remote object(s)...
- if (remoteResourceNames != null) {
- for (int idx = 0; idx < remoteResourceNames.size(); idx++)
- deleteRemoteObject(remoteResourceNames.get(idx), ss);
- } else
- deleteRemoteObject(remoteResourceName, ss);
-
- // now, find all filters that either list this remote resource or list the contents of it,
- // if it is a container... for expediency we only test for the first resource, even if given
- // a list of them...
- filterMatches = findAllRemoteItemFilterReferences(remoteResourceName, ss, null);
- if (filterMatches != null) {
- for (int idx = 0; idx < filterMatches.size(); idx++) {
- FilterMatch match = (FilterMatch) filterMatches.get(idx);
- TreeItem filterItem = match.getTreeItem();
- if (match.listsElement()) {
- // if the filter is expanded, we are ok. If not, we need to flush its memory...
- if (!getExpanded(filterItem)) refresh(filterItem.getData());
- } else // else this filter lists the contents of the deleted container element, so refresh it:
- {
- // if the filter is not expanded, we need to flush its memory...
- if (!getExpanded(filterItem))
- refresh(filterItem.getData());
- else
- // if the filter is expanded, we need to refresh it
- smartRefresh(new TreeItem[] { filterItem }, null, true);
- }
- }
- }
-
- break;
-
- // --------------------------
- // REMOTE RESOURCE RENAMED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED:
- // we can easily lose our original selection so we need save and restore it if needed
- prevSelection = null;
- parentSelectionItem = null;
- if (originatedHere) {
- prevSelection = getRemoteSelection();
- parentSelectionItem = getSelectedParentItem();
- }
-
- // rename all existing references to the remote object...
- renameRemoteObject(remoteResource, event.getOldNames()[0], ss); // assuming only one resource renamed
-
- // refresh remoteResource if it's a directory
- ISystemViewElementAdapter adapter = getViewAdapter(remoteResource);
- if (remoteResource instanceof IAdaptable && adapter.hasChildren((IAdaptable) remoteResource)) {
- refreshRemoteObject(remoteResource, remoteResource, originatedHere);
- }
-
- // now, find all filters that list the contents of the OLD name container.
- filterMatches = findAllRemoteItemFilterReferences(event.getOldNames()[0], ss, null); // assuming only one resource renamed
- if (filterMatches != null) {
- for (int idx = 0; idx < filterMatches.size(); idx++) {
- FilterMatch match = (FilterMatch) filterMatches.get(idx);
- TreeItem filterItem = match.getTreeItem();
- if (match.listsElementContents()) // this filter lists the contents of the renamed container element, so refresh it:
- {
- // if the filter is not expanded, we need only flush its memory...
- if (!getExpanded(filterItem))
- refresh(filterItem.getData());
- else
- // the filter is expanded, so refresh its contents. This will likely result in an empty list
- smartRefresh(new TreeItem[] { filterItem }, null, true);
- }
- }
- }
- // now, find all filters that list the contents of the NEW name container.
- filterMatches = findAllRemoteItemFilterReferences(remoteResourceName, ss, null);
- if (filterMatches != null) {
- for (int idx = 0; idx < filterMatches.size(); idx++) {
- FilterMatch match = (FilterMatch) filterMatches.get(idx);
- TreeItem filterItem = match.getTreeItem();
- if (match.listsElementContents()) // this filter lists the contents of the renamed container element, so refresh it:
- {
- // if the filter is not expanded, we need only flush its memory...
- if (!getExpanded(filterItem))
- refresh(filterItem.getData());
- else
- // the filter is expanded, so refresh its contents. This will likely result in an empty list
- smartRefresh(new TreeItem[] { filterItem }, null, true);
- }
- }
- }
-
- // restore selection
- if (originatedHere && (prevSelection != null)) {
- selectRemoteObjects(prevSelection, ss, parentSelectionItem);
- updatePropertySheet(); // just in case
- }
- break;
- }
- }
-
- /**
- * Turn selection into an array of remote object names
- */
- protected List getRemoteSelection() {
- List prevSelection = null;
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator i = selection.iterator();
- while (i.hasNext()) {
- Object element = i.next();
- ISystemViewElementAdapter ra = getViewAdapter(element);
- if (ra != null) {
- if (prevSelection == null) prevSelection = new Vector();
- prevSelection.add(ra.getAbsoluteName(element));
- }
- }
- return prevSelection;
- }
-
- /**
- * Turn a given remote object reference into a fully qualified absolute name
- */
- protected String getRemoteResourceAbsoluteName(Object remoteResource) {
- if (remoteResource == null) return null;
- String remoteResourceName = null;
- if (remoteResource instanceof String)
- remoteResourceName = (String) remoteResource;
- else {
- ISystemViewElementAdapter ra = getViewAdapter(remoteResource);
- if (ra == null) return null;
- remoteResourceName = ra.getAbsoluteName(remoteResource);
- }
- return remoteResourceName;
- }
-
- /**
- * Deduce the subsystem from the event or remote object
- */
- protected ISubSystem getSubSystem(ISystemRemoteChangeEvent event, Object remoteResource, Object remoteParent) {
- if (event.getSubSystem() != null) return event.getSubSystem();
- ISubSystem ss = null;
- if ((remoteResource != null) && !(remoteResource instanceof String)) {
- if (remoteResource instanceof List) {
- List v = (List) remoteResource;
- if (v.size() > 0) ss = getSubSystem(event, v.get(0), null);
- } else {
- ISystemViewElementAdapter ra = getViewAdapter(remoteResource);
- if (ra != null) ss = ra.getSubSystem(remoteResource);
- }
- }
- if ((ss == null) && (remoteParent != null) && !(remoteParent instanceof String)) {
- if (remoteParent instanceof List) {
- List v = (List) remoteParent;
- if (v.size() > 0) ss = getSubSystem(event, null, v.get(0));
- } else {
- ISystemViewElementAdapter ra = getViewAdapter(remoteParent);
- if (ra != null) ss = ra.getSubSystem(remoteParent);
- }
- }
- return ss;
- }
-
- // ------------------------------------
- // MISCELLANEOUS METHODS...
- // ------------------------------------
-
- /**
- * Close us!
- */
- protected void close() {
- previousInputProvider = inputProvider;
- previousInput = getWorkbenchPart().getSite().getPage().getInput();
- ISystemViewInputProvider ip = new SystemEmptyListAPIProviderImpl();
- setInputProvider(ip);
- }
-
- /**
- * Test if the given input is our view's input object. This is designed to only
- * consider instances of ourself in non-primary perspectives.
- */
- protected boolean affectsInput(Object[] elements) {
- boolean affected = false;
- IWorkbenchPart viewPart = getWorkbenchPart();
- if ((viewPart != null) && (getInput() != RSECorePlugin.getTheSystemRegistry()) && !(getInput() instanceof SystemEmptyListAPIProviderImpl)) {
- for (int idx = 0; !affected && (idx < elements.length); idx++)
- affected = affectsInput(elements[idx]);
- }
- return affected;
- }
-
- /**
- * Test if the given input is our view's input object. This is designed to only
- * consider instances of ourself in non-primary perspectives.
- */
- protected boolean affectsInput(Object element) {
- boolean affected = false;
- IWorkbenchPart viewPart = getWorkbenchPart();
- if ((viewPart != null) && (getInput() != RSECorePlugin.getTheSystemRegistry()) && !(getInput() instanceof SystemEmptyListAPIProviderImpl)) {
-
- Object input = viewPart.getSite().getPage().getInput();
- if (input != null) {
- Object referencedElement = getReferencedObject(element);
- Object referencedInput = getReferencedObject(input);
- //System.out.println("TESTING1 " + input + " vs " + element);
- //System.out.println("TESTING2 " + referencedInput + " vs " + referencedElement);
- if ((input == element) || (referencedInput == referencedElement))
- affected = true;
- else {
- while (!affected && (input != null)) {
- input = getElementParent(input);
- if (input != null) {
- referencedInput = getReferencedObject(input);
- //System.out.println("...TESTING1 " + input + " vs " + element);
- //System.out.println("...TESTING2 " + referencedInput + " vs " + referencedElement);
- affected = ((input == element) || (referencedInput == referencedElement));
- }
- }
- }
- }
- }
- return affected;
- }
-
- protected Object getReferencedObject(Object inputObj) {
- if (inputObj instanceof ISystemFilterPoolReference)
- return ((ISystemFilterPoolReference) inputObj).getReferencedFilterPool();
- else if (inputObj instanceof ISystemFilterReference)
- return ((ISystemFilterReference) inputObj).getReferencedFilter();
- else if (inputObj instanceof ISystemFilterStringReference)
- return ((ISystemFilterStringReference) inputObj).getReferencedFilterString();
- else
- return inputObj;
- }
-
- protected Object getElementParent(Object inputObj) {
- if (inputObj instanceof IHost)
- return ((IHost) inputObj).getSystemProfile();
- else if (inputObj instanceof ISubSystem)
- return ((ISubSystem) inputObj).getHost();
- else if (inputObj instanceof ISystemFilterPoolReference)
- return ((ISystemFilterPoolReference) inputObj).getProvider(); // will be a subsystem
- else if (inputObj instanceof ISystemFilterPool)
- return ((ISystemFilterPool) inputObj).getProvider(); // will be a subsystem factory. Hmm!
- else if (inputObj instanceof ISystemFilterReference)
- return ((ISystemFilterReference) inputObj).getParent(); // will be filter reference or filter pool reference
- else if (inputObj instanceof ISystemFilter) {
- ISystemFilter filter = (ISystemFilter) inputObj;
- if (filter.getParentFilter() != null)
- return filter.getParentFilter();
- else
- return filter.getParentFilterPool();
- } else if (inputObj instanceof ISystemFilterStringReference)
- return ((ISystemFilterStringReference) inputObj).getParent(); // will be a SystemFilterReference
- else if (inputObj instanceof ISystemFilterString)
- return ((ISystemFilterString) inputObj).getParentSystemFilter();
- else
- return null;
- }
-
- protected IHost getInputConnection(Object inputObj) {
- if (inputObj instanceof IHost)
- return (IHost) inputObj;
- else if (inputObj instanceof ISubSystem)
- return ((ISubSystem) inputObj).getHost();
- else if (inputObj instanceof ISystemFilterPoolReference) {
- ISubSystem ss = (ISubSystem) ((ISystemFilterPoolReference) inputObj).getProvider(); // will be a subsystem
- if (ss == null) return null;
- return ss.getHost();
- } else if (inputObj instanceof ISystemFilterReference) {
- ISubSystem ss = (ISubSystem) ((ISystemFilterReference) inputObj).getProvider(); // will be a subsystem
- if (ss == null) return null;
- return ss.getHost();
- } else if (inputObj instanceof ISystemFilterStringReference) {
- ISubSystem ss = (ISubSystem) ((ISystemFilterStringReference) inputObj).getProvider(); // will be a subsystem
- if (ss == null) return null;
- return ss.getHost();
- } else
- return null;
- }
-
- /**
- * Handy debug method to print a tree item
- */
- protected String printTreeItem(Item item) {
- if (item == null)
- return ""; //$NON-NLS-1$
- else if (item instanceof TreeItem) {
- TreeItem ti = (TreeItem) item;
- return printTreeItem(ti.getParentItem()) + "/" + ti.getText(); //$NON-NLS-1$
- } else
- return item.toString();
- }
-
- /**
- * Delete all occurrences of a given remote object
- */
- protected void deleteRemoteObject(Object deleteObject, ISubSystem subsystem) {
- List matches = null;
- String oldElementName = null;
-
- // STEP 1: get the object's remote adapter and subsystem
- if (deleteObject instanceof String)
- oldElementName = (String) deleteObject;
- else {
- ISystemViewElementAdapter rmtAdapter = getViewAdapter(deleteObject);
- if (rmtAdapter == null) return;
- oldElementName = rmtAdapter.getAbsoluteName(deleteObject);
- subsystem = rmtAdapter.getSubSystem(deleteObject);
- }
- // STEP 2: find all references to the object
- matches = findAllRemoteItemReferences(oldElementName, deleteObject, subsystem, matches);
- if (matches == null) {
- //System.out.println("matches is null");
- return;
- }
-
- boolean wasSelected = false;
- Item parentItem = null;
-
- boolean dupes = false;
- Object prevData = null;
- for (int idx = 0; !dupes && (idx < matches.size()); idx++) {
- Item match = (Item) matches.get(idx);
- if ((match instanceof TreeItem) && !((TreeItem) match).isDisposed()) {
- if (match.getData() == prevData)
- dupes = true;
- else
- prevData = match.getData();
- }
- }
- //System.out.println("matches size = " + matches.size() + ", any binary duplicates? " + dupes);
-
- List toRemove = new ArrayList();
- // STEP 3: process all references to the object
- for (int idx = 0; idx < matches.size(); idx++) {
- Item match = (Item) matches.get(idx);
- //System.out.println("...match " + idx + ": TreeItem? " + (match instanceof TreeItem) + ", disposed? " + ((TreeItem)match).isDisposed());
- // a reference to this remote object
- if ((match instanceof TreeItem) && !((TreeItem) match).isDisposed()) {
- ((TreeItem) match).getParentItem(); // DWD may not be necessary
- //Object data = match.getData();
- if (!wasSelected) {
- //wasSelected = isSelectedOrChildSelected(data);
- wasSelected = isTreeItemSelectedOrChildSelected(match);
- if (wasSelected) {
- clearSelection();
- parentItem = ((TreeItem) match).getParentItem();
- //System.out.println("...current item was selected");
- }
- }
- if (dupes) // defect 46818
- { // if there are multiple references to the same binary object, ...
- //System.out.println(".....calling refresh(data) on this match");
- /*
- if (pItem!=null)
- smartRefresh(new TreeItem[] {pItem}); // just refresh the parent node
- else
- refreshAll();
- */
- disassociate(match);
- match.dispose();
- } else {
- toRemove.add(match);
- //System.out.println(".....calling remove(data) on this match");
- //remove(data); // remove this item from the tree
- }
- }
- }
-
- // do the remove now
- for (int i = 0; i < toRemove.size(); i++)
- {
- Item childItem = (Item)toRemove.get(i);
- disassociate(childItem);
- childItem.dispose();
- }
-
- // STEP 4: if we removed a selected item, select its parent
- if (wasSelected && (parentItem != null) && (parentItem instanceof TreeItem) && (parentItem.getData() != null)) {
- //System.out.println("Resetting selection to parent");
- setSelection(new StructuredSelection(parentItem.getData()), true);
- }
- return;
- }
-
- /**
- * Rename a remote object. Renames all references to it currently displayed in this tree.
- */
- protected void renameRemoteObject(Object renameObject, String oldElementName, ISubSystem subsystem) {
- String[] properties = new String[1];
- properties[0] = IBasicPropertyConstants.P_TEXT;
-
- // STEP 0: do we have the physical remote object that has been renamed? If so, update it directly
- /*
- Item item = (Item)findItem(renameObject);
- if (item != null)
- {
- update(renameObject, properties); // for refreshing non-structural properties in viewer when model changes
- if (item instanceof TreeItem)
- smartRefresh(new TreeItem[] {(TreeItem)item}); // we update the kids because they typically store references to their parent
- }
- */
-
- List matches = null;
-
- // STEP 1: get the object's remote adapter and subsystem
- String newElementName = null;
- ISystemViewElementAdapter rmtAdapter = null;
- if (renameObject instanceof String) {
- //FIXME How to get the adapter based on the String name?
- newElementName = (String)renameObject;
- } else {
- rmtAdapter = getViewAdapter(renameObject);
- subsystem = rmtAdapter.getSubSystem(renameObject);
- newElementName = rmtAdapter.getName(renameObject);
- }
-
- // STEP 2: find all references to the old name object
- matches = findAllRemoteItemReferences(oldElementName, renameObject, subsystem, matches);
- if (matches == null) return;
-
- TreeItem[] selected = getTree().getSelection();
- getTree().deselectAll();
-
- boolean refresh = false;
- // STEP 3: process all references to the old name object
- for (int idx = 0; idx < matches.size(); idx++) {
- Item match = (Item) matches.get(idx);
- // a reference to this remote object
- if ((match instanceof TreeItem) && !((TreeItem) match).isDisposed())
- {
- Object data = match.getData();
-
- ISystemRemoteElementAdapter remoteAdapter = (ISystemRemoteElementAdapter)((IAdaptable)data).getAdapter(ISystemRemoteElementAdapter.class);
-
- if (data != renameObject) // not a binary match
- {
- if (remoteAdapter != null)
- {
- // DKM - would be nice to eventually get rid of remote element adapter
- refresh = remoteAdapter.refreshRemoteObject(data, renameObject); // old, new
- }
- } else {
- refresh = true;
- }
-
- // rename explicitly here (since internalUpdate doesn't seem to have an effect
- match.setText(newElementName);
- //updateItem(match, renameObject);
- internalUpdate(match, data, properties);
-
- //update(data, properties); // for refreshing non-structural properties in viewer when model changes
- //System.out.println("Match found. refresh required? " + refresh);
-// if (refresh)
- //refreshRemoteObject(data,null,false);
- // smartRefresh(new TreeItem[] { (TreeItem) match });
- }
- }
-
- if (refresh)
- {
- // causes duplicates to appear when there are more than one rename objects
- //smartRefresh((TreeItem[])matches.toArray(new TreeItem[matches.size()]));
- getTree().setSelection(selected);
- }
-
- // STEP 4: update property sheet, just in case.
- updatePropertySheet();
-
- return;
- }
-
- /**
- * Update properties of remote object. Update all references to this object
- */
- protected void updateRemoteObjectProperties(Object remoteObject) {
- List matches = new Vector();
-
- // STEP 1: get the object's remote adapter and subsystem
- ISystemRemoteElementAdapter rmtAdapter = (ISystemRemoteElementAdapter)((IAdaptable)remoteObject).getAdapter(ISystemRemoteElementAdapter.class);
-
- ISubSystem subsystem = rmtAdapter.getSubSystem(remoteObject);
-
- // STEP 2: find all references to the object
- String oldElementName = rmtAdapter.getAbsoluteName(remoteObject);
- findAllRemoteItemReferences(oldElementName, remoteObject, subsystem, matches);
-
- // STEP 3: process all references to the object
- String[] allProps = { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE };
- for (int idx = 0; idx < matches.size(); idx++) {
- Item match = (Item) matches.get(idx);
- // a reference to this remote object
- if ((match instanceof TreeItem) && !((TreeItem) match).isDisposed()) {
- Object data = match.getData();
- if (data == remoteObject) // same binary object as given?
- update(data, allProps); // for refreshing non-structural properties in viewer when model changes
- else // match by name
- {
-
-
- rmtAdapter.refreshRemoteObject(data, remoteObject); // old, new
- update(data, allProps);
- }
- }
- }
-
- // STEP 4: update the property sheet in case we changed properties of first selected item
- updatePropertySheet();
- return;
- }
-
- /**
- * Refresh contents of remote container. Refreshes all references to this container including filters that
- * display the contents of this container.
- * @param remoteObject - either an actual remote object, or the absolute name of a remote object
- * @param toSelect - the child object to select after refreshing the given object. This will force the
- * object to be expanded, and then select this object which can be a remote object or absolute name of a
- * remote object. To simply force an expand of the remote object, without bothering to select a child,
- * pass an instance of SystemViewDummyObject.
- * @return true if a refresh done, false if given a non-remote object.
- */
- protected boolean refreshRemoteObject(Object remoteObject, Object toSelect, boolean originatedHere) {
- if (remoteObject == null) return false;
-
- // STEP 1: get the object's remote adapter and subsystem, or use its name if only given that
- ISystemViewElementAdapter rmtAdapter = null;
- ISubSystem subsystem = null;
- String oldElementName = null;
- boolean doesDeferredQueries = false;
- if (!(remoteObject instanceof String)) {
- rmtAdapter = getViewAdapter(remoteObject);
- if (rmtAdapter == null) return false;
- subsystem = rmtAdapter.getSubSystem(remoteObject);
- assert subsystem!=null : "EVENT_REFRESH_REMOTE outside subsystem"; //$NON-NLS-1$
- oldElementName = rmtAdapter.getAbsoluteName(remoteObject);
- doesDeferredQueries = rmtAdapter.supportsDeferredQueries(subsystem);
- } else
- oldElementName = (String) remoteObject;
-
- List matches = new Vector();
- // STEP 2: find all references to the object
- findAllRemoteItemReferences(oldElementName, remoteObject, subsystem, matches);
- if (matches.size()>0 && remoteObject instanceof String) {
- //TODO one String may reference multiple different context objects, so we should really iterate over all matches here
- //See javadoc of findAllRemoteItemReferences
- remoteObject = getFirstRemoteObject(matches);
- rmtAdapter = getViewAdapter(remoteObject);
- assert rmtAdapter!=null; //cannot happen because matches were result of String query
- if (rmtAdapter!=null) {
- subsystem = rmtAdapter.getSubSystem(remoteObject);
- assert subsystem!=null : "EVENT_REFRESH_REMOTE outside subsystem"; //$NON-NLS-1$
- doesDeferredQueries = rmtAdapter.supportsDeferredQueries(subsystem);
- }
- }
-
- if (remoteObject instanceof ISystemContainer) {
- ((ISystemContainer) remoteObject).markStale(true);
- }
-
- // STEP 3: process all references to the object
- boolean firstSelection = true;
- for (int idx = 0; idx < matches.size(); idx++) {
- Widget match = (Widget) matches.get(idx);
- // a reference to this remote object
- if ((match instanceof TreeItem) && !((TreeItem) match).isDisposed()) {
- TreeItem matchedItem = (TreeItem)match;
- Object data = matchedItem.getData();
- boolean wasExpanded = matchedItem.getExpanded();
-
-
-
- smartRefresh(new TreeItem[] { matchedItem }); // refresh the remote object
- if (firstSelection && // for now, we just select the first binary occurrence we find
- (data == remoteObject)) // same binary object as given?
- {
- firstSelection = false;
- if ((toSelect != null) && originatedHere)
- {
- boolean allowExpand = true;
- if (rmtAdapter != null && data instanceof IAdaptable)
- {
- allowExpand = rmtAdapter.hasChildren((IAdaptable)data);
- }
- if (allowExpand && wasExpanded && !getExpanded(matchedItem)) // assume if callers wants to select kids that they want to expand parent
- {
- createChildren(matchedItem);
- setExpanded(matchedItem, true);
- }
-
- // todo: handle cumulative selections.
- // STEP 4: If requested, select the kids in the newly refreshed object.
- // If the same binary object appears multiple times, select the kids in the first occurrence.
- // ... what else to do?
- // DKM - added wasExpanded check since we don't want to expand something that isn't already expanded
- if (!doesDeferredQueries && wasExpanded && !(toSelect instanceof SystemViewDummyObject)) {
- //selecting remote objects makes only sense if not deferred, because
- //in the deferred case the objects will be retrieved in a separate job.
- selectRemoteObjects(toSelect, null, match); // select the given kids in this parent
- }
- }
- }
- }
- }
- return true;
- }
-
- protected void doUpdateItem(final Item item, Object element)
- {
- // adding this because base eclipse version isn't renaming properly on duplicates
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (adapter != null && item != null && !item.isDisposed())
- {
- String oldText = item.getText();
- String newText = adapter.getText(element);
- if (oldText == null || !oldText.equals(newText))
- {
- //if (newText != null){
- item.setText(newText);
- //}
- }
- }
-
- super.doUpdateItem(item, element);
- }
-
- /**
- * Given the result TreeItems of findAllRemoteItemReferences,
- * return the Data of the first Item.
- */
- protected Object getFirstRemoteObject(List matches) {
- if ((matches == null) || (matches.size() == 0)) return null;
- Object firstRemote = matches.get(0);
- if (firstRemote != null) firstRemote = ((Item) firstRemote).getData();
- return firstRemote;
- }
-
- /**
- * Refreshes the tree starting at the given widget.
- *
- * @param widget the widget
- * @param element the element
- * @param doStruct <code>true</code> if structural changes are to be picked up,
- * and <code>false</code> if only label provider changes are of interest
- */
- protected void ourInternalRefresh(Widget widget, Object element, boolean doStruct, boolean forceRemote) {
- final Widget fWidget = widget;
- final Object fElement = element;
- final boolean fDoStruct = doStruct;
-
- // we have to take special care if one of our kids are selected and it is a remote object...
- if (forceRemote || (isSelectionRemote() && isTreeItemSelectedOrChildSelected(widget))) {
- if (!isTreeItemSelected(widget)) // it is one of our kids that is selected
- {
- //MOB cannot see why the selection is cleared here
- //clearSelection(); // there is nothing much else we can do. Calling code will restore it anyway hopefully
- doOurInternalRefresh(fWidget, fElement, fDoStruct, true);
- } else // it is us that is selected. This might be a refresh selected operation. TreeItem address won't change
- {
- doOurInternalRefresh(fWidget, fElement, fDoStruct, true);
- }
- } else {
- preservingSelection(new Runnable() {
- public void run() {
- doOurInternalRefresh(fWidget, fElement, fDoStruct, true);
- }
- });
- }
- }
-
- protected boolean isSelectionRemote() {
- ISelection s = getSelection();
- if (s instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection) s;
- Iterator it = ss.iterator();
- while (it.hasNext()) {
- if (getRemoteAdapter(it.next()) != null) {
- return true;
- }
- }
- }
- return false;
- }
-
- protected void doOurInternalRefresh(Widget widget, Object element, boolean doStruct, boolean firstCall) {
- if (widget instanceof Item) {
- Object data = element;
- if (data instanceof IContextObject) {
- data = ((IContextObject)data).getModelObject();
- }
- if (doStruct) {
- updatePlus((Item) widget, data);
- }
- updateItem(widget, data);
- }
-
- /* may cause performance issue in bug 238363
- * calling refresh on each child item means that we'll be doing update on it
- * which ends up making it a pending decoration change since it's an update on an
- * item that already has text
- // recurse
- Item[] children = getChildren(widget);
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- Widget item = children[i];
- Object data = item.getData();
- if (data instanceof IAdaptable && item instanceof TreeItem) {
- data = getContextObject((TreeItem)item);
- }
- if (data != null) doOurInternalRefresh(item, data, doStruct, false);
- }
- }
-*/
-
- if (firstCall) {
-
- internalRefresh(element);
- }
- }
-
- /**
- * Override of internalRefreshStruct so that we can account for context
- */
- protected void internalRefreshStruct(Widget widget, Object element, boolean updateLabels) {
- if (widget instanceof TreeItem)
- {
- ContextObjectWithViewer contextObject = getContextObject((TreeItem)widget);
- IRSECallback callback = null;
-
- ArrayList expandedChildren = new ArrayList();
- if (widget instanceof TreeItem){
- TreeItem currItem = (TreeItem)widget;
- gatherExpandedChildren(currItem, currItem, expandedChildren);
- }
-
- if (expandedChildren.size() > 0){
- callback = new ExpandRemoteObjects(expandedChildren);
- contextObject.setCallback(callback);
- }
-
- internalRSERefreshStruct(widget, contextObject, updateLabels);
- }
- else
- {
- internalRSERefreshStruct(widget, element, updateLabels);
- }
- }
-
- /**
- * This is used during RSE refresh - otherwise filters aren't applied during refresh
- * @param widget the widget to refresh
- * @param element the element to refresh
- * @param updateLabels whether to update labels (ends up being ignored and having the value of true)
- */
- private void internalRSERefreshStruct(Widget widget, Object element, boolean updateLabels)
- {
- updateChildren(widget, element, null); // DKM - using deprecated API because it's the only way to call updateChildren
- // need a better solution for this in the future (the proper updateChildren is private)
- Item[] children = getChildren(widget);
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- Widget item = children[i];
- Object data = item.getData();
- if (data instanceof IAdaptable && item instanceof TreeItem) {
- data = getContextObject((TreeItem)item);
- }
- if (data != null) {
- internalRSERefreshStruct(item, data, updateLabels);
- }
- }
- }
-
- }
-
- protected Object[] getRawChildren(Widget w) {
- Object parent = w.getData();
-
- if (parent.equals(getRoot())) return super.getRawChildren(parent);
- Object[] result = ((ITreeContentProvider) getContentProvider()).getChildren(parent);
- if (result != null) return result;
-
- return new Object[0];
- }
-
- /*
- protected void preservingSelection(Runnable updateCode)
- {
- super.preservingSelection(updateCode);
- System.out.println("After preservingSelection: new selection = "+getFirstSelectionName(getSelection()));
- }
- protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection)
- {
- System.out.println("Inside handleInvalidSelection: old = "+getFirstSelectionName(invalidSelection)+", new = "+getFirstSelectionName(newSelection));
- updateSelection(newSelection);
- }
- */
- protected String getFirstSelectionName(ISelection s) {
- if ((s != null) && (s instanceof IStructuredSelection)) {
- IStructuredSelection ss = (IStructuredSelection) s;
- Object firstSel = ss.getFirstElement();
- String name = null;
- if (firstSel != null) {
- ISystemRemoteElementAdapter ra = getRemoteAdapter(firstSel);
- if (ra != null)
- name = ra.getAbsoluteName(firstSel);
- else
- name = getViewAdapter(firstSel).getName(firstSel);
- }
- return name;
- } else
- return null;
- }
-
- /**
- * Expand a remote object within the tree. Must be given its parent element within the tree,
- * in order to uniquely find it. If not given this, we expand the first occurrence we find!
- * @param remoteObject - either a remote object or a remote object absolute name
- * @param subsystem - the subsystem that owns the remote objects, to optimize searches.
- * @param parentObject - the parent that owns the remote objects, to optimize searches. Can
- * be an object or the absolute name of a remote object.
- * @return the tree item of the remote object if found and expanded, else null
- */
- public Item expandRemoteObject(Object remoteObject, ISubSystem subsystem, Object parentObject) {
- // given the parent? Should be easy
- Item remoteItem = null;
- if (parentObject != null) {
- Item parentItem = null;
- if (parentObject instanceof Item)
- parentItem = (Item) parentObject;
- else if (parentObject instanceof String) // given absolute name of remote object
- parentItem = findFirstRemoteItemReference((String) parentObject, subsystem, (Item) null); // search all roots for the parent
- else // given actual remote object
- {
- ISystemViewElementAdapter ra = getViewAdapter(parentObject);
- if (ra != null) {
- if (subsystem == null) subsystem = ra.getSubSystem(parentObject);
- parentItem = findFirstRemoteItemReference(ra.getAbsoluteName(parentObject), subsystem, (Item) null); // search all roots for the parent
- } else // else parent is not a remote object. Probably its a filter
- {
- Widget parentWidget = findItem(parentObject);
- if (parentWidget instanceof Item) parentItem = (Item) parentWidget;
- }
- }
- // ok, we have the parent item! Hopefully!
- if (remoteObject instanceof String)
- remoteItem = findFirstRemoteItemReference((String) remoteObject, subsystem, parentItem);
- else
- remoteItem = findFirstRemoteItemReference(remoteObject, parentItem);
- if (remoteItem == null) return null;
- setExpandedState(remoteItem.getData(), true);
- } else // not given a parent to refine search with. Better have a subsystem!!
- {
- if (remoteObject instanceof String)
- remoteItem = findFirstRemoteItemReference((String) remoteObject, subsystem, (Item) null);
- else {
- ISystemViewElementAdapter ra = getViewAdapter(remoteObject);
- if (ra != null) {
- if (subsystem == null) subsystem = ra.getSubSystem(remoteObject);
- remoteItem = findFirstRemoteItemReference(ra.getAbsoluteName(remoteObject), subsystem, (Item) null);
- }
- }
- if (remoteItem == null) return null;
- setExpandedState(remoteItem.getData(), true);
- }
- return remoteItem;
- }
-
- /**
- * Select a remote object or objects given the parent remote object (can be null) and subsystem (can be null)
- * @param src - either a remote object, a remote object absolute name, or a List of remote objects or remote object absolute names
- * @param subsystem - the subsystem that owns the remote objects, to optimize searches.
- * @param parentObject - the parent that owns the remote objects, to optimize searches.
- * @return true if found and selected
- */
- public boolean selectRemoteObjects(Object src, ISubSystem subsystem, Object parentObject) {
- //String parentName = null;
- // given a parent object? That makes it easy...
- if (parentObject != null) {
- ISystemViewElementAdapter ra = getViewAdapter(parentObject);
- if (ra != null) {
- //parentName = ra.getAbsoluteName(parentObject);
- if (subsystem == null) subsystem = ra.getSubSystem(parentObject);
- Item parentItem = findFirstRemoteItemReference(parentObject, (Item) null); // search all roots for the parent
- return selectRemoteObjects(src, subsystem, parentItem);
- } else // else parent is not a remote object. Probably its a filter
- {
- Item parentItem = null;
- if (parentObject instanceof Item)
- parentItem = (Item) parentObject;
- else {
- Widget parentWidget = findItem(parentObject);
- if (parentWidget instanceof Item) parentItem = (Item) parentWidget;
- }
- if (parentItem != null)
- return selectRemoteObjects(src, (ISubSystem) null, parentItem);
- else
- return false;
- }
- } else
- //return selectRemoteObjects(src, (SubSystem)null, (Item)null); // Phil test
- return selectRemoteObjects(src, subsystem, (Item) null);
- }
-
- /**
- * Select a remote object or objects given the parent remote object (can be null) and subsystem (can be null) and parent TreeItem to
- * start the search at (can be null)
- * @param src - either a remote object, a remote object absolute name, or a List of remote objects or remote object absolute names
- * @param subsystem - the subsystem that owns the remote objects, to optimize searches.
- * @param parentItem - the parent at which to start the search to find the remote objects. Else, starts at the roots.
- * @return true if found and selected
- */
- protected boolean selectRemoteObjects(Object src, ISubSystem subsystem, Item parentItem) {
- clearSelection();
- Item selItem = null;
-
- if (parentItem != null && parentItem.isDisposed()) {
- return false;
- }
-
- if ((parentItem != null) && !getExpanded(parentItem))
- //setExpanded(parentItem, true);
- setExpandedState(parentItem.getData(), true);
-
- //System.out.println("SELECT_REMOTE: PARENT = " + parent + ", PARENTITEM = " + parentItem);
- if (src instanceof List) {
- //String elementName = null;
- List setList = (List)src;
- ArrayList selItems = new ArrayList();
- // our goal here is to turn the List of names or remote objects into a collection of
- // actual TreeItems we matched them on...
- for (int idx = 0; idx < setList.size(); idx++) {
- Object o = setList.get(idx);
- //elementName = null;
- if (o instanceof String)
- selItem = findFirstRemoteItemReference((String) o, subsystem, parentItem);
- else
- selItem = findFirstRemoteItemReference(o, parentItem);
-
- if (selItem != null) {
- selItems.add(selItem);
- // when selecting multiple items, we optimize by assuming they have the same parent...
- if ((parentItem == null) && (selItem instanceof TreeItem)) parentItem = ((TreeItem) selItem).getParentItem();
- }
- }
- if (selItems.size() > 0) {
- setSelection(selItems);
- updatePropertySheet();
- return true;
- }
- } else {
- if (src instanceof String)
- //selItem = (Item)findFirstRemoteItemReference((String)src, (SubSystem)null, parentItem); Phil test
- selItem = findFirstRemoteItemReference((String) src, subsystem, parentItem);
- else
- selItem = findFirstRemoteItemReference(src, parentItem);
-
- if (selItem != null) {
- ArrayList selItems = new ArrayList();
- selItems.add(selItem);
- setSelection(selItems);
- updatePropertySheet();
- return true;
- }
- }
- return false;
- }
-
- /**
- * Refresh the whole tree. We have special code to reselect remote objects after the refresh
- */
- public void refreshAll() {
- IStructuredSelection selected = (IStructuredSelection) getSelection();
- Iterator i = selected.iterator();
- Object parentElement = null;
- List selectedRemoteObjects = new Vector();
- Widget parentItem = null;
- ISubSystem ss = null;
- while (i.hasNext()) {
- Object element = i.next();
- if (parentElement == null) {
- Item item = (Item) findItem(element);
- if (item != null) {
- parentItem = getParentItem(item);
- }
- if ((parentItem != null) && (parentItem instanceof Item)) parentElement = ((Item) parentItem).getData();
- }
- if (getViewAdapter(element) != null) {
- selectedRemoteObjects.add(element);
- if (ss == null) ss = getViewAdapter(element).getSubSystem(element);
- }
- }
-
- //super.refresh();
- smartRefresh((Object) null, (selectedRemoteObjects.size() > 0));
-
- if (selectedRemoteObjects.size() > 0) {
- selectRemoteObjects(selectedRemoteObjects, ss, parentElement);
- }
- }
-
- /**
- * Do an intelligent refresh of an expanded item. The inherited algorithm for refresh is stupid,
- * in that it re-expands children based on their original ordinal position which can change after a
- * refresh, resulting in the wrong children being expanded. Currently this only truly comes to light
- * for remote objects, where refresh really can change the resulting list and hence each child's
- * ordinal position. So, to be safe we only override the inherited algorithm if any nested child
- * is a remote object
- */
- protected void smartRefresh(TreeItem[] itemsToRefresh) {
- smartRefresh(itemsToRefresh, null, false);
- }
-
- protected void smartRefresh(TreeItem[] itemsToRefresh, ArrayList expandedChildren, boolean forceRemote) {
- areAnyRemote = false; // set in ExpandedItem constructor
- boolean fullRefresh = false;
- // for each selected tree item gather a list of expanded child nodes...
- if (expandedChildren == null)
- expandedChildren = new ArrayList();
- else
- fullRefresh = true;
- boolean[] wasExpanded = new boolean[itemsToRefresh.length];
- for (int idx = 0; idx < itemsToRefresh.length; idx++) {
- TreeItem currItem = itemsToRefresh[idx];
- if (currItem.getExpanded()) {
- // ...if this selected item is expanded, recursively gather up all its expanded descendents
- Object data = currItem.getData();
- ISystemViewElementAdapter adapter = null;
- if (data != null) adapter = getViewAdapter(data);
- if (adapter != null && adapter.isPromptable(data))
- setExpandedState(data, false); // collapse temp expansion of prompts
- else {
- //expandedChildren.add(new ExpandedItem(currItem)); we don't need special processing for given items themselves as they will not be refreshed, only their kids
- gatherExpandedChildren((fullRefresh ? null : currItem), currItem, expandedChildren);
- wasExpanded[idx] = true;
- }
- } else {
- wasExpanded[idx] = false;
- }
- }
- // ok, we have found all expanded descendants of all selected items.
- // If none of the expanded sub-nodes are remote simply use the inherited algorithm for refresh
- if (!areAnyRemote) {
- for (int idx = 0; idx < itemsToRefresh.length; idx++)
- //ourInternalRefresh(itemsToRefresh[idx], itemsToRefresh[idx].getData(), wasExpanded[idx]);
- ourInternalRefresh(itemsToRefresh[idx], itemsToRefresh[idx].getData(), true, forceRemote); // defect 42321
- return;
- }
- getControl().setRedraw(false);
- // If any selected nodes are remote use our own algorithm:
- // 1. collapse each given node and refresh it to remove the children from memory, then
- // expand it again. It doesn't matter if it is remote or not since its own memory
- // address (absolute name) won't change, only that of its children.
- for (int idx = 0; idx < itemsToRefresh.length; idx++) {
- TreeItem currItem = itemsToRefresh[idx];
- setExpanded(currItem, false); // collapse node
- ourInternalRefresh(currItem, currItem.getData(), true, true); // dispose of children, update plus
-
- if (wasExpanded[idx]) {
-
-
-
- IRSECallback callback = new ExpandRemoteObjects(expandedChildren);
-
- createChildren(currItem, callback); // re-expand
- currItem.setExpanded(true);
- } else // hmm, item was not expanded so just flush its memory
- {
-
- }
- }
-
- // for non-deferred queries
-
- // 2. expand each previously expanded sub-node, recursively
- for (int idx = 0; idx < expandedChildren.size(); idx++) {
- ExpandedItem itemToExpand = (ExpandedItem) expandedChildren.get(idx);
- if (itemToExpand.isRemote()) {
- // find remote item based on its original name and unchanged root parent
- Item item = null;
-
- // for deferred queries, we handle this via a callback
- item = findFirstRemoteItemReference(itemToExpand.remoteName, itemToExpand.subsystem, itemToExpand.parentItem);
-
- // if found, re-expand it
- if (item != null) {
- //setExpanded(item, true);
- createChildren(item);
- ((TreeItem) item).setExpanded(true);
- if (debug) System.out.println("Re-Expanded RemoteItem: " + itemToExpand.remoteName); //$NON-NLS-1$
- } else if (debug) System.out.println("Re-Expand of RemoteItem '" + itemToExpand.remoteName + "' failed. Not found"); //$NON-NLS-1$ //$NON-NLS-2$
- } else if (itemToExpand.data!=null) {
- setExpandedState(itemToExpand.data, true);
- if (debug) System.out.println("Re-Expanded non-remote Item: " + itemToExpand.data); //$NON-NLS-1$
- }
- }
-
- getControl().setRedraw(true);
- }
-
- public void refreshRemote(Object element)
- {
- smartRefresh(element, true);
- }
-
-
-
- protected ArrayList getExpandedChildren(TreeItem[] roots){
- ArrayList expandedChildren = new ArrayList();
- for (int idx = 0; idx < roots.length; idx++) {
- TreeItem currItem = roots[idx];
- if (currItem.getExpanded()) {
- Object data = currItem.getData();
- ISystemViewElementAdapter adapter = null;
- if (data != null) adapter = getViewAdapter(data);
- if(adapter != null && adapter.isPromptable(data)) {
- setExpandedState(data, false);
- }
- else {
- expandedChildren.add(new ExpandedItem(null, currItem));
- }
- }
- }
- return expandedChildren;
- }
-
- /**
- * Do an intelligent refresh of the given element. Can be null for full refresh
- */
- protected void smartRefresh(Object element, boolean forceRemote) {
- if ((element == null) || (element == getInput())) {
- // fullRefresh
- Tree tree = getTree();
- TreeItem[] roots = tree.getItems();
- boolean anyExpanded = false;
- areAnyRemote = false; // set in ExpandedItem constructor
- ArrayList expandedChildren = getExpandedChildren(roots);
- if (expandedChildren.size() > 0)
- anyExpanded = true;
-
- if (!anyExpanded)
- super.refresh();
- else {
- internalRefresh(getInput());
- roots = tree.getItems(); // re-query roots
- smartRefresh(roots, expandedChildren, forceRemote);
- }
- } else if (getViewAdapter(element) != null) {
-
- Item item = null;
- if (element instanceof String) {
- item = findFirstRemoteItemReference((String) element, (ISubSystem) null, (Item) null);
- if (item != null) {
- smartRefresh(new TreeItem[] { (TreeItem) item });
- }
- } else {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- // DKM - taken out as per defect 174295
- //String elementName = adapter.getName(element);
-
- String searchString = adapter.getAbsoluteName(element);
- ISubSystem subSystem = adapter.getSubSystem(element);
-
- List matches = new Vector();
- findAllRemoteItemReferences(searchString, element, subSystem, matches);
-
- // DKM - taken out as per defect 174295
- //findAllRemoteItemReferences(elementName, element, subSystem, matches);
- if (matches.size() > 0) {
- for (int i = 0; i < matches.size(); i++) {
- Item match = (Item) matches.get(i);
- if ((match instanceof TreeItem) && !((TreeItem) match).isDisposed()) {
- smartRefresh(new TreeItem[] { (TreeItem) match });
- }
- }
- }
- }
-
- /*
- Item item = null;
- if (element instanceof String)
- item = findFirstRemoteItemReference((String)element, (SubSystem)null, (Item)null);
- else
- item = findFirstRemoteItemReference(element, (Item)null);
- if (item != null)
- smartRefresh(new TreeItem[] {(TreeItem)item});
-
- */
- } else {
- Item item = (Item) findItem(element);
- //System.out.println("Inside SV smartRefresh for "+element+". Item found? " + (item!=null));
- if (item != null) smartRefresh(new TreeItem[] { (TreeItem) item });
- }
- }
-
- class ExpandedItem {
- //private TreeItem item; //not needed since we'll get the item by absolute name
- //For mixed remote/non-remote selections we may want a TreePath
- TreeItem parentItem;
- Object data;
- String remoteName;
- ISubSystem subsystem;
- private ISystemRemoteElementAdapter remoteAdapter;
-
- ExpandedItem(TreeItem parentItem, TreeItem item) {
- this.parentItem = parentItem;
- this.data = item.getData();
- if (data != null) {
- remoteAdapter = getRemoteAdapter(data);
- if (remoteAdapter != null) {
- remoteName = remoteAdapter.getAbsoluteName(data);
- subsystem = remoteAdapter.getSubSystem(data);
- areAnyRemote = true;
- if (debug) System.out.println("ExpandedRemoteItem added. remoteName = " + remoteName); //$NON-NLS-1$
- } else {
- ISystemViewElementAdapter adapter = getViewAdapter(data);
- if (adapter != null) {
- remoteName = adapter.getAbsoluteName(data);
- subsystem = adapter.getSubSystem(data);
- }
- if (debug) System.out.println("ExpandedItem added. Data = " + data); //$NON-NLS-1$
- }
- } else if (debug) System.out.println("ExpandedItem added. Data = null"); //$NON-NLS-1$
- }
-
- boolean isRemote() {
- return (remoteAdapter != null);
- }
- }
-
- /**
- * Gather up all expanded children of the given tree item into a list
- * that can be used later to reexpand.
- * @param parentItem The root parent which will not be refreshed itself
- * (only its kids) and hence will remain valid after refresh.
- * In a full refresh this will be null.
- * @param startingItem The starting item for this search.
- * Usually same as parentItem, but changes via recursion
- * @param listToPopulate An array list that will be populated
- * with instances of our inner class ExpandedItem
- */
- protected void gatherExpandedChildren(TreeItem parentItem, TreeItem startingItem, ArrayList listToPopulate) {
- TreeItem[] itemChildren = startingItem.getItems();
- for (int idx = 0; idx < itemChildren.length; idx++) {
- TreeItem currChild = itemChildren[idx];
- if (currChild.getExpanded()) {
- Object data = currChild.getData();
- ISystemViewElementAdapter adapter = null;
- if (data != null) adapter = getViewAdapter(data);
- if (adapter != null && adapter.isPromptable(data)) {
- setExpandedState(data, false);
- } else {
- listToPopulate.add(new ExpandedItem(parentItem, currChild));
- gatherExpandedChildren(parentItem, currChild, listToPopulate);
- }
- }
- }
- }
-
- /**
- * Get index of item given its data element
- */
- protected int getItemIndex(Widget parent, Object element) {
- int index = -1;
- Item[] kids = getChildren(parent);
- if (kids != null) for (int idx = 0; idx < kids.length; idx++)
- if (kids[idx].getData() == element) index = idx;
- return index;
- }
-
- /**
- * We don't show actual filters, only filter references that are unique generated
- * for each subtree of each subsystem. Yet, each event is relative to the filter,
- * not our special filter references. Hence, all this code!!
- * <p>
- * Special case handling for updates to filters which affect the filter
- * but not the filter parent:
- * 1. Existing filter renamed (RENAME)
- * 2. Existing filter's filter strings changed (CHANGE)
- * <p>
- * Assumption:
- * 1. event.getGrandParent() == subsystem (one event fired per affected subsystem)
- * 2. event.getSource() == filter or filter string (not the reference, the real filter or string)
- * 3. event.getParent() == parent of filter or filter string. One of:
- * a. filterPool reference or filter reference (nested)
- * b. filterPool for non-nested filters when showing filter pools
- * c. subsystem for non-nested filters when not showing filter pools
- * d. filter for nested filters
- * <p>
- * Our job here:
- * 1. Determine if we are even showing the given subsystem
- * 2. Find the reference to the updated filter in that subsystem's subtree
- * 3. Ask that parent to either update its name or collapse and refresh its children
- * 4. Forget selecting something ... the original item remains selected!
- */
- protected void findAndUpdateFilter(ISystemResourceChangeEvent event, int type) {
- ISystemFilter filter = (ISystemFilter) event.getSource();
- //Object parent = event.getParent();
- if (debug) {
- String eventType = null;
- switch (type) {
- case ISystemResourceChangeEvents.EVENT_RENAME_FILTER_REFERENCE:
- eventType = "EVENT_RENAME_FILTER_REFERENCE"; //$NON-NLS-1$
- break;
- case ISystemResourceChangeEvents.EVENT_CHANGE_FILTER_REFERENCE:
- eventType = "EVENT_CHANGE_FILTER_REFERENCE"; //$NON-NLS-1$
- break;
- }
- logDebugMsg("SV event: " + eventType); //$NON-NLS-1$
- }
-
- // STEP 1. ARE WE EVEN SHOWING THE GIVEN SUBSYSTEM?
- ISubSystem ss = (ISubSystem) event.getGrandParent();
- Widget widget = findItem(ss);
-
- if (widget != null) {
-
- // STEP 2: ARE WE SHOWING A REFERENCE TO RENAMED OR UPDATED FILTER?
- Widget item = null;
-
- Control c = getControl();
-
- // KM: defect 53008.
- // Yes we are showing the subsystem, so widget is the subsystem item
- if (widget != c && widget instanceof Item) {
-
- if (debug) logDebugMsg("...Found ss " + ss); //$NON-NLS-1$
-
- item = internalFindReferencedItem(widget, filter, SEARCH_INFINITE);
- }
- // No, we are not showing the subsystem, so widget is the control
- else if (widget == c) {
-
- if (debug) logDebugMsg("...Din not find ss " + ss); //$NON-NLS-1$
-
- item = internalFindReferencedItem(widget, filter, SEARCH_INFINITE);
- }
-
- if (item == null)
- logDebugMsg("......didn't find renamed/updated filter's reference!"); //$NON-NLS-1$
- else {
- // STEP 3: UPDATE THAT FILTER...
- if (type == ISystemResourceChangeEvents.EVENT_RENAME_FILTER_REFERENCE) {
- String[] rproperties = { IBasicPropertyConstants.P_TEXT };
- update(item.getData(), rproperties); // for refreshing non-structural properties in viewer when model changes
- } else if (type == ISystemResourceChangeEvents.EVENT_CHANGE_FILTER_REFERENCE) {
- //if (((TreeItem)item).getExpanded())
- //refresh(item.getData());
- smartRefresh(new TreeItem[] { (TreeItem) item });
- /*
- Object data = item.getData();
- boolean wasExpanded = getExpanded((Item)item);
- setExpandedState(data, false); // collapse node
- refresh(data); // clear all cached widgets
- if (wasExpanded)
- setExpandedState(data, true); // by doing this all subnodes that were expanded are now collapsed
- */
- }
- updatePropertySheet();
- }
- }
- }
-
- protected void findAndUpdateFilterString(ISystemResourceChangeEvent event, int type) {
- ISystemFilterString filterString = (ISystemFilterString) event.getSource();
- // STEP 1. ARE WE EVEN SHOWING THE GIVEN SUBSYSTEM?
- ISubSystem ss = (ISubSystem) event.getGrandParent();
- Widget item = findItem(ss);
- if (item != null && item != getControl()) {
- Item ssItem = (Item) item;
- if (debug) logDebugMsg("...Found ss " + ss); //$NON-NLS-1$
- // STEP 2: ARE WE SHOWING A REFERENCE TO THE UPDATED FILTER STRING?
- item = internalFindReferencedItem(ssItem, filterString, SEARCH_INFINITE);
- if (item == null)
- logDebugMsg("......didn't find updated filter string's reference!"); //$NON-NLS-1$
- else {
- // STEP 3: UPDATE THAT FILTER STRING...
- if (type == ISystemResourceChangeEvents.EVENT_CHANGE_FILTERSTRING_REFERENCE) // HAD BETTER!
- {
- //if (((TreeItem)item).getExpanded())
- //refresh(item.getData());
- // boolean wasExpanded = getExpanded((Item)item);
- Object data = item.getData();
- setExpandedState(data, false); // collapse node
- refresh(data); // clear all cached widgets
- //if (wasExpanded)
- //setExpandedState(data, true); // hmm, should we?
- String properties[] = { IBasicPropertyConstants.P_TEXT };
- update(item.getData(), properties); // for refreshing non-structural properties in viewer when model changes
- updatePropertySheet();
- }
- }
- }
- }
-
- /**
- * We don't show actual filters, only filter references that are unique generated
- * for each subtree of each subsystem. Yet, each event is relative to the filter,
- * not our special filter references. Hence, all this code!!
- * <p>
- * Special case handling for updates to filters which affect the parent of the
- * filter, such that the parent's children must be re-generated:
- * 1. New filter created (ADD)
- * 2. Existing filter deleted (DELETE)
- * 3. Existing filters reordered (MOVE)
- * <p>
- * Assumption:
- * 1. event.getGrandParent() == subsystem (one event fired per affected subsystem)
- * 2. event.getSource() == filter (not the reference, the real filter)
- * 3. event.getParent() == parent of filter. One of:
- * a. filterPool reference or filter reference (nested)
- * b. filterPool for non-nested filters when showing filter pools
- * c. subsystem for non-nested filters when not showing filter pools
- * d. filter for nested filters
- * <p>
- * Our job here:
- * 1. Determine if we are even showing the given subsystem
- * 2. Find the parent to the given filter: filterPool or subsystem
- * 3. Ask that parent to refresh its children (causes re-gen of filter references)
- * 4. Select something: QUESTION: is this subsystem the origin of this action??
- * a. For ADD, select the newly created filter reference for the new filter
- * ANSWER: IF PARENT OF NEW FILTER IS WITHIN THIS SUBSYSTEM, AND WAS SELECTED PREVIOUSLY
- * b. For DELETE, select the parent of the filter?
- * ANSWER: IF DELETED FILTER IS WITHING THIS SUBSYSTEM AND WAS SELECTED PREVIOUSLY
- * c. For MOVE, select the moved filters
- * ANSWER: IF MOVED FILTERS ARE WITHIN THIS SUBSYSTEM, AND WERE SELECTED PREVIOUSLY
- */
- protected void findAndUpdateFilterParent(ISystemResourceChangeEvent event, int type) {
- ISubSystem ss = (ISubSystem) event.getGrandParent();
-
-
- boolean add = false, move = false, delete = false;
- boolean afilterstring = false;
- //if (debug)
- //{
- String eventType = null;
- switch (type) {
- case ISystemResourceChangeEvents.EVENT_ADD_FILTER_REFERENCE:
- add = true;
- if (debug) eventType = "EVENT_ADD_FILTER_REFERENCE"; //$NON-NLS-1$
- break;
- case ISystemResourceChangeEvents.EVENT_DELETE_FILTER_REFERENCE:
- delete = true;
- if (debug) eventType = "EVENT_DELETE_FILTER_REFERENCE"; //$NON-NLS-1$
- break;
- case ISystemResourceChangeEvents.EVENT_MOVE_FILTER_REFERENCES:
- move = true;
- if (debug) eventType = "EVENT_MOVE_FILTER_REFERENCES"; //$NON-NLS-1$
- break;
- case ISystemResourceChangeEvents.EVENT_ADD_FILTERSTRING_REFERENCE:
- add = true;
- afilterstring = true;
- if (debug) eventType = "EVENT_ADD_FILTERSTRING_REFERENCE"; //$NON-NLS-1$
- break;
- case ISystemResourceChangeEvents.EVENT_DELETE_FILTERSTRING_REFERENCE:
- delete = true;
- afilterstring = true;
- if (debug) eventType = "EVENT_DELETE_FILTERSTRING_REFERENCE"; //$NON-NLS-1$
- break;
- case ISystemResourceChangeEvents.EVENT_MOVE_FILTERSTRING_REFERENCES:
- move = true;
- afilterstring = true;
- if (debug) eventType = "EVENT_MOVE_FILTERSTRING_REFERENCES"; //$NON-NLS-1$
- break;
-
- }
- if (debug) logDebugMsg("SV event: " + eventType); //$NON-NLS-1$
- //}
- //clearSelection();
-
- ISystemFilter filter = null;
- ISystemFilterString filterstring = null;
- if (!afilterstring)
- filter = (ISystemFilter) event.getSource(); // for multi-source move, gets first filter
- else
- filterstring = (ISystemFilterString) event.getSource();
-
- boolean multiSource = move;
- // STEP 1: ARE WE SHOWING THE SUBSYSTEM GRANDPARENT OF CURRENT REFRESH?
- Widget item = findItem(ss);
-
- if (item == null) {
- refresh();
-
- if (debug) logDebugMsg("...Did not find ss " + ss.getName()); //$NON-NLS-1$
- return;
- }
-
- boolean wasSelected = false;
- IStructuredSelection oldSelections = (IStructuredSelection) getSelection();
-
- Object parent = event.getParent();
- if (debug) logDebugMsg("...Found ss " + ss); //$NON-NLS-1$
-
- // STEP 2: ARE WE SHOWING A REFERENCE TO THE FILTER's PARENT POOL?
- Widget parentRefItem = null;
- ISystemFilterContainer refdParent = null;
- // 3a (reference to filter pool or filter)
- if (parent instanceof ISystemFilterContainerReference) // given a reference to parent?
- {
- refdParent = ((ISystemFilterContainerReference) parent).getReferencedSystemFilterContainer();
- parentRefItem = internalFindReferencedItem(item, refdParent, SEARCH_INFINITE);
- }
- // 3b and 3d. (filter pool or filter)
- else if (parent instanceof ISystemFilterContainer) {
- refdParent = (ISystemFilterContainer) parent;
- parentRefItem = internalFindReferencedItem(item, refdParent, SEARCH_INFINITE);
- }
- // 3c (subsystem)
- else {
- parentRefItem = item;
- }
- if (parentRefItem != null) {
- if (debug) logDebugMsg("......We are showing reference to parent"); //$NON-NLS-1$
- // STEP 3... YES, SO REFRESH PARENT... IT WILL RE-GEN THE FILTER REFERENCES FOR EACH CHILD FILTER
- // ... actually, call off the whole show if that parent is currently not expanded!!
- // HMMM... WE NEED TO REFRESH EVEN IF NOT EXPANDED IF ADDING FIRST CHILD
- if (!add) // move or delete
- {
- // Widgets can only be Tree or TreeItem here
- if (parentRefItem instanceof Item){
- if (!(((TreeItem) parentRefItem).getExpanded())) {
- refresh(parentRefItem.getData()); // flush cached widgets so next expand is fresh
- return;
- }
- }
-
-
- // move or delete and parent is expanded...
- Item oldItem = (Item) internalFindReferencedItem(parentRefItem, afilterstring ? (Object) filterstring : (Object) filter, 1);
- //if (debug)
- //logDebugMsg("oldItem null? " + (oldItem==null));
- if (oldItem != null) // found moved or deleted filter in our subtree
- {
- wasSelected = isSelected(oldItem.getData(), oldSelections); // was it selected before?
- //if (debug)
- //logDebugMsg("was selected? " + wasSelected);
- } else {
- // else interesting case ... we are showing the parent, but can't find the child!
- }
- if (move) {
- Object[] srcObjects = null;
- if (multiSource)
- srcObjects = event.getMultiSource();
- else {
- srcObjects = new Object[1];
- srcObjects[0] = event.getSource();
- }
- moveReferencedTreeItems(parentRefItem, srcObjects, event.getPosition());
- //refresh(parentRefItem.getData());
- } else // remove
- {
- if (oldItem != null)
- remove(oldItem.getData());
- }
- } else // add operation
- {
- if (!(((TreeItem) parentRefItem).getExpanded())) {
- refresh(parentRefItem.getData()); // delete cached GUIs
- //setExpandedState(parentRefItem,true); // not our job to expand here.
- } else if (afilterstring) {
- ISystemFilterReference fr = (ISystemFilterReference) parentRefItem.getData();
- ISystemFilterStringReference fsr = fr.getSystemFilterStringReference(filterstring);
- createTreeItem(parentRefItem, fsr, event.getPosition());
- //setSelection(new StructuredSelection(fsr),true);
- } else {
- Object data = parentRefItem.getData();
- if (data instanceof ISystemFilterContainerReference) {
- ISystemFilterContainerReference sfcr = (ISystemFilterContainerReference) data;
- ISystemFilterReference sfr = sfcr.getSystemFilterReference(ss, filter);
- createTreeItem(parentRefItem, sfr, event.getPosition());
- } else // hmm, could be parent is a subsystem, child is a filter in no-show-filter-pools mode
- {
- if (data instanceof ISystemFilterPoolReferenceManagerProvider) // that's a subsystem!
- {
- ISystemFilterPoolReferenceManagerProvider sfprmp = (ISystemFilterPoolReferenceManagerProvider) data;
- ISystemFilterPoolReferenceManager sfprm = sfprmp.getSystemFilterPoolReferenceManager();
- ISystemFilterReference sfr = sfprm.getSystemFilterReference(ss, filter);
- createTreeItem(parentRefItem, sfr, sfprm.getSystemFilterReferencePosition(sfr));
- }
- }
- }
- //refresh(parentRefItem.getData());
- }
-
- // STEP 4: DECIDE WHAT TO SELECT:
-
- // 4a. ADD ... only select if parent of new filter was previously selected...
- if (add && isSelected(parentRefItem.getData(), oldSelections)) {
- if (debug) logDebugMsg(".........that parent was previously selected"); //$NON-NLS-1$
- // .... YES, SO SELECT NEW FILTER'S REFERENCE
- Item filterItem = (Item) internalFindReferencedItem(parentRefItem, afilterstring ? (Object) filterstring : (Object) filter, 1); // start at filter's parent, search for filter
- if (filterItem == null) {
- if (debug) logDebugMsg("Hmm, didn't find new filter's reference!"); //$NON-NLS-1$
- } else {
- if (debug) logDebugMsg(".........Trying to set selection to " + filterItem.getData()); //$NON-NLS-1$
- setSelection(new StructuredSelection(filterItem.getData()), true);
- }
- }
- // 4b. DELETE ... select parent if deleted filter was previously selected
- else if (delete && wasSelected) {
- setSelection(new StructuredSelection(parentRefItem.getData())); // select parent
- }
- // 4c. MOVE ... only select if any of moved references were previously selected...
- else if (move && wasSelected && !afilterstring) {
- ISystemFilter[] filters = (ISystemFilter[]) event.getMultiSource();
- if (filters != null) {
- ISystemFilterReference[] newRefs = new ISystemFilterReference[filters.length];
- for (int idx = 0; idx < newRefs.length; idx++) {
- Widget w = internalFindReferencedItem(parentRefItem, filters[idx], 1);
- newRefs[idx] = (ISystemFilterReference) ((Item) w).getData();
- }
- setSelection(new StructuredSelection(newRefs), true);
- }
- } else if (move && wasSelected && afilterstring) {
- ISystemFilterString[] filterStrings = (ISystemFilterString[]) event.getMultiSource();
- if (filterStrings != null) {
- ISystemFilterStringReference[] newRefs = new ISystemFilterStringReference[filterStrings.length];
- for (int idx = 0; idx < newRefs.length; idx++) {
- Widget w = internalFindReferencedItem(parentRefItem, filterStrings[idx], 1);
- newRefs[idx] = (ISystemFilterStringReference) ((Item) w).getData();
- }
- setSelection(new StructuredSelection(newRefs), true);
- }
- }
-
- } else if (debug) logDebugMsg("Did not find parent ref " + parent); //$NON-NLS-1$
- }
-
- /**
- * 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
- * positive, they are all moved down by the given amount.<p>
- */
- protected void moveReferencedTreeItems(Widget parentItem, Object[] masterSrc, int delta) {
- int[] oldPositions = new int[masterSrc.length];
- Item[] oldItems = new Item[masterSrc.length];
- Object[] src = new Object[masterSrc.length];
-
- for (int idx = 0; idx < src.length; idx++) {
- oldItems[idx] = (Item) internalFindReferencedItem(parentItem, masterSrc[idx], 1);
- src[idx] = oldItems[idx].getData();
- }
- Item[] children = null;
- if (parentItem instanceof Item) {
- children = getItems((Item) parentItem);
- } else
- children = getChildren(parentItem);
-
- for (int idx = 0; idx < src.length; idx++) {
- oldPositions[idx] = getTreeItemPosition(oldItems[idx], children) + 1;
- //logDebugMsg("::: Old position : " + oldPositions[idx]);
- }
-
- if (delta > 0) // moving down, process backwards
- {
- for (int idx = src.length - 1; idx >= 0; idx--) {
- //logDebugMsg("DN: Old position : " + oldPositions[idx] + ", new position : " + (oldPositions[idx]+delta));
- moveTreeItem(parentItem, oldItems[idx], src[idx], oldPositions[idx] + delta);
- }
- } else // moving up, process forewards
- {
- for (int idx = 0; idx < src.length; idx++) {
- //logDebugMsg("UP: Old position : " + oldPositions[idx] + ", new position : " + (oldPositions[idx]+delta-1));
- moveTreeItem(parentItem, oldItems[idx], src[idx], oldPositions[idx] + delta - 1);
- }
- }
- }
-
- /**
- * Recursively tries to find a reference to the given referenced item
- *
- * @param parent the parent item at which to start the search.
- * @param element the master element to which we want to find a tree item which references it
- * @param searchLimit how deep to search
- */
- protected Widget internalFindReferencedItem(Widget parent, Object element, int searchLimit) {
- previousItem = null;
- searchDepth = 0;
-
- Widget result = mappedFindFirstRemoteItemReference(element);
- if (result == null)
- {
- result = recursiveInternalFindReferencedItem(parent, element, searchLimit);
- }
- return result;
- }
-
- /**
- * Recursively tries to find a reference the given filtercontainer
- * Limits search depth to when we find an item that is not a connection,
- * subsystem, filter pool, filter or filter string.
- * @param parent the parent item at which to start the search.
- * @param element the master element to which we want to find a tree item which references it
- * @param searchLimit how deep to search
- */
- protected Widget recursiveInternalFindReferencedItem(Widget parent, Object element, int searchLimit) {
- // compare with node
- Object data = parent.getData();
- if ((data != null) && (data instanceof IRSEBaseReferencingObject)) {
- IRSEBaseReferencingObject refingData = (IRSEBaseReferencingObject) data;
- Object refedData = refingData.getReferencedObject();
- //logDebugMsg("data is a refing obj to " + refingData);
- if (refedData == element)
- //if (refedData.equals(element))
- return parent;
- else
- previousItem = parent;
- }
- // recurse over children if we are listing a subsystem or connection or
- // filter framework reference object, and nesting limit not reached.
- if (((data instanceof ISubSystem) || (data instanceof IHost) || (data instanceof ISystemFilterContainer) || (data instanceof ISystemFilterContainerReference) || (data instanceof ISystemFilterStringReference))
- && (searchDepth < searchLimit)) {
- ++searchDepth;
- int oldDepth = searchDepth;
- Item[] items = getChildren(parent);
- for (int i = 0; (i < items.length); i++)
- {
- Widget o = recursiveInternalFindReferencedItem(items[i], element, searchLimit);
- if (o != null) return o;
- searchDepth = oldDepth;
- }
- }
- return null;
- }
-
- /**
- * Recursively tries to find an item starting at the given item.
- * (base viewer classes do not offer a relative search!)
- *
- * @param parent the parent item at which to start the search.
- * @param element the element to match on. Matches on "==" versus equals()
- */
- protected Widget internalFindRelativeItem(Widget parent, Object element, int searchLimit) {
- searchDepth = 0;
- return recursiveInternalFindRelativeItem(parent, element, searchLimit);
- }
-
- /**
- * Recursively tries to find an item starting at the given item.
- * (base viewer classes do not offer a relative search!)
- *
- * @param parent the parent item at which to start the search.
- * @param element the element to match on. Matches on "==" versus equals()
- */
- protected Widget recursiveInternalFindRelativeItem(Widget parent, Object element, int searchLimit) {
- // compare with node
- Object data = parent.getData();
- if ((data != null) && (data == element)) return parent;
- // recurse over children
- if (searchDepth < searchLimit) {
- ++searchDepth;
- int oldDepth = searchDepth;
- Item[] items = getChildren(parent);
- for (int i = 0; i < items.length; i++) {
- Widget o = recursiveInternalFindRelativeItem(items[i], element, searchLimit);
- if (o != null) return o;
- searchDepth = oldDepth;
- }
- }
- return null;
- }
-
-
-
- /**
- * Find the first binary-match or name-match of remote object, given its absolute name.
- * @param remoteObjectName The absolute name of the remote object to find.
- * @param subsystem The subsystem of the remote object to find. Optional.
- * @param parentItem The parent item at which to start the search. Optional.
- * @return TreeItem hit if found
- */
- public Item findFirstRemoteItemReference(String remoteObjectName, ISubSystem subsystem, Item parentItem) {
- //List matches = new Vector();
- Item match = null;
- if (parentItem == null)
- //findAllRemoteItemReferences(remoteObjectName, null, subsystem, matches);
- match = internalFindFirstRemoteItemReference(remoteObjectName, null, subsystem);
- else {
-
- //recursiveFindAllRemoteItemReferences(parentItem, remoteObjectName, null, subsystem, matches);
- match = recursiveFindFirstRemoteItemReference(parentItem, remoteObjectName, null, subsystem);
- }
- //if (matches.size() > 0)
- // return (Item)matches.elementAt(0);
- //else
- // return null;
- return match;
- }
-
- /**
- * Find the first binary-match or name-match of a remote object, given its binary object.
- * @param remoteObject - The remote object to find.
- * @param parentItem - Optionally, the parent item to start the search at
- * @return TreeItem hit if found
- */
- public Item findFirstRemoteItemReference(Object remoteObject, Item parentItem) {
-
- Item match = mappedFindFirstRemoteItemReference(remoteObject);
- if (match != null)
- return match;
-
- //List matches = new Vector();
- ISystemViewElementAdapter adapter = getViewAdapter(remoteObject);
- if (adapter == null) return null;
-
- ISubSystem subsystem = adapter.getSubSystem(remoteObject);
- String remoteObjectName = adapter.getAbsoluteName(remoteObject);
- if (parentItem == null)
- //findAllRemoteItemReferences(remoteObjectName, remoteObject, subsystem, matches);
- match = internalFindFirstRemoteItemReference(remoteObjectName, remoteObject, subsystem);
- else {
- //recursiveFindAllRemoteItemReferences(parentItem, remoteObjectName, remoteObject, subsystem, matches);
- //System.out.println("recursiveFindFirstRemoteItemReference(parentItem, remoteObjectName, remoteObject, subsystem)");
- match = recursiveFindFirstRemoteItemReference(parentItem, remoteObjectName, remoteObject, subsystem);
- }
-
- //if (matches.size() > 0)
- // return (Item)matches.elementAt(0);
- //else
- // return null;
- return match;
- }
-
- /**
- * Recursively tries to find a given remote object. Since the object memory object
- * for a remote object is not dependable we call getAbsoluteName() on the adapter to
- * do the comparisons. Note this does not take into account the parent connection or
- * subsystem or filter, hence you must know where to start the search, else you risk
- * finding the wrong one.
- *
- * @param element the remote object to which we want to find a tree item which references it. Can be a string or an object
- * @param elementObject the actual remote element to find, for binary matching, optionally for cases when element is a string
- * @param matches the List to populate with hits, or <code>null</code> to
- * get a new List created and returned with the hits.
- * @return the List populated with hits, or <code>null</code> if <code>null</code>
- * was passed in as the List to populate and no hits were found.
- */
- public List findAllRemoteItemReferences(Object element, Object elementObject, List matches) {
- String searchString = null;
- ISubSystem subsystem = null;
- if (element instanceof String)
- searchString = (String) element;
- else {
- if (elementObject == null)
- elementObject = element;
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (adapter == null)
- return matches;
- subsystem = adapter.getSubSystem(element);
- searchString = adapter.getAbsoluteName(element);
- }
- Tree tree = getTree();
- Item[] roots = tree.getItems();
- if (roots == null)
- return matches;
- if (matches == null)
- matches = new Vector();
-
- // try new map lookup method - won't work in cases of rename
- if (!mappedFindAllRemoteItemReferences(elementObject, matches)){
- for (int idx = 0; idx < roots.length; idx++) {
- //System.out.println("recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches);");
- matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches);
- }
- }
-
- return matches;
- }
-
- /**
- * Recursively tries to find all occurrences of a given remote object, starting at the tree root.
- * Since the object memory object for a remote object is not dependable we call getAbsoluteName()
- * on the adapter to do the comparisons.
- * <p>
- * TODO: This method should not return any invalid matches, i.e. remote objects
- * that do match the String identifier but have been deleted already. Because the
- * 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.
- * <p>
- * 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),
- * or <code>null</code> to get a new List created and returned
- * @return the List populated with hits, or <code>null</code> if
- * <code>null</code> was passed as matches to populate and no matches
- * were found.
- */
- protected List findAllRemoteItemReferences(String searchString, Object elementObject, ISubSystem subsystem, List matches) {
- Tree tree = getTree();
- Item[] roots = tree.getItems();
- if (roots == null) return matches;
- 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)){
- foundExact = true;
- }
- }
-
- if (!foundExact)
- {
- for (int idx = 0; idx < roots.length; idx++){
- matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches);
- }
- }
- }
- return matches;
- }
-
-
- private boolean recursiveFindExactMatches(TreeItem root, Object elementObject, ISubSystem subsystem, List matches)
- {
- boolean foundSomething = false;
- Object data = root.getData();
- if (data == elementObject)
- {
- matches.add(root);
- foundSomething = true;
- }
- if (subsystem != null){
- if (data instanceof ISubSystem){
- if (data != subsystem)
- return false;
- }
- else if (data instanceof IHost){
- if (subsystem.getHost() != data)
- return false;
- }
- }
-
- TreeItem[] children = root.getItems();
- for (int i = 0; i < children.length; i++)
- {
- if (recursiveFindExactMatches(children[i], elementObject, subsystem, matches))
- {
- foundSomething = true;
- }
- }
- return foundSomething;
- }
-
- /**
- * 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.
- * <p>
- * 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
- * @return TreeItem hit if found
- */
- 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);
- }
-
- return match;
- }
-
- protected Item mappedFindFirstRemoteItemReference(Object elementObject)
- {
- return (Item)findItem(elementObject);
- }
-
- protected boolean mappedFindAllRemoteItemReferences(Object elementObject, List occurrences)
- {
- Widget[] items = findItems(elementObject);
- if (items.length > 0)
- {
- for (int i = 0; i < items.length; i++)
- {
- occurrences.add(items[i]);
- }
- 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.
- * @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
- * @param occurrences the List to populate with hits. Must not be <code>null</code>
- * @return the given List populated with hits
- */
- protected List recursiveFindAllRemoteItemReferences(Item parent, String elementName, Object elementObject, ISubSystem subsystem, List occurrences) {
- Object rawData = parent.getData();
- ISystemViewElementAdapter remoteAdapter = null;
- // ----------------------------
- // what are we looking at here?
- // ----------------------------
- if (rawData != null) remoteAdapter = getViewAdapter(rawData);
- // -----------------------------------------------------------------------
- // if this is a remote object, test if it is the one we are looking for...
- // -----------------------------------------------------------------------
- if (remoteAdapter != null) {
- // first test for binary match
- if (elementObject == rawData) {
- occurrences.add(parent); // found a match!
- if (debugRemote) System.out.println("Find All: Remote item binary match found"); //$NON-NLS-1$
- return occurrences; // no point in checking the kids
- }
- // now test for absolute name match
- String fqn = remoteAdapter.getAbsoluteName(rawData);
- if (debugRemote) System.out.println("TESTING FINDALL: '" + fqn + "' vs '" + elementName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if ((fqn != null) && fqn.equals(elementName)) {
- occurrences.add(parent); // found a match!
- if (debugRemote) System.out.println("...and remote item name match found"); //$NON-NLS-1$
- return occurrences; // no point in checking the kids
- }
- }
- // -------------------------------------------------------------------------
- // if we have been given a subsystem to restrict to, that is a hint to us...
- // -------------------------------------------------------------------------
- else if ((rawData != null) && (subsystem != null)) // test for hints we are in the wrong place
- {
- // if we are currently visiting a subsystem, and that subsystem is not from the same
- // factory, then we can assume the remote object occurrences we are looking for are
- // not to be found within this branch...
- if ((rawData instanceof ISubSystem) && (((ISubSystem) rawData).getSubSystemConfiguration() != subsystem.getSubSystemConfiguration())) {
- 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
- // 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
- 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;
- }
-
-
-
-
- /**
- * Recursively tries to find the first references to a remote object.
- * This search is restricted to the given subsystem, if given.
- * @param parent the parent item at which to start the search.
- * @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.
- */
- protected Item recursiveFindFirstRemoteItemReference(Item parent, String elementName, Object elementObject, ISubSystem subsystem) {
- Object rawData = parent.getData();
- ISystemViewElementAdapter remoteAdapter = null;
- // ----------------------------
- // what are we looking at here?
- // ----------------------------
- if (rawData != null) remoteAdapter = getViewAdapter(rawData);
- // -----------------------------------------------------------------------
- // if this is a remote object, test if it is the one we are looking for...
- // -----------------------------------------------------------------------
- if (remoteAdapter != null) {
- // first test for binary match
- if (elementObject == rawData) {
- if (debugRemote) System.out.println("Remote item binary match found"); //$NON-NLS-1$
- return parent; // return the match
- }
- // now test for absolute name match
- String fqn = remoteAdapter.getAbsoluteName(rawData);
- if (debugRemote) System.out.println("TESTING FINDFIRST: '" + fqn + "' vs '" + elementName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if ((fqn != null) && fqn.equals(elementName)) {
- if ((subsystem != null) && (subsystem == remoteAdapter.getSubSystem(rawData))) {
- if (debugRemote) System.out.println("Remote item name match found and subsystems matched"); //$NON-NLS-1$
- return parent; // return the match
- } else if (subsystem == null) {
- if (debugRemote) System.out.println("Remote item name match found and subsystem null"); //$NON-NLS-1$
- return parent;
- } else if (debugRemote) System.out.println("Remote item name match found but subsystem mismatch"); //$NON-NLS-1$
- }
- }
- // -------------------------------------------------------------------------
- // if we have been given a subsystem to restrict to, that is a hint to us...
- // -------------------------------------------------------------------------
- else if ((rawData != null) && (subsystem != null)) // test for hints we are in the wrong place
- {
- // if we are currently visiting a subsystem, and that subsystem is not from the same
- // factory, then we can assume the remote object occurrences we are looking for are
- // not to be found within this branch...
- if ((rawData instanceof ISubSystem) && (rawData != subsystem)) {
- 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
- // 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
- Item[] items = getChildren(parent);
- Item match = null;
- for (int i = 0; (match == null) && (i < items.length); i++) {
- if (!items[i].isDisposed()) match = recursiveFindFirstRemoteItemReference(items[i], elementName, elementObject, subsystem);
- }
- return match;
- }
-
- /**
- * 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 <code>null</code>,
- * in which case a new List is created and returned.
- * @return List of FilterMatch objects for each affected filter, or
- * <code>null</code> if <code>null</code> was passed in as the List
- * to populate and no matches were found.
- */
- protected List findAllRemoteItemFilterReferences(String elementName, ISubSystem subsystem, List matches) {
- Tree tree = getTree();
- Item[] roots = tree.getItems();
- if (roots == null) return matches;
- if (matches == null)
- matches = new Vector();
-
- for (int idx = 0; idx < roots.length; idx++){
- matches = recursiveFindAllRemoteItemFilterReferences(roots[idx], elementName, subsystem, matches);
- }
- return matches;
-
- }
-
- /**
- * Recursively tries to find all filters which are affected by a given remote object, such that we can subsequently refresh that filter
- * after a remote resource change.
- * @param parent the parent item at which to start the search.
- * @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 <code>null</code>.
- *
- * @return The given List of occurrences, populated with FilterMatch objects
- * for each affected filter.
- */
- protected List recursiveFindAllRemoteItemFilterReferences(Item parent, String elementName, ISubSystem subsystem, List occurrences) {
- Object rawData = parent.getData();
-
- // ----------------------------
- // what are we looking at here?
- // ----------------------------
-
- // ---------------------------------------------------------------------
- // if this is a filter object, test for two things:
- // #1. does this filter list this remote object if expanded/refreshed?
- // #2. does this filter list the contents of this remote object?
- // ---------------------------------------------------------------------
- if (rawData instanceof ISystemFilterReference) {
- ISystemFilterReference filterRef = (ISystemFilterReference) rawData;
- if (filterRef.getReferencedFilter().isPromptable()) return occurrences;
- ISubSystem fss = (ISubSystem) filterRef.getProvider();
- if (fss != null) // should never happen!!
- {
- // #1
- if (fss.doesFilterMatch(filterRef.getReferencedFilter(), elementName)) {
- occurrences.add(new FilterMatch((TreeItem) parent, true)); // found a match!
- if (debugRemote) System.out.println("...Filter match found for " + elementName + ": " + filterRef.getReferencedFilter().getName()); //$NON-NLS-1$ //$NON-NLS-2$
- return occurrences; // no point in checking the kids
- }
- // #2
- else if (fss.doesFilterListContentsOf(filterRef.getReferencedFilter(), elementName)) {
- occurrences.add(new FilterMatch((TreeItem) parent, false)); // found a match!
- if (debugRemote) System.out.println("...Filter content match found for " + elementName + ": " + filterRef.getReferencedFilter().getName()); //$NON-NLS-1$ //$NON-NLS-2$
- return occurrences; // no point in checking the kids
- } else if (debugRemote) System.out.println("... no match on the filter for element name " + elementName); //$NON-NLS-1$
- }
- }
- // ----------------------------------------------------------------------
- // if this is not a filter, then before recursing on its kids, check for
- // hints that such recursion is a waste of time, for performance reasons
- // ----------------------------------------------------------------------
- else if (rawData != null) {
- // ---------------------------------------------------------------------------------
- // if we are currently visiting a subsystem, and that subsystem is not from the same
- // factory, then we can assume the remote object occurrences we are looking for are
- // not to be found within this branch...
- // ---------------------------------------------------------------------------------
- if ((rawData instanceof ISubSystem) && (subsystem != null)) {
- ISubSystem currSS = (ISubSystem) rawData;
- if (currSS.getSubSystemConfiguration() != subsystem.getSubSystemConfiguration()) 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
- // looking for are not to be found within this branch...
- // -----------------------------------------------------------------------------------------
- else if (rawData instanceof IHost) {
- if (subsystem==null) {
- return occurrences; //bug 187061: renaming a host has no subsystem associated, therefore no other matches to rename
- }
- IHost currConn = (IHost) rawData;
- if (!currConn.getHostName().equals(subsystem.getHost().getHostName()))
- return occurrences; // they don't match, so don't bother checking the kids
- }
- // skip the new connection prompts...
- else if (rawData instanceof ISystemPromptableObject)
- return occurrences;
- // ------------------------------------------------------------------------
- // if this is a remote object, we are too deep into this branch of the tree
- // for filters, so stop here
- // ------------------------------------------------------------------------
- else if (getRemoteAdapter(rawData) != null) return occurrences;
- }
- // recurse over children
- Item[] items = getChildren(parent);
- for (int i = 0; (i < items.length); i++) {
- occurrences = recursiveFindAllRemoteItemFilterReferences(items[i], elementName, subsystem, occurrences);
- }
- return occurrences;
- }
-
- /**
- * Inner class to encapsulate what is put in the List for the recursiveFindAllRemoteItemFilterReferences() method.
- */
- protected class FilterMatch {
- protected boolean filterListsElement;
- protected boolean filterListsElementContents;
- protected TreeItem match;
-
- FilterMatch(TreeItem match, boolean filterListsElement) {
- this.match = match;
- this.filterListsElement = filterListsElement;
- this.filterListsElementContents = !filterListsElement;
- }
-
- boolean listsElement() {
- return filterListsElement;
- }
-
- boolean listsElementContents() {
- return filterListsElementContents;
- }
-
- TreeItem getTreeItem() {
- return match;
- }
- }
-
- /**
- * --------------------------------------------------------------------------------
- * For many actions we have to walk the selection list and examine each selected
- * object to decide if a given common action is supported or not.
- * <p>
- * Walking this list multiple times while building the popup menu is a performance
- * hit, so we have this common method that does it only once, setting instance
- * variables for all of the decisions we are in interested in.
- * --------------------------------------------------------------------------------
- */
- protected void scanSelections(String whereFrom) {
- //System.out.println("inside scanSelections. Called from " + whereFrom);
- // here are the instance variables we set...
- // protected boolean selectionShowRefreshAction;
- // protected boolean selectionShowOpenViewActions;
- // protected boolean selectionShowDeleteAction;
- // protected boolean selectionShowRenameAction;
- // protected boolean selectionIsRemoteObject;
- // 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;
- selectionShowOpenViewActions = true;
- selectionShowGenericShowInTableAction = true;
- selectionShowDeleteAction = true;
- selectionShowRenameAction = true;
- selectionEnableDeleteAction = true;
- selectionEnableRenameAction = true;
- selectionIsRemoteObject = true;
-
- selectionHasAncestorRelation = hasAncestorRelationSelection();
-
-
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
- SystemRemoteElementResourceSet lastSet = null;
- while (elements.hasNext()) {
-
- Object element = elements.next();
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (adapter == null) continue;
-
- if (selectionShowPropertiesAction) selectionShowPropertiesAction = adapter.showProperties(element);
-
- if (selectionShowRefreshAction) selectionShowRefreshAction = adapter.showRefresh(element);
-
- if (selectionShowOpenViewActions) selectionShowOpenViewActions = adapter.showOpenViewActions(element);
-
- if (selectionShowGenericShowInTableAction) selectionShowGenericShowInTableAction = adapter.showGenericShowInTableAction(element);
-
- if (selectionShowDeleteAction) selectionShowDeleteAction = adapter.showDelete(element);
-
- if (selectionShowRenameAction) selectionShowRenameAction = adapter.showRename(element);
-
- if (selectionEnableDeleteAction) selectionEnableDeleteAction = selectionShowDeleteAction && adapter.canDelete(element) && !selectionHasAncestorRelation;
- //System.out.println("ENABLE DELETE SET TO " + selectionEnableDeleteAction);
-
- if (selectionEnableRenameAction) selectionEnableRenameAction = selectionShowRenameAction && adapter.canRename(element);
-
- if (selectionIsRemoteObject) selectionIsRemoteObject = adapter.isRemote(element);
-
- if (selectionIsRemoteObject && !selectionFlagsUpdated) {
- ISubSystem srcSubSystem = adapter.getSubSystem(element);
- if (srcSubSystem != null &&
- (srcSubSystem.isConnected() || element instanceof ISystemFilterReference || element instanceof ISubSystem))
- {
- SystemRemoteElementResourceSet set = null;
- if (lastSet != null)
- {
- if (lastSet.getViewAdapter() == adapter && lastSet.getSubSystem() == srcSubSystem)
- {
- set = lastSet;
- }
- }
- if (set == null)
- {
- set = getSetFor(srcSubSystem, adapter);
- lastSet = set;
- }
- set.addResource(element);
- }
- }
-
- }
-
-
- selectionFlagsUpdated = true;
- //System.out.println("Inside scan selections: selectionShowOpenViewActions = " + selectionShowOpenViewActions);
-
- }
-
- /**
- * Decides whether to even show the properties menu item.
- * Assumes scanSelections() has already been called
- */
- protected boolean showProperties() {
- return selectionShowPropertiesAction;
- }
-
- /**
- * Decides whether to even show the refresh menu item.
- * Assumes scanSelections() has already been called
- */
- protected boolean showRefresh() {
- return selectionShowRefreshAction;
- /*
- boolean ok = true;
- IStructuredSelection selection= (IStructuredSelection)getSelection();
- Iterator elements= selection.iterator();
- int count = 0;
- while (ok && elements.hasNext())
- {
- Object element= elements.next();
- ISystemViewElementAdapter adapter = getAdapter(element);
- if (!adapter.showRefresh(element))
- ok = false;
- }
- return ok;
- */
- }
-
- /**
- * Decides whether to even show the "open in new perspective" menu item.
- * Assumes scanSelections() has already been called
- */
- protected boolean showOpenViewActions() {
- return selectionShowOpenViewActions;
- }
-
- /**
- * Decides whether to even show the generic "show in table" menu item.
- * Assumes scanSelections() has already been called
- */
- protected boolean showGenericShowInTableAction() {
- return selectionShowGenericShowInTableAction;
- }
-
- /**
- * Decides whether all the selected objects are remote objects or not
- * Assumes scanSelections() has already been called
- */
- protected boolean areSelectionsRemote() {
- return selectionIsRemoteObject;
- }
-
- // ---------------------------
- // ISYSTEMDELETETARGET METHODS
- // ---------------------------
-
- /**
- * Required method from ISystemDeleteTarget.
- * Decides whether to even show the delete menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean showDelete() {
- if (!selectionFlagsUpdated) {
- //System.out.println("Inside showDelete. selectFlagsUpdated = false");
- scanSelections("showDelete"); //$NON-NLS-1$
- }
- return selectionShowDeleteAction;
- }
-
- /**
- * Required method from ISystemDeleteTarget
- * Decides whether to enable the delete menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean canDelete() {
- if (!selectionFlagsUpdated) {
- //System.out.println("Inside canDelete. selectFlagsUpdated = false");
- scanSelections("canDelete"); //$NON-NLS-1$
- }
- return selectionEnableDeleteAction;
- }
-
- /**
- * 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
- */
- public boolean doDelete(IProgressMonitor monitor) {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
- //int selectedCount = selection.size();
- //Object multiSource[] = new Object[selectedCount];
- //int idx = 0;
- Object element = null;
- //Object parentElement = getSelectedParent();
- ISystemViewElementAdapter adapter = null;
- 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();
- //multiSource[idx++] = element;
- adapter = getViewAdapter(element);
- if (getRemoteAdapter(element) != null) continue;
- ok = adapter.doDelete(getShell(), element, monitor);
- if (ok) {
- anyOk = true;
- deletedVector.add(element);
- }
- }
- // now we have things divided into sets
- // delete 1 set at a time
- for (int s = 0; s < _setList.size() && ok; s++) {
- set = (SystemRemoteElementResourceSet) _setList.get(s);
- ISubSystem srcSubSystem = set.getSubSystem();
- 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());
- }
- }
- }
- } catch (SystemMessageException exc) {
- SystemMessageDialog.displayErrorMessage(getShell(), exc.getSystemMessage());
- ok = false;
- } catch (Exception exc) {
- 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).
- 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);
- refreshedList.add(parent);
- }
- }
- }
- }
- }
-
- ok = false;
- }
- //System.out.println("in doDelete. Any ok? " + anyOk + ", selectionIsRemoteObject? " + selectionIsRemoteObject);
- if (anyOk) {
- if (selectionIsRemoteObject)
- sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED, deletedVector, null, null, null, this);
- else {
- Object[] deleted = new Object[deletedVector.size()];
- for (int idx = 0; idx < deleted.length; idx++)
- deleted[idx] = deletedVector.get(idx);
- sr.fireEvent(new org.eclipse.rse.core.events.SystemResourceChangeEvent(deleted, ISystemResourceChangeEvents.EVENT_DELETE_MANY, getSelectedParent()));
- }
- }
- return ok;
- }
-
- // ---------------------------
- // ISYSTEMRENAMETARGET METHODS
- // ---------------------------
-
- private class RenameJob extends WorkspaceJob
- {
- String[] newNames = null;
- Object[] elements = null;
- 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
- * @param elements array of all the elements need to be renamed
- * @param elementAdapters array of all the view adapters of the elements need to be renamed
- * @param parentElement the parent object of the list of objects to be renamed
- * @param renameMessage the title of the Rename job.
- */
- public RenameJob(String[] newNames, Object[] elements, Object[] elementAdapters, Object parentElement, String renameMessage)
- {
- super(renameMessage);
- this.newNames = newNames;
- this.elements = elements;
- this.elementAdapters = elementAdapters;
- this.parentElement = parentElement;
- setUser(true);
- }
-
- public IStatus runInWorkspace(IProgressMonitor monitor)
- {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- Object element = null;
- ISystemViewElementAdapter adapter = null;
- ISystemRemoteElementAdapter remoteAdapter = null;
- String oldFullName = ""; //$NON-NLS-1$
- String oldName = ""; //$NON-NLS-1$
- Vector fileNamesRenamed = new Vector();
-
- boolean ok = true;
- try {
- int steps = elements.length;
- monitor.beginTask(renameMessage, steps);
- for (int i=0; i < elements.length; i++)
- {
- element = elements[i];
- adapter = (ISystemViewElementAdapter)elementAdapters[i];
- remoteAdapter = getRemoteAdapter(element);
- 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)
- {
- fileNamesRenamed.add(oldName);
- if (remoteAdapter != null)
- {
- ISubSystem ss = adapter.getSubSystem(element);
- sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED, element, parentElement, ss, new String[] {oldFullName}, this);
- }
-
- else
- sr.fireEvent(new org.eclipse.rse.core.events.SystemResourceChangeEvent(element, ISystemResourceChangeEvents.EVENT_RENAME, parentElement));
- }
- monitor.worked(1);
- }
- }
- catch (SystemMessageException exc)
- {
- ok = false;
- //If this operation is cancelled, need to display a proper message to the user.
- if (monitor.isCanceled() && fileNamesRenamed.size() > 0)
- {
- //Get the renamed file names
- String renamedFileNames = (String)(fileNamesRenamed.get(0));
- for (int i=1; i<(fileNamesRenamed.size()); i++)
- {
- renamedFileNames = renamedFileNames + "\n" + fileNamesRenamed.get(i); //$NON-NLS-1$
- }
- //getMessage("RSEG1125").makeSubstitution(movedFileName));
- SystemMessage thisMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_RENAME_INTERRUPTED);
- thisMessage.makeSubstitution(renamedFileNames);
- SystemMessageDialog.displayErrorMessage(shell, thisMessage);
- }
- else
- {
- SystemMessageDialog.displayErrorMessage(shell, exc.getSystemMessage());
- }
- } catch (Exception exc) {
- //String msg = exc.getMessage();
- //if ((msg == null) || (exc instanceof ClassCastException))
- // msg = exc.getClass().getName();
- exc.printStackTrace();
- SystemMessageDialog.displayErrorMessage(null, RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_RENAMING).makeSubstitution(element, exc), //msg),
- exc);
- ok = false;
- }
-
- return Status.OK_STATUS;
- }
- }
- /**
- * Required method from ISystemRenameTarget.
- * Decides whether to even show the rename menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean showRename() {
- return selectionShowRenameAction;
- }
-
- /**
- * Required method from ISystemRenameTarget
- * 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..."
- */
- protected SystemMessage getRenamingMessage(String oldName)
- {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_RENAMEGENERIC_PROGRESS);
- msg.makeSubstitution(oldName);
- return msg;
- }
-
- /**
- * Required method from ISystemRenameTarget
- */
- public boolean doRename(String[] newNames) {
- 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;
- while (elements.hasNext()) {
- renameElements[i] = elements.next();
- elementAdapters[i] = getViewAdapter(renameElements[i]);
- i++;
- //remoteAdapter = getRemoteAdapter(element);
- }
- SystemMessage renameMessage = getRenamingMessage(""); //$NON-NLS-1$
- String renameMessageText = renameMessage.getLevelOneText();
- RenameJob renameJob = new RenameJob(newNames, renameElements, elementAdapters, parentElement, renameMessageText);
- renameJob.schedule();
- return true;
- }
-
- protected void logDebugMsg(String msg) {
- //RSEUIPlugin.logDebugMessage(this.getClass().getName(),msg);
- msg = this.getClass().getName() + ": " + msg; //$NON-NLS-1$
- SystemBasePlugin.logInfo(msg);
- System.out.println(msg);
- }
-
- // -----------------------------------------------------------------
- // ISystemSelectAllTarget methods to facilitate the global action...
- // -----------------------------------------------------------------
- /**
- * Return true if select all should be enabled for the given object.
- * For a tree view, you should return true if and only if the selected object has children.
- * You can use the passed in selection or ignore it and query your own selection.
- */
- public boolean enableSelectAll(IStructuredSelection selection) {
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
- if ((items == null) || (items.length != 1)) // only allow for single selections
- return false;
-
- TreeItem ti = items[0];
- int count = getItemCount(ti);
- if (count == 1) // is it a dummy?
- {
- if ((getItems(ti)[0]).getData() == null) count = 0; // assume a dummy
- }
- return (count > 0);
- }
-
- /**
- * 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
- * of the given selected object. You can use the passed in selected object
- * or ignore it and query the selected object yourself.
- */
- public void doSelectAll(IStructuredSelection selection) {
- Tree tree = getTree();
- TreeItem[] currSel = tree.getSelection();
- TreeItem[] childItems = currSel[0].getItems();
- if (childItems.length == 0) return;
- tree.setSelection(childItems);
- Object[] childObjects = new Object[childItems.length];
- for (int idx = 0; idx < childObjects.length; idx++)
- childObjects[idx] = childItems[idx].getData();
- 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.
- * <p>
- * Designed to be as fast as possible by going directly to the SWT widgets
- */
- public boolean sameParent() {
- boolean same = true;
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
- if ((items == null) || (items.length == 0)) return true;
- TreeItem prevParent = null;
- TreeItem currParent = null;
- for (int idx = 0; same && (idx < items.length); idx++) {
- currParent = items[idx].getParentItem();
- if ((idx > 0) && (currParent != prevParent))
- same = false;
- else {
- prevParent = currParent;
- }
- }
- return same;
- }
-
- protected boolean selectionHasAncestryRelationship() {
- if (selectionFlagsUpdated) return selectionHasAncestorRelation;
-
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
- return hasSelectedAncestor(items);
- /*
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
-
- for (int idx = 0; idx < items.length; idx++) {
- TreeItem item = items[idx];
- // for (int c = 0; c < items.length; c++) {
- // if (item != items[c]) {
- if (isAncestorOf(item, items)) {
- return true;
- }
-// }
- // }
- }
- return false;
- */
- }
-
- protected boolean isAncestorOf(TreeItem container, TreeItem[] items) {
- TreeItem[] children = container.getItems();
- for (int i = 0; i < children.length; i++) {
- TreeItem child = children[i];
- for (int j = 0; j < items.length; j++)
- {
- TreeItem item = items[j];
- if (child == item) {
- return true;
- }
- else if (child.getItemCount() > 0)
- {
- if (isAncestorOf(child, items))
- {
- return true;
- }
- }
- }
- }
- 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;
- }
- else
- {
- cleanParents.add(parent);
- parent = parent.getParentItem();
- }
- }
- }
- return false;
- }
-
-
-
-
-
-
-/*
- protected boolean isAncestorOf(TreeItem container, TreeItem item) {
- TreeItem[] children = container.getItems();
- for (int i = 0; i < children.length; i++) {
- TreeItem child = children[i];
- if (child == item) {
- return true;
- } else if (child.getItemCount() > 0) {
- if (isAncestorOf(child, item)) {
- return true;
- }
- }
- }
- return false;
- }
-*/
-
- /**
- * This is called to accurately get the parent object for the current selection
- * for this viewer.
- * <p>
- * 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.
- */
- public Object getSelectedParent() {
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
- if ((items == null) || (items.length == 0)) {
- return tree.getData();
- } else {
- TreeItem parentItem = items[0].getParentItem();
- if (parentItem != null)
- return parentItem.getData();
- else
- return tree.getData();
- }
- }
-
- /**
- * Return the TreeItem of the parent of the selected node. Or null if a root is selected.
- */
- public TreeItem getSelectedParentItem() {
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
- if ((items == null) || (items.length == 0)) {
- return null;
- } else {
- return items[0].getParentItem();
- }
- }
-
- /**
- * This returns the element immediately before the first selected element in this tree level.
- * Often needed for enablement decisions for move up actions.
- */
- public Object getPreviousElement() {
- Object prevElement = null;
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
- if ((items != null) && (items.length > 0)) {
- TreeItem item1 = items[0];
- TreeItem[] parentItems = null;
- TreeItem parentItem = item1.getParentItem();
- if (parentItem != null)
- parentItems = parentItem.getItems();
- else
- parentItems = item1.getParent().getItems();
- if (parentItems != null) {
- TreeItem prevItem = null;
- for (int idx = 0; (prevItem == null) && (idx < parentItems.length); idx++)
- if ((parentItems[idx] == item1) && (idx > 0)) prevItem = parentItems[idx - 1];
- if (prevItem != null) prevElement = prevItem.getData();
- }
- }
- return prevElement;
- }
-
- /**
- * This returns the element immediately after the last selected element in this tree level
- * Often needed for enablement decisions for move down actions.
- */
- public Object getNextElement() {
- Object nextElement = null;
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
- if ((items != null) && (items.length > 0)) {
- TreeItem itemN = items[items.length - 1];
- TreeItem[] parentItems = null;
- TreeItem parentItem = itemN.getParentItem();
- if (parentItem != null)
- parentItems = parentItem.getItems();
- else
- parentItems = itemN.getParent().getItems();
- if (parentItems != null) {
- TreeItem nextItem = null;
- for (int idx = 0; (nextItem == null) && (idx < parentItems.length); idx++)
- if ((parentItems[idx] == itemN) && (idx < (parentItems.length - 1))) nextItem = parentItems[idx + 1];
- if (nextItem != null) nextElement = nextItem.getData();
- }
- }
- return nextElement;
- }
-
- /**
- * This is called to walk the tree back up to the roots and return the visible root
- * node for the first selected object.
- */
- public Object getRootParent() {
- Tree tree = getTree();
- TreeItem[] selectedItems = tree.getSelection();
- Object rootElement = null;
- if ((selectedItems != null) && (selectedItems.length > 0)) {
- TreeItem item = selectedItems[0];
- TreeItem parentItem = item.getParentItem();
- if (parentItem == null) // item is a root element
- rootElement = item.getData();
- else
- while (rootElement == null) {
- item = parentItem;
- parentItem = item.getParentItem();
- if (parentItem == null) // item is a root element
- rootElement = item.getData();
- }
- }
- //logDebugMsg("getRootParent returned: "+rootElement);
- return rootElement;
- }
-
- /**
- * This returns an array containing each element in the tree, up to but not including the root.
- * The array is in reverse order, starting at the leaf and going up.
- */
- public Object[] getElementNodes(Object element) {
- Widget w = findItem(element);
- if ((w != null) && (w instanceof TreeItem)) return getElementNodes((TreeItem) w);
- return null;
- }
-
- /**
- * This returns an array containing each element in the tree, up to but not including the root.
- * 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.
- */
- public Object[] getElementNodes(TreeItem item) {
- List v = new Vector();
- v.add(item.getData());
- while (item != null) {
- item = item.getParentItem();
- if (item != null) v.add(item.getData());
- }
- Object[] nodes = new Object[v.size()];
- for (int idx = 0; idx < nodes.length; idx++)
- nodes[idx] = v.get(idx);
- return nodes;
- }
-
- /**
- * This returns an array containing each element in the tree, up to but not including the root.
- * 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.
- */
- public TreeItem[] getItemNodes(TreeItem item) {
- List v = new Vector();
- v.add(item);
- while (item != null) {
- item = item.getParentItem();
- if (item != null) v.add(item);
- }
- TreeItem[] nodes = new TreeItem[v.size()];
- for (int idx = 0; idx < nodes.length; idx++)
- nodes[idx] = (TreeItem) v.get(idx);
- return nodes;
- }
-
- /**
- * Helper method to determine if a given object is currently selected.
- * Does consider if a child node of the given object is currently selected.
- */
- public boolean isSelectedOrChildSelected(Object parentElement) {
- boolean isSelected = false;
- Item[] selectedItems = ((Tree) getControl()).getSelection();
- if ((selectedItems != null) && (selectedItems.length > 0)) {
- Widget w = findItem(parentElement);
- if (!(w instanceof TreeItem)) return true; // assume we have been given the root, which means any selection is a child
- TreeItem item = (TreeItem) w;
- // for every selected tree item, scan upwards to the root to see if
- // it or any of its parents are the given element.
- for (int idx = 0; !isSelected && (idx < selectedItems.length); idx++) {
- if (selectedItems[idx] instanceof TreeItem) {
- if (selectedItems[idx] == item)
- isSelected = true;
- else
- isSelected = searchToRoot((TreeItem) selectedItems[idx], item);
- }
- }
- }
- return isSelected;
- //return isSelected(element, (IStructuredSelection)getSelection());
- }
-
- /**
- * Override that takes a widget.
- */
- public boolean isTreeItemSelectedOrChildSelected(Widget w) {
- boolean isSelected = false;
- Item[] selectedItems = ((Tree) getControl()).getSelection();
- if ((selectedItems != null) && (selectedItems.length > 0)) {
- if (!(w instanceof TreeItem)) return true; // assume we have been given the root, which means any selection is a child
- TreeItem item = (TreeItem) w;
- // for every selected tree item, scan upwards to the root to see if
- // it or any of its parents are the given element.
- for (int idx = 0; !isSelected && (idx < selectedItems.length); idx++) {
- if (selectedItems[idx] instanceof TreeItem) {
- if (selectedItems[idx] == item)
- isSelected = true;
- else
- isSelected = searchToRoot((TreeItem) selectedItems[idx], item);
- }
- }
- }
- return isSelected;
- //return isSelected(element, (IStructuredSelection)getSelection());
- }
-
- /**
- * Return the number of immediate children in the tree, for the given tree node
- */
- public int getChildCount(Object element) {
- if (getTree().isDisposed()) return 0;
- Widget w = findItem(element);
- if (w == null)
- return 0;
-
- // modified patch initially provided by Tobias Schwarz
- if (w instanceof TreeItem) {
- TreeItem ti = (TreeItem) w;
- int count = getItemCount((Item) w);
- int ignoreItems = 0;
- if (count > 0) {
- Item[] items = getItems(ti);
- for (int i=0; i<count; i++) {
- Object itemData = items[i].getData();
- if (itemData==null
- || itemData instanceof SystemMessageObject
- || itemData instanceof PendingUpdateAdapter
- ) {
- ignoreItems++;
- } else {
- break;
- }
- }
- }
- return count - ignoreItems;
- }
- return getItemCount((Control) w);
- }
-
- /**
- * Return the tree item of the first selected object
- */
- protected TreeItem getFirstSelectedTreeItem() {
- // find the selected tree item...
- Item[] selectedItems = ((Tree) getControl()).getSelection();
- if ((selectedItems == null) || (selectedItems.length == 0) || !(selectedItems[0] instanceof TreeItem)) return null;
- return (TreeItem) selectedItems[0];
- }
-
- /**
- * Refresh the given tree item node
- */
- protected void refreshTreeItem(TreeItem item) {
- // if we are already expanded, collapse and refresh to clear memory
- if (getExpanded(item)) {
- collapseNode(item.getData(), true);
- //setExpanded(selectedItem, false);
- //refreshItem(selectedItem, selectedItem.getData());
- }
- // ok, now time to force an expand...
- createChildren(item); // re-expand. this calls the content provider, which calls the getChildren() method in the adapter. That will call us back.
- item.setExpanded(true);
- }
-
- /**
- * Called when a property is updated and we need to inform the Property Sheet viewer.
- * There is no formal mechanism for this so we simulate a selection changed event as
- * this is the only event the property sheet listens for.
- */
- public void updatePropertySheet() {
- ISelection selection = getSelection();
- if (selection == null) return;
-
- // only fire this event if the view actually has focus
- if (getControl().isFocusControl())
- {
- // create an event
- SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
- // fire the event
- fireSelectionChanged(event);
- }
- }
-
- /**
- * Called to select an object within the tree, and optionally expand it
- */
- public void select(Object element, boolean expand) {
- setSelection(new StructuredSelection(element), true); // true => reveal
- if (expand) setExpandedState(element, true);
- }
-
- /**
- * Returns the tree item of the first selected object. Used for setViewerItem in a resource
- * change event.
- */
- public Item getViewerItem() {
- TreeItem[] selectedItems = getTree().getSelection();
- if ((selectedItems != null) && (selectedItems.length > 0))
- return selectedItems[0];
- else
- return null;
- }
-
- /**
- * Returns true if any of the selected items are currently expanded
- */
- public boolean areAnySelectedItemsExpanded() {
- boolean expanded = false;
- Item[] selectedItems = ((Tree) getControl()).getSelection();
- if ((selectedItems != null) && (selectedItems.length > 0)) {
- // for every selected tree item, see if it is currently expanded...
- for (int idx = 0; !expanded && (idx < selectedItems.length); idx++) {
- if (selectedItems[idx] instanceof TreeItem) {
- if (((TreeItem) selectedItems[idx]).getExpanded()) expanded = true;
- }
- }
- }
- return expanded;
- }
-
- /**
- * Returns true if any of the selected items are expandable but not yet expanded
- */
- public boolean areAnySelectedItemsExpandable() {
- boolean expandable = false;
- Item[] selectedItems = ((Tree) getControl()).getSelection();
- if ((selectedItems != null) && (selectedItems.length > 0)) {
- // for every selected tree item, see if needs expanding...
- for (int idx = 0; !expandable && (idx < selectedItems.length); idx++) {
- if (selectedItems[idx] instanceof TreeItem) {
- if ((((TreeItem) selectedItems[idx]).getItemCount() > 0) && !((TreeItem) selectedItems[idx]).getExpanded()) expandable = true;
- }
- }
- }
- return expandable;
- }
-
-
- /**
- * Initialize drag and drop support for this view.
- *
- */
- protected void initDragAndDrop()
- {
- int ops = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] dragtransfers = new Transfer[]
- { PluginTransfer.getInstance(),
- EditorInputTransfer.getInstance()
- };
-
- Transfer[] droptransfers = new Transfer[]
- { PluginTransfer.getInstance(),
- FileTransfer.getInstance(),
- EditorInputTransfer.getInstance(),
- ResourceTransfer.getInstance()
- };
-
- addDragSupport(ops | DND.DROP_DEFAULT, dragtransfers, new SystemViewDataDragAdapter(this));
- addDropSupport(ops | DND.DROP_DEFAULT, droptransfers, new SystemViewDataDropAdapter(this));
- }
- // ----------------------------------
- // Support for EXPAND TO-> ACTIONS...
- // ----------------------------------
-
- public void expandTo(Object parentObject, Object remoteObject)
- {
- SystemViewLabelAndContentProvider provider = (SystemViewLabelAndContentProvider)getContentProvider();
- provider.setEnableDeferredQueries(false);
-
- ISystemViewElementAdapter adapter = getViewAdapter(parentObject);
- ISystemViewElementAdapter targetAdapter = getViewAdapter(remoteObject);
- Assert.isNotNull(adapter, "adapter is null for " + parentObject); //$NON-NLS-1$
- ISubSystem ss = adapter.getSubSystem(parentObject);
- String parentName = adapter.getAbsoluteName(parentObject);
- String remoteObjectName = targetAdapter.getAbsoluteName(remoteObject);
- Item parentItem = findFirstRemoteItemReference(parentName, ss, null);
- if (parentItem != null)
- {
- createChildren(parentItem);
- Item[] children = getItems(parentItem);
- setExpanded(parentItem, true);
- for (int i = 0; i < children.length; i++)
- {
-
- Item child = children[i];
- Object data = child.getData();
- if (data.equals(remoteObject))
- {
- select(remoteObject, false);
- provider.setEnableDeferredQueries(true);
- return;
- }
- else if (data instanceof ISystemFilterReference)
- {
- ISystemFilterReference ref = (ISystemFilterReference)data;
- if (ss.doesFilterMatch(ref.getReferencedFilter(), remoteObjectName)){
- expandTo(data, remoteObject);
- }
- else if (ss.doesFilterListContentsOf(ref.getReferencedFilter(),remoteObjectName)){
- expandTo(data, remoteObject);
- }
- }
- else if (data instanceof ISystemFilterPoolReference)
- {
- expandTo(data, remoteObject);
- }
- else
- {
- ISystemViewElementAdapter dataAdapter = (ISystemViewElementAdapter)((IAdaptable)data).getAdapter(ISystemViewElementAdapter.class);
- String path = dataAdapter.getAbsoluteName(data);
- if (remoteObjectName.startsWith(path))
- {
- expandTo(data, remoteObject);
- }
- }
- }
- }
- provider.setEnableDeferredQueries(true);
- }
-
-
- /**
- * Called when user selects an Expand To action to expand the selected remote object with a quick filter
- */
- public void expandTo(String filterString) {
- SystemViewPart svp = getSystemViewPart();
- if (svp == null) return;
- // find the selected tree item...
- TreeItem selectedItem = getFirstSelectedTreeItem();
- if (selectedItem == null) return;
- Object element = selectedItem.getData();
- ISystemViewElementAdapter remoteAdapter = getViewAdapter(element);
- if (remoteAdapter == null) return;
- // update our hashtables, keyed by object address and tree path...
- if (expandToFiltersByObject == null) expandToFiltersByObject = new Hashtable();
- if (expandToFiltersByTreePath == null) expandToFiltersByTreePath = new Hashtable();
- if (filterString != null)
- expandToFiltersByObject.put(selectedItem.getData(), filterString);
- else
- expandToFiltersByObject.remove(selectedItem.getData());
- if (filterString != null)
- expandToFiltersByTreePath.put(getItemPath(selectedItem), filterString);
- else
- expandToFiltersByTreePath.remove(getItemPath(selectedItem));
-
- // now refresh this tree item node...
- refreshTreeItem(selectedItem);
- }
-
- /**
- * Return the fully-qualified path up to the given item, expressible as a string
- */
- protected String getItemPath(TreeItem item) {
- StringBuffer idBuffer = new StringBuffer(getItemNodeID(item));
- TreeItem[] elementNodes = getItemNodes(item);
- if (elementNodes != null) {
- for (int idx = elementNodes.length - 1; idx >= 0; idx--) {
- item = elementNodes[idx];
- idBuffer.append(SystemViewPart.MEMENTO_DELIM + getItemNodeID(item));
- }
- }
- //System.out.println("MEMENTO HANDLE: " + idBuffer.toString());
- return idBuffer.toString();
- }
-
- /**
- * Return the string identifying this node in the tree
- */
- protected String getItemNodeID(TreeItem item) {
- //ISystemViewElementAdapter adapter = getAdapter(item.getData());
- //return adapter.getMementoHandle(item.getData());
- return item.getText();
- }
-
- /**
- * Callback from the input provider to test if the given node has expand-to filtering criteria
- */
- public String getExpandToFilter(Object element) {
- String filter = null;
- // for performance reasons, we first test for a binary match...
- if (expandToFiltersByObject != null) {
- filter = (String) expandToFiltersByObject.get(element);
- }
- // if binary match fails, look for tree path match...
- if ((filter == null) && (expandToFiltersByTreePath != null)) {
- Widget item = findItem(element);
- if ((item != null) && (item instanceof TreeItem)) {
- filter = (String) expandToFiltersByTreePath.get(getItemPath((TreeItem) item));
- if (filter != null) {
- if (expandToFiltersByObject == null) expandToFiltersByObject = new Hashtable();
- expandToFiltersByObject.put(element, filter); // so next time it will be faster
- }
- }
- }
- return filter;
- }
-
- /**
- * To support restoring state we need to write out to disk out current table that maps
- * tree items to their current expand-to filter. That means we need access to the table.
- */
- public Hashtable getExpandToFilterTable() {
- return expandToFiltersByTreePath;
- }
-
- /**
- * To support restoring state we need to write out to disk out current table that maps
- * tree items to their current expand-to filter. That means we need to be able to set the table.
- */
- public void setExpandToFilterTable(Hashtable ht) {
- expandToFiltersByTreePath = ht;
- }
-
- protected SystemRemoteElementResourceSet getSetFor(ISubSystem subSystem, ISystemViewElementAdapter adapter) {
- for (int i = 0; i < _setList.size(); i++) {
- SystemRemoteElementResourceSet set = (SystemRemoteElementResourceSet) _setList.get(i);
- if (set.getViewAdapter() == adapter && set.getSubSystem() == subSystem) {
- return set;
- }
- }
-
- // no existing set - create one
- SystemRemoteElementResourceSet newSet = new SystemRemoteElementResourceSet(subSystem, adapter);
- _setList.add(newSet);
- return newSet;
- }
-/*
- protected boolean usingElementMap() {
- return false;
- }
-*/
-
- /**
- * For bug 204684:
- *
- * Because we don't have an API for ISystemViewElementAdapter.exists()...
- * This class is used to determine whether an object exists and consequently whether to remove it from the view
- * after a query comes back with either no children or a SystemMessageObject. We query the parent to determine
- * whether the remote object exists - in that case we just leave the message as is in the view. In the case where
- * we detect that the object does not exist, we re-populate the parent node with the new children.
- */
- public static class CheckExistenceJob extends Job
- {
-
-
- private IAdaptable _remoteObject;
- //private TreeItem _parentItem;
- private IContextObject _context;
- public CheckExistenceJob(IAdaptable remoteObject, TreeItem parentItem, IContextObject context)
- {
- super("Check existence"); //$NON-NLS-1$
- _remoteObject = remoteObject;
- //_parentItem = parentItem;
- _context = context;
- }
-
- public IStatus run(IProgressMonitor monitor)
- {
- // need to use the model object to get the adapter (since it could be a filter)
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)_context.getModelObject().getAdapter(ISystemViewElementAdapter.class);
- if (adapter != null)
- {
- final Object[] children = adapter.getChildren(_context, monitor);
- if (contains(children, _remoteObject))
- {
- // we want to end this so the user sees the error message
- }
- else
- {
- Display.getDefault().asyncExec(new Runnable(){
- public void run()
- {
- /*
- // first need to remove the old items
- TreeItem[] items = _parentItem.getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i].getData() != null) {
- disassociate(items[i]);
- items[i].dispose();
- } else {
- items[i].dispose();
- }
- }
-
-
- // we want to propagate the changes to the view
- add(_context.getModelObject(), children);
- */
- // refresh using the event since other views may need updating
- IAdaptable par = _context.getModelObject();
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
-
- }
- });
- }
- }
-
- return Status.OK_STATUS;
- }
-
- public static boolean contains(Object[] children, IAdaptable remoteObject)
- {
- ISystemViewElementAdapter adapter1 = (ISystemViewElementAdapter)remoteObject.getAdapter(ISystemViewElementAdapter.class);
- String path1 = adapter1==null ? null : adapter1.getAbsoluteName(remoteObject);
- for (int i = 0; i < children.length; i++)
- {
- if (remoteObject==children[i] || remoteObject.equals(children[i]))
- {
- return true;
- }
- else if (children[i] instanceof IAdaptable)
- {
- IAdaptable remoteObject2 = (IAdaptable)children[i];
- ISystemViewElementAdapter adapter2 = (ISystemViewElementAdapter)remoteObject2.getAdapter(ISystemViewElementAdapter.class);
- if (adapter2 != null)
- {
- String path2 = adapter2.getAbsoluteName(remoteObject2);
- if (path1 != null && path2 != null && path1.equals(path2))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- }
-
-
- public void add(Object parentElementOrTreePath, Object[] childElements) {
-
- assertElementsNotNull(childElements);
- IContextObject contextObject = null;
- ISystemFilterReference originalFilter = null;
- if (parentElementOrTreePath instanceof IContextObject)
- {
- contextObject = (IContextObject)parentElementOrTreePath;
- originalFilter = contextObject.getFilterReference();
- parentElementOrTreePath = contextObject.getModelObject();
-
- }
-
- List matches = new Vector();
- findAllRemoteItemReferences(parentElementOrTreePath, parentElementOrTreePath, matches);
-
- // get rid of references to items for different connection
- if (parentElementOrTreePath instanceof IAdaptable)
- {
- List invalidMatches = new ArrayList();
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)parentElementOrTreePath).getAdapter(ISystemViewElementAdapter.class);
- if (adapter != null)
- {
- IHost parentHost = adapter.getSubSystem(parentElementOrTreePath).getHost();
- for (int i = 0; i < matches.size(); i++)
- {
- Widget match = (Widget) matches.get(i);
- Object data = null;
- try {
- data = match.getData();
- }
- catch (SWTException e){
- // not sure why this occurs -logging it for now
- // this is reported in bug 251625
- SystemBasePlugin.logError("Exception in SystemView.add() with " + match); //$NON-NLS-1$
- SystemBasePlugin.logError(e.getMessage());
- }
-
- if (data instanceof IAdaptable)
- {
- ISystemViewElementAdapter madapter = (ISystemViewElementAdapter)((IAdaptable)data).getAdapter(ISystemViewElementAdapter.class);
- if (madapter != null)
- {
- IHost mHost = madapter.getSubSystem(data).getHost();
- if (mHost != parentHost)
- {
- invalidMatches.add(match);
- }
- }
- }
- }
- }
-
- if (invalidMatches.size() > 0)
- {
- for (int m = invalidMatches.size() - 1; m >= 0 ; m--)
- {
- Object match = invalidMatches.get(m);
- matches.remove(match);
- }
- }
- }
-
- //Widget[] widgets = internalFindItems(parentElementOrTreePath);
- // If parent hasn't been realized yet, just ignore the add.
- if (matches.size() == 0) {
- super.add(parentElementOrTreePath, childElements);
- }
- else
- {
- for (int i = 0; i < matches.size(); i++) {
- Widget match = (Widget) matches.get(i);
- ISystemFilterReference ref = null;
- if (match instanceof TreeItem)
- {
- ref = getContainingFilterReference((TreeItem)match);
- }
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)parentElementOrTreePath).getAdapter(ISystemViewElementAdapter.class);
-
- if (matches.size() > 1 && ref != null && ref != originalFilter)
- {
- // could have the same object under multiple filters
- // need to apply filter
-
- Object[] newChildren = null;
- if (match instanceof TreeItem)
- {
- ContextObjectWithViewer context = getContextObject((TreeItem)match);
- newChildren = adapter.getChildren(context, new NullProgressMonitor());
- internalAdd(match, parentElementOrTreePath, newChildren);
- }
- }
- else
- {
- internalAdd(match, parentElementOrTreePath, childElements);
-
- // refresh parent in this case because the parentElementOrTreePath may no longer exist
- if (childElements.length == 0 || childElements[0] instanceof SystemMessageObject)
- {
- if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))
- {
- /*
- // refresh the parent
- Object par = adapter.getParent(parentElementOrTreePath);
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
-
- */
-
- // for bug 204684, using this job to determine whether or not the object exists before trying to update
- if (match instanceof TreeItem)
- {
- TreeItem parentItem = ((TreeItem)match).getParentItem();
- if (parentItem != null)
- {
- ContextObjectWithViewer context = getContextObject(parentItem);
- if (adapter.supportsDeferredQueries(context.getSubSystem())) {
- CheckExistenceJob job = new CheckExistenceJob((IAdaptable)parentElementOrTreePath, parentItem, context);
- job.schedule();
- } else {
- Object[] children = adapter.getChildren(context, new NullProgressMonitor());
- if (!CheckExistenceJob.contains(children, (IAdaptable)parentElementOrTreePath)) {
- IAdaptable par = context.getModelObject();
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
- }
- }
- }
- }
- }
- }
-
- }
- }
- }
-
- TreeItem item = getFirstSelectedTreeItem();
- if (item != null)
- {
- if (item.getData() == parentElementOrTreePath)
- {
- updatePropertySheet();
- }
- }
-
- // for bug 187739
- if (contextObject instanceof ContextObjectWithViewer) {
- ContextObjectWithViewer ctx = (ContextObjectWithViewer)contextObject;
- IRSECallback cb = ctx.getCallback();
- if (cb!=null) {
- cb.done(Status.OK_STATUS, childElements);
- }
- }
- }
-
-
- /**
- * Get the containing filter reference for an item
- * @param item the item to get the filter reference for
- * @return the filter reference
- */
- public ISystemFilterReference getContainingFilterReference(TreeItem item)
- {
- Object data = item.getData();
- if (data instanceof ISystemFilterReference)
- {
- return (ISystemFilterReference)data;
- }
- else
- {
- TreeItem parent = item.getParentItem();
- if (parent != null)
- {
- return getContainingFilterReference(parent);
- }
- else
- {
- Object input = getInput();
- if (input instanceof ISystemFilterReference)
- {
- return (ISystemFilterReference)input;
- }
- else
- {
- return null;
- }
- }
- }
- }
-
- /**
- * Get the containing subsystem from an item
- * @param item the item to get the subsystem for
- * @return the subsystem
- */
- public ISubSystem getContainingSubSystem(TreeItem item)
- {
- Object data = item.getData();
- if (data instanceof ISubSystem)
- {
- return (ISubSystem)data;
- }
- else
- {
- TreeItem parent = item.getParentItem();
- if (parent != null)
- {
- return getContainingSubSystem(parent);
- }
- else
- {
- Object input = getInput();
- if (input instanceof ISubSystem)
- {
- return (ISubSystem)input;
- }
- else
- {
- return null;
- }
- }
- }
- }
-
-
- /**
- * Get the context object from a tree item
- * @param item the item to get the context for
- * @return the context object
- */
- public ContextObjectWithViewer getContextObject(TreeItem item)
- {
- Object data = item.getData();
- ISystemFilterReference filterReference = getContainingFilterReference(item);
- if (filterReference != null)
- {
- return new ContextObjectWithViewer(data, filterReference.getSubSystem(), filterReference, this);
- }
- else
- {
- ISubSystem subSystem = getContainingSubSystem(item);
- if (subSystem != null)
- {
- return new ContextObjectWithViewer(data, subSystem, this);
- }
- else
- {
- return new ContextObjectWithViewer(data, this);
- }
- }
- }
-
-
- /**
- * Create tree items for the specified children
- *
- * @param widget the parent item for the items to create
- * @param children the children to create items for
- */
- public void createTreeItems(TreeItem widget, Object[] children)
- {
- TreeItem[] tis = widget.getItems();
-
- // first dispose of dummies
- for (int i = 0; i < tis.length; i++) {
- if (tis[i].getData() != null) {
- disassociate(tis[i]);
- Assert.isTrue(tis[i].getData() == null,
- "Second or later child is non -null");//$NON-NLS-1$
- }
- tis[i].dispose();
- }
-
- // now create children
- for (int i = 0; i < children.length; i++)
- {
- createTreeItem(widget, children[i], -1);
- }
- }
-
- /**
- * For bug 187739
- */
- protected void createChildren(final Widget widget, IRSECallback callback)
- {
- if (widget instanceof TreeItem)
- {
- final Item[] tis = getChildren(widget);
- if (tis != null && tis.length > 0) {
- Object data = tis[0].getData();
- if (data != null) {
- return; // children already there!
- }
- }
- final IRSECallback cb = callback;
-
- BusyIndicator.showWhile(widget.getDisplay(), new Runnable() {
- public void run() {
- // fix for PR 1FW89L7:
- // don't complain and remove all "dummies" ...
- if (tis != null) {
- for (int i = 0; i < tis.length; i++) {
- if (tis[i].getData() != null) {
- disassociate(tis[i]);
- Assert.isTrue(tis[i].getData() == null,
- "Second or later child is non -null");//$NON-NLS-1$
-
- }
- tis[i].dispose();
- }
- }
- Object d = widget.getData();
- if (d != null)
- {
- ContextObjectWithViewer parentElement = getContextObject((TreeItem)widget);
- if (cb != null){
- parentElement.setCallback(cb);
- }
-
- Object[] children = getSortedChildren(parentElement);
- if (children != null)
- {
- for (int i = 0; i < children.length; i++)
- {
- createTreeItem(widget, children[i], -1);
- }
- }
- }
- }
-
- });
- }
- else
- {
- super.createChildren(widget);
- }
- }
-
- /**
- * Overridden so that we can pass a wrapper IContextObject into the provider to get children instead
- * of the model object, itself
- */
- protected void createChildren(final Widget widget)
- {
- createChildren(widget, null);
- }
-
- /**
- * Override to pass context into hasChildren()
- *
- */
- public boolean isExpandable(Object elementOrTreePath) {
- Object element;
- TreePath path;
- if (elementOrTreePath instanceof TreePath) {
- path = (TreePath) elementOrTreePath;
- element = path.getLastSegment();
- } else {
- element = elementOrTreePath;
- path = null;
- }
- IContentProvider cp = getContentProvider();
- if (cp instanceof ITreePathContentProvider) {
- ITreePathContentProvider tpcp = (ITreePathContentProvider) cp;
- if (path == null) {
- // A path was not provided so try and find one
- Widget w = findItem(element);
- if (w instanceof Item) {
- Item item = (Item) w;
- path = getTreePathFromItem(item);
- }
- if (path == null) {
- path = new TreePath(new Object[] { element });
- }
- }
- return tpcp.hasChildren(path);
- }
- if (cp instanceof ITreeContentProvider)
- {
- ITreeContentProvider tcp = (ITreeContentProvider) cp;
- if (elementOrTreePath instanceof TreeItem)
- {
- ContextObjectWithViewer context = getContextObject((TreeItem)elementOrTreePath);
- return tcp.hasChildren(context);
- }
- else
- {
- return tcp.hasChildren(element);
- }
- }
- return false;
- }
-
- public void update(Object element, String[] properties) {
- Assert.isNotNull(element);
- List matches = new Vector();
- findAllRemoteItemReferences(element, element, matches);
-
- for (int i = 0; i < matches.size(); i++) {
-
- internalUpdate((Widget)matches.get(i), element, properties);
- }
- }
-
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForConnections.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForConnections.java
deleted file mode 100644
index 59442b816..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForConnections.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * It is used when the contents are the children of a particular connection.
- * Used when user right clicks on a connection and selects Open In New Perspective.
- */
-public class SystemViewAPIProviderForConnections
- extends SystemAbstractAPIProvider
-{
-
-
- protected IHost connection = null;
-
- /**
- * Constructor
- * @param connection The connection object we are drilling down on.
- */
- public SystemViewAPIProviderForConnections(IHost connection)
- {
- super();
- this.connection = connection;
- }
-
- /**
- * Get the input connection object.
- */
- public IHost getConnection()
- {
- return connection;
- }
- /**
- * Reset the input connection object.
- */
- public void setConnection(IHost connection)
- {
- this.connection = connection;
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
- /**
- * Return the children objects to consistute the root elements in the system view tree.
- * We return all subsystems for this connection
- */
- public Object[] getSystemViewRoots()
- {
- //return sr.getSubSystems(connection);
- return getViewAdapter(connection).getChildren(connection, new NullProgressMonitor()); // pc42690
- }
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- * We return true, assuming there is at least one subsystem object
- */
- public boolean hasSystemViewRoots()
- {
- return true;
- }
- /**
- * This method is called by the connection adapter when the user expands
- * a connection. This method must return the child objects to show for that
- * connection.
- * <p>Not applicable for us.
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- //return sr.getSubSystems(selectedConnection);
- return getViewAdapter(selectedConnection).getChildren(selectedConnection, new NullProgressMonitor()); // pc42690
- }
- /**
- * This method is called by the connection adapter when deciding to show a plus-sign
- * or not beside a connection. Return true if this connection has children to be shown.
- * <p>Not applicable for us.
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- return true;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilterPools.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilterPools.java
deleted file mode 100644
index 773aa5edd..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilterPools.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * It is used when the contents are the children of a particular subsystem.
- * Used when user right clicks on a filter pool and selects Open In New Perspective.
- */
-public class SystemViewAPIProviderForFilterPools
- extends SystemAbstractAPIProvider
-{
-
-
- protected ISubSystem subsystem = null;
- protected ISystemFilterPool filterPool = null;
- protected ISystemFilterPoolReference filterPoolReference = null;
-
- /**
- * Constructor
- * @param filterPoolReference The filterpool reference object we are drilling down on.
- */
- public SystemViewAPIProviderForFilterPools(ISystemFilterPoolReference filterPoolReference)
- {
- super();
- setFilterPoolReference(filterPoolReference);
- }
-
- /**
- * Get the parent subsystem object.
- */
- public ISubSystem getSubSystem()
- {
- return subsystem;
- }
- /**
- * Get the input filter pool reference object.
- */
- public ISystemFilterPoolReference getSystemFilterPoolReference()
- {
- return filterPoolReference;
- }
- /**
- * Get the filter pool referenced by the input filter pool reference object.
- */
- public ISystemFilterPool getSystemFilterPool()
- {
- return filterPool;
- }
-
- /**
- * Reset the input filter pool reference object.
- */
- public void setFilterPoolReference(ISystemFilterPoolReference filterPoolReference)
- {
- this.filterPoolReference = filterPoolReference;
- this.filterPool = filterPoolReference.getReferencedFilterPool();
- this.subsystem = (ISubSystem)filterPoolReference.getProvider();
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
- /**
- * Return the children objects to consistute the root elements in the system view tree.
- * We return all filters for this filter pool
- */
- public Object[] getSystemViewRoots()
- {
- return filterPoolReference.getSystemFilterReferences(getSubSystem());
- }
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- * We return true if the referenced filter pool has any filters
- */
- public boolean hasSystemViewRoots()
- {
- return (filterPool.getSystemFilterCount() > 0);
- }
- /**
- * This method is called by the connection adapter when the user expands
- * a connection. This method must return the child objects to show for that
- * connection.
- * <p>Not applicable for us.
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- return null;
- }
- /**
- * This method is called by the connection adapter when deciding to show a plus-sign
- * or not beside a connection. Return true if this connection has children to be shown.
- * <p>Not applicable for us.
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilterStrings.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilterStrings.java
deleted file mode 100644
index a30acf68c..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilterStrings.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.filters.ISystemFilterString;
-import org.eclipse.rse.core.filters.ISystemFilterStringReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemMessageObject;
-import org.eclipse.rse.core.model.SystemMessageObject;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * It is used when the contents are the children of a particular subsystem.
- * Used when user right clicks on a filter string and selects Open In New Perspective.
- */
-public class SystemViewAPIProviderForFilterStrings
- extends SystemAbstractAPIProvider
-{
-
-
- protected ISubSystem subsystem = null;
- protected ISystemFilterPool filterPool = null;
- protected ISystemFilterPoolReference filterPoolReference = null;
- protected ISystemFilterReference filterReference = null;
- protected ISystemFilter filter = null;
- protected ISystemFilterString filterString = null;
- protected ISystemFilterStringReference filterStringReference = null;
-
- /**
- * Constructor
- * @param filterStringReference The filter string reference object we are drilling down on.
- */
- public SystemViewAPIProviderForFilterStrings(ISystemFilterStringReference filterStringReference)
- {
- super();
- setFilterStringReference(filterStringReference);
- }
-
- /**
- * Get the parent subsystem object.
- */
- public ISubSystem getSubSystem()
- {
- return subsystem;
- }
- /**
- * Get the parent filter pool reference object.
- */
- public ISystemFilterPoolReference getSystemFilterPoolReference()
- {
- return filterPoolReference;
- }
- /**
- * Get the parent filter pool.
- */
- public ISystemFilterPool getSystemFilterPool()
- {
- return filterPool;
- }
- /**
- * Get the parent filter reference object.
- */
- public ISystemFilterReference getSystemFilterReference()
- {
- return filterReference;
- }
- /**
- * Get the parent filter
- */
- public ISystemFilter getSystemFilter()
- {
- return filter;
- }
- /**
- * Get the input filter string reference object.
- */
- public ISystemFilterStringReference getSystemFilterStringReference()
- {
- return filterStringReference;
- }
- /**
- * Get the filter referenced by the input filter string reference object.
- */
- public ISystemFilterString getSystemFilterString()
- {
- return filterString;
- }
-
-
- /**
- * Reset the input filter string reference object.
- */
- public void setFilterStringReference(ISystemFilterStringReference filterStringReference)
- {
- this.filterStringReference = filterStringReference;
- this.filterString = filterStringReference.getReferencedFilterString();
- this.filterReference = filterStringReference.getParent();
- this.filter = filterReference.getReferencedFilter();
- this.filterPoolReference = filterReference.getParentSystemFilterReferencePool();
- this.filterPool = filterPoolReference.getReferencedFilterPool();
- this.subsystem = (ISubSystem)filterPoolReference.getProvider();
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
- /**
- * Return the children objects to consistute the root elements in the system view tree.
- * What we return depends on setting of Show Filter Strings.
- */
- public Object[] getSystemViewRoots()
- {
- ISubSystem ss = subsystem;
- Object element = filterStringReference;
- Object[] children = null;
- try
- {
- children = ss.resolveFilterString(filterStringReference.getString(), new NullProgressMonitor());
- children = checkForEmptyList(children, element, true);
- }
- catch (InterruptedException exc)
- {
- children = new SystemMessageObject[1];
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED),
- ISystemMessageObject.MSGTYPE_CANCEL, element);
- System.out.println("Cancelled."); //$NON-NLS-1$
- }
- catch (Exception exc)
- {
- children = new SystemMessageObject[1];
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED),
- ISystemMessageObject.MSGTYPE_ERROR, element);
- System.out.println("Exception resolving filter strings: " + exc.getClass().getName() + ", " + exc.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- exc.printStackTrace();
- } // message already issued
- return children;
- }
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- * We return true
- */
- public boolean hasSystemViewRoots()
- {
- return true;
- }
- /**
- * This method is called by the connection adapter when the user expands
- * a connection. This method must return the child objects to show for that
- * connection.
- * <p>Not applicable for us.
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- return null;
- }
- /**
- * This method is called by the connection adapter when deciding to show a plus-sign
- * or not beside a connection. Return true if this connection has children to be shown.
- * <p>Not applicable for us.
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilters.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilters.java
deleted file mode 100644
index 7ce326bae..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForFilters.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * Martin Oberhuber (Wind River) - [218524][api] Remove deprecated ISystemViewInputProvider#getShell()
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemMessageObject;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.model.SystemMessageObject;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.SubSystemHelpers;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-
-
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * It is used when the contents are the children of a particular subsystem.
- * Used when user right clicks on a filter and selects Open In New Perspective.
- */
-public class SystemViewAPIProviderForFilters
- extends SystemAbstractAPIProvider
-{
-
-
- protected ISubSystem subsystem = null;
- protected ISystemFilterPool filterPool = null;
- protected ISystemFilterPoolReference filterPoolReference = null;
- protected ISystemFilterReference filterReference = null;
- protected ISystemFilter filter = null;
-
- /**
- * Constructor
- * @param filterReference The filter reference object we are drilling down on.
- */
- public SystemViewAPIProviderForFilters(ISystemFilterReference filterReference)
- {
- super();
- setFilterReference(filterReference);
- }
-
- /**
- * Get the parent subsystem object.
- */
- public ISubSystem getSubSystem()
- {
- return subsystem;
- }
- /**
- * Get the parent filter pool reference object.
- */
- public ISystemFilterPoolReference getSystemFilterPoolReference()
- {
- return filterPoolReference;
- }
- /**
- * Get the parent filter pool.
- */
- public ISystemFilterPool getSystemFilterPool()
- {
- return filterPool;
- }
- /**
- * Get the input filter reference object.
- */
- public ISystemFilterReference getSystemFilterReference()
- {
- return filterReference;
- }
- /**
- * Get the filter referenced by the input filter reference object.
- */
- public ISystemFilter getSystemFilter()
- {
- return filter;
- }
-
- /**
- * Reset the input filter reference object.
- */
- public void setFilterReference(ISystemFilterReference filterReference)
- {
- this.filterReference = filterReference;
- this.filter = filterReference.getReferencedFilter();
- this.filterPoolReference = filterReference.getParentSystemFilterReferencePool();
- this.filterPool = filterPoolReference.getReferencedFilterPool();
- this.subsystem = (ISubSystem)filterPoolReference.getProvider();
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
- /**
- * Return the children objects to consistute the root elements in the system view tree.
- * What we return depends on setting of Show Filter Strings.
- */
- public Object[] getSystemViewRoots()
- {
- // see getChildren() OF SystemViewFilterReferenceAdapter. TODO: RE-USE VS COPY!
- Object[] children = null;
- ISystemFilterReference fRef = filterReference;
- Object element = fRef;
- //Object[] children = fRef.getChildren(getShell());
- ISystemFilter referencedFilter = fRef.getReferencedFilter();
-
- ISubSystemConfiguration ssf = SubSystemHelpers.getParentSubSystemConfiguration(referencedFilter);
- boolean promptable = referencedFilter.isPromptable();
- //System.out.println("Promptable? " + promptable);
- if (promptable)
- {
- children = new SystemMessageObject[1];
- try {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssf.getAdapter(ISubSystemConfigurationAdapter.class);
- ISystemFilter newFilter = adapter.createFilterByPrompting(ssf, fRef, RSEUIPlugin.getTheSystemRegistryUI().getShell());
- if (newFilter == null)
- {
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED),
- ISystemMessageObject.MSGTYPE_CANCEL,element);
- }
- else // filter successfully created!
- {
- // return "filter created successfully" message object for this node
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FILTERCREATED),
- ISystemMessageObject.MSGTYPE_OBJECTCREATED,element);
- // select the new filter reference...
- ISubSystem ss = fRef.getSubSystem();
- ISystemFilterReference sfr = fRef.getParentSystemFilterReferencePool().getExistingSystemFilterReference(ss, newFilter);
- ISystemViewInputProvider inputProvider = this;
- if ((sfr != null) && (inputProvider.getViewer()!=null))
- {
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(sfr, ISystemResourceChangeEvents.EVENT_SELECT_EXPAND, null);
- Viewer v = (Viewer)inputProvider.getViewer();
- if (v instanceof ISystemResourceChangeListener)
- {
- //sr.fireEvent((ISystemResourceChangeListener)v, event); // only expand in the current viewer, not all viewers!
- RSEUIPlugin.getTheSystemRegistryUI().postEvent((ISystemResourceChangeListener)v, event); // only expand in the current viewer, not all viewers!
- }
- }
- }
- } catch (Exception exc) {
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED),
- ISystemMessageObject.MSGTYPE_ERROR, element);
- SystemBasePlugin.logError("Exception prompting for filter ",exc); //$NON-NLS-1$
- }
- //RSEUIPlugin.logDebugMessage(this.getClass().getName(),"returning children");
- return children;
- }
- ISubSystem ss = fRef.getSubSystem();
- Object[] nestedFilterReferences = fRef.getSystemFilterReferences(ss);
- int nbrFilterStrings = referencedFilter.getFilterStringCount();
- if (nbrFilterStrings == 0)
- return nestedFilterReferences;
- else
- {
-
- {
- String[] filterStrings = referencedFilter.getFilterStrings();
- try
- {
- if (nestedFilterReferences != null)
- {
- Object[] allChildren = ss.resolveFilterStrings(filterStrings, new NullProgressMonitor());
- int nbrNestedFilters = nestedFilterReferences.length;
- children = new Object[nbrNestedFilters + allChildren.length];
- int idx = 0;
- for (idx=0; idx<nbrNestedFilters; idx++)
- children[idx] = nestedFilterReferences[idx];
- for (int jdx=0; jdx<allChildren.length; jdx++)
- children[idx++] = allChildren[jdx];
- }
- }
- catch (InterruptedException exc)
- {
- children = new SystemMessageObject[1];
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED),
- ISystemMessageObject.MSGTYPE_CANCEL,element);
- SystemBasePlugin.logDebugMessage(this.getClass().getName(),"Filter resolving cancelled by user."); //$NON-NLS-1$
- }
- catch (Exception exc)
- {
- children = new SystemMessageObject[1];
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED),
- ISystemMessageObject.MSGTYPE_ERROR, element);
- SystemBasePlugin.logError("Exception resolving filters' strings ",exc); //$NON-NLS-1$
- } // message already issued
-
- return checkForEmptyList(children, element, true);
- }
- }
- }
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- * We return true if the referenced filter has nested filters or has filter strings.
- */
- public boolean hasSystemViewRoots()
- {
- int nbrNestedFilters = filter.getSystemFilterCount();
- int nbrFilterStrings = filter.getFilterStringCount();
- return (nbrNestedFilters > 0) || (nbrFilterStrings > 0);
- }
- /**
- * This method is called by the connection adapter when the user expands
- * a connection. This method must return the child objects to show for that
- * connection.
- * <p>Not applicable for us.
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- return null;
- }
- /**
- * This method is called by the connection adapter when deciding to show a plus-sign
- * or not beside a connection. Return true if this connection has children to be shown.
- * <p>Not applicable for us.
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- return false;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForSubSystems.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForSubSystems.java
deleted file mode 100644
index 8ad201567..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAPIProviderForSubSystems.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.view.SystemAbstractAPIProvider;
-
-
-/**
- * This class is a provider of root nodes to the remote systems tree viewer part.
- * It is used when the contents are the children of a particular subsystem.
- * Used when user right clicks on a subsystem and selects Open In New Perspective.
- */
-public class SystemViewAPIProviderForSubSystems
- extends SystemAbstractAPIProvider
-{
-
-
- protected ISubSystem subsystem = null;
-
- /**
- * Constructor
- * @param subsystem The subsystem object we are drilling down on.
- */
- public SystemViewAPIProviderForSubSystems(ISubSystem subsystem)
- {
- super();
- setSubSystem(subsystem);
- }
-
- /**
- * Get the input subsystem object.
- */
- public ISubSystem getSubSystem()
- {
- return subsystem;
- }
- /**
- * Reset the input subsystem object.
- */
- public void setSubSystem(ISubSystem subsystem)
- {
- this.subsystem = subsystem;
- }
-
- // ----------------------------------
- // SYSTEMVIEWINPUTPROVIDER METHODS...
- // ----------------------------------
- /**
- * Return the children objects to consistute the root elements in the system view tree.
- * We return all filter pools for this subsystem
- */
- public Object[] getSystemViewRoots()
- {
- return subsystem.getChildren();
- }
- /**
- * Return true if {@link #getSystemViewRoots()} will return a non-empty list
- * We return subsystem.hasChildren()
- */
- public boolean hasSystemViewRoots()
- {
- return subsystem.hasChildren();
- }
- /**
- * This method is called by the connection adapter when the user expands
- * a connection. This method must return the child objects to show for that
- * connection.
- * <p>Not applicable for us.
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- return null;
- }
- /**
- * This method is called by the connection adapter when deciding to show a plus-sign
- * or not beside a connection. Return true if this connection has children to be shown.
- * <p>Not applicable for us.
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAdapterFactory.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAdapterFactory.java
deleted file mode 100644
index fb180a3fe..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewAdapterFactory.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2006, 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.filters.ISystemFilterString;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemMessageObject;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
-import org.eclipse.rse.internal.ui.view.team.SystemTeamViewCategoryAdapter;
-import org.eclipse.rse.internal.ui.view.team.SystemTeamViewCategoryNode;
-import org.eclipse.rse.internal.ui.view.team.SystemTeamViewProfileAdapter;
-import org.eclipse.rse.internal.ui.view.team.SystemTeamViewPropertySetAdapter;
-import org.eclipse.rse.internal.ui.view.team.SystemTeamViewPropertySetNode;
-import org.eclipse.rse.internal.ui.view.team.SystemTeamViewSubSystemConfigurationAdapter;
-import org.eclipse.rse.internal.ui.view.team.SystemTeamViewSubSystemConfigurationNode;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.internal.model.SystemNewConnectionPromptObject;
-import org.eclipse.rse.ui.model.ISystemPromptableObject;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.ui.IActionFilter;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- * This factory maps requests for an adapter object from a given
- * element object.
- */
-public class SystemViewAdapterFactory implements IAdapterFactory {
-
- private SystemViewRootInputAdapter rootAdapter = new SystemViewRootInputAdapter();
- private SystemViewConnectionAdapter connectionAdapter = new SystemViewConnectionAdapter();
- private SystemViewSubSystemAdapter subsystemAdapter = new SystemViewSubSystemAdapter();
- private SystemViewFilterPoolAdapter filterPoolAdapter = new SystemViewFilterPoolAdapter();
- private SystemViewFilterAdapter filterAdapter = new SystemViewFilterAdapter();
- private SystemViewFilterPoolReferenceAdapter filterPoolReferenceAdapter = new SystemViewFilterPoolReferenceAdapter();
- private SystemViewFilterReferenceAdapter filterReferenceAdapter = new SystemViewFilterReferenceAdapter();
- private SystemViewMessageAdapter msgAdapter = new SystemViewMessageAdapter();
- private SystemViewPromptableAdapter promptAdapter = new SystemViewPromptableAdapter();
- private SystemViewNewConnectionPromptAdapter newConnPromptAdapter = new SystemViewNewConnectionPromptAdapter();
- private SystemTeamViewProfileAdapter profileAdapter = new SystemTeamViewProfileAdapter();
- private SystemTeamViewCategoryAdapter categoryAdapter = new SystemTeamViewCategoryAdapter();
- private SystemTeamViewSubSystemConfigurationAdapter subsysFactoryAdapter = new SystemTeamViewSubSystemConfigurationAdapter();
- private SystemTeamViewPropertySetAdapter propertySetAdapter = new SystemTeamViewPropertySetAdapter();
-
- private SystemViewFilterStringAdapter filterStringAdapter = new SystemViewFilterStringAdapter();
-
- /**
- * @see IAdapterFactory#getAdapterList()
- */
- public Class[] getAdapterList() {
- return new Class[] { ISystemViewElementAdapter.class, ISystemDragDropAdapter.class, IPropertySource.class, IWorkbenchAdapter.class,
- IActionFilter.class, IDeferredWorkbenchAdapter.class };
- }
-
- /**
- * Called by our plugin's startup method to register our adaptable object types
- * with the platform. We prefer to do it here to isolate/encapsulate all factory
- * logic in this one place.
- * @param manager the adapter manager controlling this factory
- */
- public void registerWithManager(IAdapterManager manager) {
- manager.registerAdapters(this, ISystemViewInputProvider.class);
- manager.registerAdapters(this, ISystemProfile.class);
- manager.registerAdapters(this, IHost.class);
- manager.registerAdapters(this, ISubSystem.class);
- manager.registerAdapters(this, ISystemFilter.class);
- manager.registerAdapters(this, ISystemFilterPool.class);
- manager.registerAdapters(this, ISystemFilterPoolReference.class);
- manager.registerAdapters(this, ISystemFilterReference.class);
- manager.registerAdapters(this, ISystemFilterString.class);
- manager.registerAdapters(this, ISystemMessageObject.class);
- manager.registerAdapters(this, ISystemPromptableObject.class);
- manager.registerAdapters(this, SystemTeamViewCategoryNode.class);
- manager.registerAdapters(this, SystemTeamViewSubSystemConfigurationNode.class);
- manager.registerAdapters(this, SystemTeamViewPropertySetNode.class);
-
- // FIXME - UDAs no longer in core
- //manager.registerAdapters(this, SystemTeamViewCompileTypeNode.class);
- //manager.registerAdapters(this, SystemTeamViewCompileCommandNode.class);
- //manager.registerAdapters(this, SystemUDActionElement.class);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- Object adapter = null;
- if (adaptableObject instanceof ISystemViewElementAdapter)
- adapter = adaptableObject;
- else if (adaptableObject instanceof ISystemDragDropAdapter)
- adapter = adaptableObject;
- else if (adaptableObject instanceof ISystemViewInputProvider)
- adapter = rootAdapter;
- else if (adaptableObject instanceof ISystemProfile)
- adapter = profileAdapter;
- else if (adaptableObject instanceof IHost)
- adapter = connectionAdapter;
- else if (adaptableObject instanceof ISubSystem)
- adapter = subsystemAdapter;
- else if (adaptableObject instanceof ISystemFilterPoolReference)
- adapter = filterPoolReferenceAdapter;
- else if (adaptableObject instanceof ISystemFilterPool)
- adapter = filterPoolAdapter;
- else if (adaptableObject instanceof ISystemFilterReference)
- adapter = filterReferenceAdapter;
- else if (adaptableObject instanceof ISystemFilterString)
- adapter = filterStringAdapter;
- else if (adaptableObject instanceof ISystemFilter)
- adapter = filterAdapter;
- else if (adaptableObject instanceof ISystemMessageObject)
- adapter = msgAdapter;
- else if (adaptableObject instanceof ISystemPromptableObject) {
-
- if (adaptableObject instanceof SystemNewConnectionPromptObject) {
- adapter = newConnPromptAdapter;
- } else {
- adapter = promptAdapter;
- }
- } else if (adaptableObject instanceof SystemTeamViewCategoryNode)
- adapter = categoryAdapter;
- else if (adaptableObject instanceof SystemTeamViewSubSystemConfigurationNode) adapter = subsysFactoryAdapter;
- else if (adaptableObject instanceof SystemTeamViewPropertySetNode) adapter = propertySetAdapter;
-
- /** FIXME - UDAs no longer in core
- else if (adaptableObject instanceof SystemTeamViewCompileTypeNode)
- adapter = getCompileTypeAdapter();
- else if (adaptableObject instanceof SystemTeamViewCompileCommandNode)
- adapter = getCompileCommandAdapter();
- else if (adaptableObject instanceof SystemUDActionElement)
- adapter = getUserActionAdapter();
- */
-
- if ((adapter != null) && (adapterType == IPropertySource.class)) {
- ((ISystemViewElementAdapter) adapter).setPropertySourceInput(adaptableObject);
- } else if (adapter == null) {
- SystemBasePlugin.logWarning("No adapter found for object of type: " + adaptableObject.getClass().getName()); //$NON-NLS-1$
- }
- return adapter;
- }
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewCompositeActionGroup.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewCompositeActionGroup.java
deleted file mode 100644
index aeb4d88b7..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewCompositeActionGroup.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-
-public class SystemViewCompositeActionGroup extends ActionGroup {
-
-
-
- private ActionGroup[] fGroups;
-
- public SystemViewCompositeActionGroup() {
- }
-
- public SystemViewCompositeActionGroup(ActionGroup[] groups) {
- setGroups(groups);
- }
-
- protected void setGroups(ActionGroup[] groups) {
- Assert.isTrue(fGroups == null);
- Assert.isNotNull(groups);
- fGroups= groups;
- }
-
- public ActionGroup get(int index) {
- if (fGroups == null)
- return null;
- return fGroups[index];
- }
-
- public void addGroup(ActionGroup group) {
- if (fGroups == null) {
- fGroups= new ActionGroup[] { group };
- } else {
- ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
- System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
- newGroups[fGroups.length]= group;
- fGroups= newGroups;
- }
- }
-
- public void dispose() {
- super.dispose();
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].dispose();
- }
- }
-
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].fillActionBars(actionBars);
- }
- }
-
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].fillContextMenu(menu);
- }
- }
-
- public void setContext(ActionContext context) {
- super.setContext(context);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].setContext(context);
- }
- }
-
- public void updateActionBars() {
- super.updateActionBars();
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].updateActionBars();
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java
deleted file mode 100644
index 9306395e4..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java
+++ /dev/null
@@ -1,734 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David Dykstal (IBM) - moved SystemPreferencesManager to a new package
- * - created and used RSEPreferencesManager
- * Uwe Stieber (Wind River) - Menu action contributions can be acknowlegded by system type provider
- * David Dykstal (IBM) - 180562: remove implementation of IRSEUserIdConstants
- * Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
- * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
- * Kevin Doyle (IBM) - [189005] Fixed getParent() to return SystemRegistryUI instead of SystemRegistry
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * David McKnight (IBM) - [191288] Up To Action doesn't go all the way back to the connections
- * Uwe Stieber (Wind River) - [199032] [api] Remove method acceptContextMenuActionContribution(...) from RSESystemTypeAdapter
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * Martin Oberhuber (Wind River) - [216266] Consider stateless subsystems (supportsSubSystemConnect==false)
- * David Dykstal (IBM) - [197036] minor refactoring caused by SystemRegistry fix for this bug
- * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
- * David Dykstal (IBM) - [216858] Need the ability to Import/Export RSE connections for sharing
- * David McKnight (IBM) - [226324] Default user ID from preferences not inherited
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.IRSEUserIdConstants;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.RSEPreferencesManager;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.subsystems.IConnectorService;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.actions.SystemClearAllPasswordsAction;
-import org.eclipse.rse.internal.ui.actions.SystemConnectAllSubSystemsAction;
-import org.eclipse.rse.internal.ui.actions.SystemCopyConnectionAction;
-import org.eclipse.rse.internal.ui.actions.SystemDisconnectAllSubSystemsAction;
-import org.eclipse.rse.internal.ui.actions.SystemExportConnectionAction;
-import org.eclipse.rse.internal.ui.actions.SystemImportConnectionAction;
-import org.eclipse.rse.internal.ui.actions.SystemMoveConnectionAction;
-import org.eclipse.rse.internal.ui.actions.SystemMoveDownConnectionAction;
-import org.eclipse.rse.internal.ui.actions.SystemMoveUpConnectionAction;
-import org.eclipse.rse.internal.ui.actions.SystemWorkOfflineAction;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSESystemTypeAdapter;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.actions.SystemNewConnectionAction;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.validators.ValidatorSpecialChar;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ISystemPropertyConstants;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-
-/**
- * Adapter for displaying SystemConnection objects in tree views.
- */
-public class SystemViewConnectionAdapter
- extends AbstractSystemViewAdapter
-{
- private SystemNewConnectionAction anotherConnectionAction = null;
- //private SystemUpdateConnectionAction updateAction = null;
- private SystemMoveUpConnectionAction upAction = null;
- private SystemMoveDownConnectionAction downAction = null;
- private SystemDisconnectAllSubSystemsAction disconnectAction = null;
- private SystemConnectAllSubSystemsAction connectAction = null;
- private SystemClearAllPasswordsAction clearPasswordAction = null;
- private SystemCopyConnectionAction copyAction = null;
- private SystemMoveConnectionAction moveAction = null;
- private SystemExportConnectionAction exportAction = null;
- private SystemImportConnectionAction importAction = null;
-
- // yantzi: artemis 6.0, add work offline support
- private SystemWorkOfflineAction offlineAction = null;
-
- private SystemInheritablePropertyData userIdData = new SystemInheritablePropertyData();
- private String translatedType = null;
- private String translatedHostname = null;
- private String translatedDescription = null;
- // for reset property support
- private String original_hostName, original_description;
- private SystemInheritablePropertyData original_userIdData = new SystemInheritablePropertyData();
- private boolean changed_hostName, changed_description, changed_userId;
- private boolean actionsCreated = false;
-
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
-
- /**
- * Returns the system type object for the specified host.
- *
- * @param host The host to get the system type object from.
- * @return The system type object or <code>null</code>.
- */
- private IRSESystemType getSystemTypeForHost(IHost host) {
- if (host != null) {
- return host.getSystemType();
- }
- return null;
- }
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given element.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup) {
- if (!actionsCreated) createActions();
-
- // bugzilla#161195: _ALL_ actions needs to be passed to the system type for approval.
- // _Never_ add any action without the system type provider having said ok to this.
- IHost host = (IHost)selection.getFirstElement();
- IRSESystemType sysType = getSystemTypeForHost(host);
- Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
- RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
-
- //updateAction.setValue(null); // reset
- menu.add(menuGroup, anotherConnectionAction);
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_NEW, new GroupMarker(ISystemContextMenuConstants.GROUP_NEW_NONCASCADING));// user or BP/ISV additions
-
- menu.add(menuGroup, copyAction);
- menu.add(menuGroup, moveAction);
- menu.add(menuGroup, upAction);
- menu.add(menuGroup, downAction);
- menu.add(menuGroup, exportAction);
- menu.add(menuGroup, importAction);
-
- // MJB: RE defect 40854
- addConnectOrDisconnectAction(menu, menuGroup, selection);
-
- // SystemClearAllPasswordsAction is added only if passwords are supported
- // by any of the sub systems.
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- IConnectorService[] connectorServices = registry.getConnectorServices(host);
- boolean passwordsSupported = false;
- for (int i = 0; i < connectorServices.length && passwordsSupported == false; i++) {
- passwordsSupported |= connectorServices[i].supportsPassword();
- }
- if (passwordsSupported) menu.add(menuGroup, clearPasswordAction);
-
- // yantzi: artemis 6.0, offline support, only add work offline action for system types that support offline mode
- if (sysTypeAdapter != null && sysTypeAdapter.isEnableOffline(host.getSystemType())) {
- menu.add(menuGroup, offlineAction);
- }
- }
-
- private void addConnectOrDisconnectAction(SystemMenuManager menu, String menuGroup, IStructuredSelection selection) {
- IHost host = (IHost)selection.getFirstElement();
-
- ISystemRegistry sysReg = RSECorePlugin.getTheSystemRegistry();
- boolean anySupportsConnect = sysReg.isAnySubSystemSupportsConnect(host);
-
- if (anySupportsConnect) {
- boolean anyConnected = sysReg.isAnySubSystemConnected(host);
- boolean allConnected = sysReg.areAllSubSystemsConnected(host);
-
- if (!allConnected) menu.add(menuGroup, connectAction);
- if (anyConnected) menu.add(menuGroup, disconnectAction);
- }
- }
-
- private void createActions()
- {
- anotherConnectionAction = new SystemNewConnectionAction(null,
- SystemResources.ACTION_ANOTHERCONN_LABEL,
- SystemResources.ACTION_ANOTHERCONN_TOOLTIP,
- false,
- true,
- null);
- anotherConnectionAction.setHelp(RSEUIPlugin.HELPPREFIX+"actn0015"); //$NON-NLS-1$
-
- //updateAction = new SystemUpdateConnectionAction(null);
- upAction = new SystemMoveUpConnectionAction(null);
- downAction = new SystemMoveDownConnectionAction(null);
- disconnectAction = new SystemDisconnectAllSubSystemsAction(null);
- copyAction = new SystemCopyConnectionAction(null);
- moveAction = new SystemMoveConnectionAction(null);
- offlineAction = new SystemWorkOfflineAction(null);
- connectAction = new SystemConnectAllSubSystemsAction(null);
- clearPasswordAction = new SystemClearAllPasswordsAction(null);
- exportAction = new SystemExportConnectionAction();
- importAction = new SystemImportConnectionAction();
- actionsCreated = true;
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element) {
- IHost connection = (IHost)element;
- boolean anyConnected = RSECorePlugin.getTheSystemRegistry().isAnySubSystemConnected(connection);
- ImageDescriptor descriptor = null;
- IRSESystemType systemType = getSystemTypeForHost(connection);
- if (systemType != null) {
- RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(systemType.getAdapter(RSESystemTypeAdapter.class));
- if (anyConnected) {
- descriptor = sysTypeAdapter.getLiveImageDescriptor(systemType);
- } else {
- descriptor = sysTypeAdapter.getImageDescriptor(systemType);
- }
- } else {
- descriptor = ImageDescriptor.getMissingImageDescriptor();
- }
- return descriptor;
- }
-
- /**
- * Return the label for this object
- */
- public String getText(Object element)
- {
- IHost conn = (IHost)element;
- boolean qualifyNames = RSEUIPlugin.getTheSystemRegistryUI().getQualifiedHostNames();
- if (!qualifyNames)
- return conn.getAliasName();
- else
- return conn.getSystemProfileName() + "." + conn.getAliasName(); //$NON-NLS-1$
- }
-
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- IHost conn = (IHost)element;
- return conn.getAliasName();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- IHost conn = (IHost)element;
- return conn.getSystemProfileName() + "." + conn.getAliasName(); //$NON-NLS-1$
- }
-
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- if (translatedType == null)
- translatedType = SystemViewResources.RESID_PROPERTY_CONNECTION_TYPE_VALUE;
- return translatedType;
- }
-
- /**
- * Return the string to display in the status line when the given object is selected.
- * We return:
- * Connection: name - Host name: hostName - Description: description
- */
- public String getStatusLineText(Object element)
- {
- IHost conn = (IHost)element;
- if (translatedHostname == null)
- translatedHostname = SystemViewResources.RESID_PROPERTY_HOSTNAME_LABEL;
- if (translatedDescription == null)
- translatedDescription = SystemViewResources.RESID_PROPERTY_CONNDESCRIPTION_LABEL;
- String statusText =
- getType(element) + ": " + conn.getAliasName() + " - " + //$NON-NLS-1$ //$NON-NLS-2$
- translatedHostname + ": " + conn.getHostName(); //$NON-NLS-1$
- String text = conn.getDescription();
- if ((text==null) || (text.length()==0))
- return statusText;
- else
- return statusText + " - " + translatedDescription + ": " + text; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Return the parent of this object
- */
- public Object getParent(Object element)
- {
- return RSECorePlugin.getTheSystemRegistry();
- }
-
- /**
- * Return the children of this object
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- IHost conn = (IHost)element;
- ISystemViewInputProvider input = getInput();
- if (input != null)
- {
- Object[] children = input.getConnectionChildren(conn);
- if (children != null)
- {
- Vector v = new Vector();
- boolean someSkipped = false;
- for (int idx=0; idx<children.length; idx++)
- {
- if ((children[idx] instanceof ISubSystem) &&
- ((ISubSystem)children[idx]).isHidden() )
- someSkipped = true;
- else
- v.addElement(children[idx]);
- }
- if (someSkipped)
- {
- children = new Object[v.size()];
- for (int idx=0; idx<children.length; idx++)
- children[idx] = v.elementAt(idx);
- }
- }
- return children;
- }
- else
- {
- System.out.println("SystemViewConnection.getChildren(): adapter has no input!"); //$NON-NLS-1$
- return null;
- }
- }
-
- /**
- * Return true if this object has children
- */
- public boolean hasChildren(IAdaptable element)
- {
- IHost conn = (IHost)element;
- return getInput().hasConnectionChildren(conn);
- }
-
- // Property sheet descriptors defining all the properties we expose in the Property Sheet
-
- /**
- * Return our unique property descriptors
- */
- protected IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- propertyDescriptorArray = new PropertyDescriptor[6];
- int idx = -1;
-
- // add our unique property descriptors...
- //idx = defaultProperties.length;
- //RSEUIPlugin plugin = RSEUIPlugin.getDefault();
-
- // profile
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PROFILE, SystemViewResources.RESID_PROPERTY_PROFILE_LABEL, SystemViewResources.RESID_PROPERTY_PROFILE_TOOLTIP);
-
- // system type
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_SYSTEMTYPE,SystemViewResources.RESID_PROPERTY_SYSTEMTYPE_LABEL, SystemViewResources.RESID_PROPERTY_SYSTEMTYPE_TOOLTIP);
-
- // status
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_CONNECTED,SystemViewResources.RESID_PROPERTY_CONNECTIONSTATUS_LABEL, SystemViewResources.RESID_PROPERTY_CONNECTIONSTATUS_TOOLTIP);
-
- // hostname
- if (translatedHostname == null)
- translatedHostname = SystemViewResources.RESID_PROPERTY_HOSTNAME_LABEL;
- propertyDescriptorArray[++idx] = new TextPropertyDescriptor(ISystemPropertyConstants.P_HOSTNAME, translatedHostname);
- propertyDescriptorArray[idx].setDescription(SystemViewResources.RESID_PROPERTY_HOSTNAME_TOOLTIP);
-
- // default user id
- //propertyDescriptorArray[++idx] = new TextPropertyDescriptor(ISystemPropertyConstants.P_DEFAULTUSERID,
- // SystemViewResources.RESID_PROPERTY_DEFAULTUSERID_LABEL));
- SystemInheritableTextPropertyDescriptor userIdDescriptor =
- new SystemInheritableTextPropertyDescriptor(ISystemPropertyConstants.P_DEFAULTUSERID,
- SystemViewResources.RESID_PROPERTY_DEFAULTUSERID_LABEL);
- //RSEUIPlugin sp = RSEUIPlugin.getDefault();
- userIdDescriptor.setToggleButtonToolTipText(SystemResources.RESID_CONNECTION_DEFAULTUSERID_INHERITBUTTON_TIP);
- userIdDescriptor.setEntryFieldToolTipText(SystemResources.RESID_CONNECTION_DEFAULTUSERID_TIP);
- ICellEditorValidator userIdValidator =
- new ValidatorSpecialChar("=;",false, //$NON-NLS-1$
- RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_USERID_NOTVALID),
- RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_USERID_EMPTY)); // false => allow empty? No.
- userIdDescriptor.setValidator(userIdValidator);
- propertyDescriptorArray[++idx] = userIdDescriptor;
- propertyDescriptorArray[idx].setDescription(SystemViewResources.RESID_PROPERTY_DEFAULTUSERID_TOOLTIP);
-
- // description
- if (translatedDescription == null)
- translatedDescription = SystemViewResources.RESID_PROPERTY_CONNDESCRIPTION_LABEL;
- propertyDescriptorArray[++idx] = new TextPropertyDescriptor(ISystemPropertyConstants.P_DESCRIPTION, translatedDescription);
- propertyDescriptorArray[idx].setDescription(SystemViewResources.RESID_PROPERTY_CONNDESCRIPTION_TOOLTIP);
-
- }
- return propertyDescriptorArray;
- }
-
- /**
- * Returns the current value for the named property.
- * The parent handles P_TEXT and P_TYPE only, and we augment that here.
- * @param key the name of the property as named by its property descriptor
- * @return the current value of the property
- */
- protected Object internalGetPropertyValue(Object key)
- {
- String name = (String)key;
- IHost conn = (IHost)propertySourceInput;
-
- if (name.equals(ISystemPropertyConstants.P_SYSTEMTYPE))
- return conn.getSystemType().getLabel();
- else if (name.equals(ISystemPropertyConstants.P_HOSTNAME))
- return conn.getHostName();
- else if (name.equals(ISystemPropertyConstants.P_DEFAULTUSERID))
- {
- setDefaultUserIdPropertyData(userIdData, conn);
- //System.out.println("Testing getPropertyValue: " + userIdData);
- return userIdData;
- }
- else if (name.equals(ISystemPropertyConstants.P_DESCRIPTION))
- return conn.getDescription();
- else if (name.equals(ISystemPropertyConstants.P_PROFILE))
- return conn.getSystemProfile().getName();
- else if (name.equals(ISystemPropertyConstants.P_IS_CONNECTED))
- {
- if (conn.isOffline())
- {
- return SystemResources.RESID_OFFLINE_LABEL;
- }
- else
- {
- boolean anyConnected = RSECorePlugin.getTheSystemRegistry().isAnySubSystemConnected(conn);
- if (anyConnected)
- return SystemViewResources.RESID_PROPERTY_CONNECTIONSTATUS_CONNECTED_VALUE;
- else
- return SystemViewResources.RESID_PROPERTY_CONNECTIONSTATUS_DISCONNECTED_VALUE;
- }
- }
- else
- return null;
- }
-
- /**
- * Set the values in the userIdPropertyData object that drives the userId property sheet widget
- */
- private SystemInheritablePropertyData setDefaultUserIdPropertyData(SystemInheritablePropertyData data, IHost conn)
- {
- String localUserId = conn.getLocalDefaultUserId();
- data.setLocalValue(localUserId);
- String parentUserId = RSEPreferencesManager.getDefaultUserId(conn.getSystemType());
- data.setInheritedValue(parentUserId);
- data.setIsLocal((localUserId!=null)&&(localUserId.length()>0));
- //data.printDetails();
- return data;
- }
-
- // because this node has some editable properties, these overrides of our
- // parent class are needed as callbacks from the PropertySheet window.
- /**
- * Set input object for property source queries. This is called by the
- * SystemViewAdaptorFactory before returning this adapter object.
- */
- public void setPropertySourceInput(Object propertySourceInput)
- {
- if (this.propertySourceInput == propertySourceInput) // no change?
- return; // don't mistakenly update history values else reset from property sheet doesn't work correctly.
- super.setPropertySourceInput(propertySourceInput);
- IHost conn = (IHost)propertySourceInput;
- original_userIdData = setDefaultUserIdPropertyData(original_userIdData,conn);
- original_hostName = conn.getHostName();
- original_description = conn.getDescription();
- changed_userId = changed_hostName = changed_description = false;
- //System.out.println("Inside setPropertySourceInput in adapter");
- }
- /**
- * Returns whether the property value has changed from the default.
- * Only applicable for editable properties.
- * Called by PropertySheet viewer when user presses reset.
- * @return <code>true</code> if the value of the specified property has changed
- * from its original default value; <code>false</code> otherwise.
- */
- public boolean isPropertySet(Object propertyObject)
- {
- String property = (String)propertyObject;
- boolean changed = false;
- if (property.equals(ISystemPropertyConstants.P_DEFAULTUSERID))
- changed = changed_userId;
- else if (property.equals(ISystemPropertyConstants.P_HOSTNAME))
- changed = changed_hostName;
- else if (property.equals(ISystemPropertyConstants.P_DESCRIPTION))
- changed = changed_description;
- return changed;
- }
-
- /**
- * Called when user selects the reset button in property sheet.
- */
- public void resetPropertyValue(Object propertyObject)
- {
- //System.out.println("Inside resetPropertyValue in adapter");
- String property = (String)propertyObject;
- IHost conn = (IHost)propertySourceInput;
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
-
- if (property.equals(ISystemPropertyConstants.P_DEFAULTUSERID))
- {
- //sr.updateConnection(null, conn, conn.getSystemType().getName(), conn.getAliasName(),
- // conn.getHostName(), conn.getDescription(), original_userId, USERID_LOCATION_CONNECTION);
- updateDefaultUserId(conn, original_userIdData);
- }
- else if (property.equals(ISystemPropertyConstants.P_HOSTNAME))
- {
- sr.updateHost(conn, conn.getSystemType(), conn.getAliasName(), original_hostName,
- conn.getDescription(), conn.getDefaultUserId(), IRSEUserIdConstants.USERID_LOCATION_NOTSET);
- }
- else if (property.equals(ISystemPropertyConstants.P_DESCRIPTION))
- {
- sr.updateHost(conn, conn.getSystemType(), conn.getAliasName(), conn.getHostName(),
- original_description, conn.getDefaultUserId(), IRSEUserIdConstants.USERID_LOCATION_NOTSET);
- }
- }
- /**
- * Change the default user Id value
- */
- private void updateDefaultUserId(IHost conn, SystemInheritablePropertyData data)
- {
- int whereToUpdate = IRSEUserIdConstants.USERID_LOCATION_HOST;
- //if (!data.getIsLocal())
- //whereToUpdate = USERID_LOCATION_DEFAULT_SYSTEMTYPE;
- String userId = data.getLocalValue(); // will be "" if !data.getIsLocal(), which results in wiping out local override
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.updateHost(conn, conn.getSystemType(), conn.getAliasName(), conn.getHostName(),
- conn.getDescription(), userId, whereToUpdate);
- }
-
- /**
- * Called when user changes property via property sheet.
- */
- public void setPropertyValue(Object property, Object value)
- {
- String name = (String)property;
- IHost conn = (IHost)propertySourceInput;
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
-
- if (name.equals(ISystemPropertyConstants.P_DEFAULTUSERID))
- {
- //System.out.println("Testing setPropertyValue: " + value);
- //sr.updateConnection(null, conn, conn.getSystemType().getName(), conn.getAliasName(),
- // conn.getHostName(), conn.getDescription(), (String)value, USERID_LOCATION_CONNECTION);
- updateDefaultUserId(conn, (SystemInheritablePropertyData)value);
- changed_userId = true;
- }
- else if (name.equals(ISystemPropertyConstants.P_HOSTNAME))
- {
- // DKM - don't update unless it really changed
- // defect 57739
- if (!((String)value).equalsIgnoreCase(conn.getHostName()))
- {
- sr.updateHost(conn, conn.getSystemType(), conn.getAliasName(), (String)value,
- conn.getDescription(), conn.getDefaultUserId(), IRSEUserIdConstants.USERID_LOCATION_NOTSET);
- changed_hostName = true;
- }
- }
- else if (name.equals(ISystemPropertyConstants.P_DESCRIPTION))
- {
- // DKM - don't update unless it really changed
- // defect 57739
- if (!((String)value).equalsIgnoreCase(conn.getDescription()))
- {
- sr.updateHost(conn, conn.getSystemType(), conn.getAliasName(), conn.getHostName(),
- (String)value, conn.getDefaultUserId(), IRSEUserIdConstants.USERID_LOCATION_NOTSET);
- changed_description = true;
- }
- }
- }
-
- // FOR COMMON DELETE ACTIONS
- /**
- * Return true if this object is deletable by the user. If so, when selected,
- * the Edit->Delete menu item will be enabled.
- */
- public boolean canDelete(Object element)
- {
- if (element instanceof IHost)
- {
- IHost host = (IHost)element;
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- //do not allow delete if any subsystem is connected but supports disconnect.
- //specifically, this allows deletion of "Local" which is always connected (but does not support disconnect)
- //need to get subsystems from registry instead of host in order to be lazy:
- //subsystems which are not yet instantiated do not need to be considered.
- ISubSystem[] ss = sr.getSubSystems(host);
- for (int i=0; i<ss.length; i++) {
- if (ss[i].isConnected() && ss[i].getSubSystemConfiguration().supportsSubSystemConnect())
- return false;
- }
- }
- return true;
- }
-
-
-
- /**
- * Perform the delete action.
- */
- public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor)
- {
- boolean ok = true;
- IHost conn = (IHost)element;
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.deleteHost(conn);
- return ok;
- }
-
- // FOR COMMON RENAME ACTIONS
- /**
- * Return true if this object is renamable by the user. If so, when selected,
- * the Rename popup menu item will be enabled.
- */
- public boolean canRename(Object element)
- {
- return true; // all connections are renamable
- }
- /**
- * Perform the rename action.
- */
- public boolean doRename(Shell shell, Object element, String name, IProgressMonitor monitor) throws Exception
- {
- boolean ok = true;
- IHost conn = (IHost)element;
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.renameHost(conn,name); // renames and saves to disk
- return ok;
- }
- /**
- * Return a validator for verifying the new name is correct.
- */
- public ISystemValidator getNameValidator(Object element)
- {
- IHost conn = (IHost)element;
- //return org.eclipse.rse.core.ui.SystemConnectionForm.getConnectionNameValidator(conn); defect 42117
- return org.eclipse.rse.ui.SystemConnectionForm.getConnectionNameValidator(conn.getSystemProfile());
- }
- /**
- * Parent override.
- * <p>
- * Form and return a new canonical (unique) name for this object, given a candidate for the new
- * name. This is called by the generic multi-rename dialog to test that all new names are unique.
- * To do this right, sometimes more than the raw name itself is required to do uniqueness checking.
- * <p>
- * Returns profile.connectionName, upperCased
- */
- public String getCanonicalNewName(Object element, String newName)
- {
- IHost conn = (IHost)element;
- return (conn.getSystemProfileName() + "." + newName).toUpperCase(); //$NON-NLS-1$
- }
-
-
- // FOR COMMON DRAG AND DROP ACTIONS
- /**
- * Indicates whether the connection can be dragged.
- * Can't be used for physical copies but rather
- * for views (like the Scratchpad)
- */
- public boolean canDrag(Object element)
- {
- return true;
- }
-
- /**
- * Returns the connection (no phyiscal operation required to drag and subsystem (because it's local)
- */
- public Object doDrag(Object element, boolean sameSystemType, IProgressMonitor monitor)
- {
- return element;
- }
-
-
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- * This just defaults to getName, but if that is not sufficient override it here.
- */
- public String getMementoHandle(Object element)
- {
- IHost conn = (IHost)element;
- return conn.getSystemProfileName() + "." + conn.getAliasName(); //$NON-NLS-1$
- }
- /**
- * Return a short string to uniquely identify the type of resource. Eg "conn" for connection.
- * This just defaults to getType, but if that is not sufficient override it here, since that is
- * a translated string.
- */
- public String getMementoHandleKey(Object element)
- {
- return ISystemMementoConstants.MEMENTO_KEY_CONNECTION;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDataDragAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDataDragAdapter.java
deleted file mode 100644
index ad5640582..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDataDragAdapter.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * David Dykstal (IBM) - [142065] fix drag and drop on Mac OS X
- * Kevin Doyle (IBM) - [187536] Drag & Drop file to Editor launchs file in system editor
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.actions.LazyDownloadJob;
-import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceAdapter;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.part.EditorInputTransfer;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.part.PluginTransfer;
-import org.eclipse.ui.part.PluginTransferData;
-
-
-/**
- * Drag adapter for dragging objects in the Systems views
- *
- */
-public class SystemViewDataDragAdapter extends DragSourceAdapter
-{
-
-
- ISelectionProvider _selectionProvider;
- private ISelection _selection = null; // set this on dragStart, set to null on dragFinished
- public static final char CONNECTION_DELIMITER = ':';
- public static final char RESOURCE_SEPARATOR = '|';
-
- /**
- * Constructor for drag adapter
- *
- */
- public SystemViewDataDragAdapter(ISelectionProvider provider)
- {
- _selectionProvider = provider;
- }
-
- public void dragFinished(DragSourceEvent event)
- {
- _selection = null; // drag has finished, forget the selection
- if (event.doit == false)
- {
- return;
- }
- }
-
-
- private void serializeObject(Object dragObject, ISystemDragDropAdapter adapter, StringBuffer dataStream)
- {
- // get the subsystem id
- ISubSystem subSystem = null;
- if (dragObject instanceof ISubSystem)
- {
- subSystem = (ISubSystem)dragObject;
- String subSystemId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForSubSystem(subSystem);
- dataStream.append(subSystemId);
- }
- else if (dragObject instanceof IHost)
- {
- IHost connection = (IHost)dragObject;
- String connectionId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForConnection(connection);
- dataStream.append(connectionId);
- }
- else
- {
- subSystem = adapter.getSubSystem(dragObject);
-
- if (subSystem != null)
- {
- String subSystemId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForSubSystem(subSystem);
- dataStream.append(subSystemId);
-
- }
-
- String objectId = adapter.getAbsoluteName(dragObject);
- dataStream.append(":"); //$NON-NLS-1$
- dataStream.append(objectId);
- }
- }
-
- public void dragStart(DragSourceEvent event)
- {
- /*
- * Remember the selection at drag start. This is the only point at which the selection is valid
- * during the drag operations on all platforms.
- */
- _selection = _selectionProvider.getSelection();
- if (_selection instanceof IStructuredSelection)
- {
- IStructuredSelection ss = (IStructuredSelection) _selection;
- Iterator iterator = ss.iterator();
- while (iterator.hasNext())
- {
- Object dragObject = iterator.next();
-
- if (dragObject instanceof IAdaptable)
- {
- ISystemDragDropAdapter adapter = (ISystemDragDropAdapter) ((IAdaptable) dragObject).getAdapter(ISystemDragDropAdapter.class);
- if (adapter == null || !adapter.canDrag(dragObject))
- {
- event.doit = false;
- event.detail = DND.DROP_NONE;
- }
- else
- {
- if (EditorInputTransfer.getInstance().isSupportedType(event.dataType))
- {
- if (adapter instanceof ISystemRemoteElementAdapter)
- {
- if (((ISystemRemoteElementAdapter)adapter).canEdit(dragObject))
- {
- event.doit = true;
- }
- else
- {
- event.doit = false;
- event.detail = DND.DROP_NONE;
- return;
- }
- }
- }
- else
- {
- event.doit = true;
- event.detail = DND.DROP_COPY;
- ////FIXME as per bug [142947], drag under feedback now works differently in SWT
- //event.feedback = DND.FEEDBACK_INSERT_AFTER;
- }
- }
- }
- else
- {
- event.doit = false;
- event.detail = DND.DROP_NONE;
- return;
- }
- }
- }
-
- //event.doit = true;
- }
-
-
- /**
- * Method for determining the source (drag) object(s) and
- * encoding those objects in a byte[]. We encode the profile,
- * connection and subsystem, and then we use ISystemDragDropAdapter.getAbsoluteName()
- * to determine the ID for the object within it's subsystem.
- */
- public void dragSetData(DragSourceEvent event)
- {
-
- /*
- * We cannot request the selection from the selection provider at this point since
- * on some platforms (particularly Mac OS X) the selection is forgotten by the underlying
- * OS control immediately after the drag is started. This call is invoked at the end
- * of the drag operation but just before the corresponding drop call in the drop adapter.
- * Thus, we must remember the selection at drag start.
- */
- if (_selection instanceof IStructuredSelection)
- {
- IStructuredSelection ss = (IStructuredSelection) _selection;
-
- if (PluginTransfer.getInstance().isSupportedType(event.dataType))
- {
- StringBuffer dataStream = new StringBuffer(""); //$NON-NLS-1$
- Iterator iterator = ss.iterator();
- while (iterator.hasNext())
- {
- Object dragObject = iterator.next();
-
- if (dragObject instanceof IAdaptable)
- {
- ISystemDragDropAdapter adapter = (ISystemDragDropAdapter) ((IAdaptable) dragObject).getAdapter(ISystemDragDropAdapter.class);
- if (adapter != null)
- {
- if (adapter.canDrag(dragObject))
- {
- serializeObject(dragObject, adapter, dataStream);
-
- if (iterator.hasNext())
- {
- dataStream.append(RESOURCE_SEPARATOR);
- }
- }
- }
- }
- }
-
- PluginTransferData data = new PluginTransferData("org.eclipse.rse.ui.view.DropActions", dataStream.toString().getBytes()); //$NON-NLS-1$
- event.data = data;
- if (dataStream.length() > 0)
- {
- event.doit = true;
- event.detail = DND.DROP_COPY;
-
- }
- else
- {
- event.doit = false;
- event.detail = DND.ERROR_CANNOT_INIT_DRAG;
- }
- }
- else if (FileTransfer.getInstance().isSupportedType(event.dataType))
- {
- // external drag and drop
- String[] fileNames = new String[ss.size()];
- Iterator iterator = ss.iterator();
- int i = 0;
- while (iterator.hasNext())
- {
- Object dragObject = iterator.next();
- if (dragObject instanceof IAdaptable)
- {
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) dragObject).getAdapter(ISystemViewElementAdapter.class);
- if (adapter.canDrag(dragObject))
- {
- IResource resource = getResource((IAdaptable)dragObject);
- if (resource != null)
- {
- String fileName = resource.getLocation().toOSString();
- fileNames[i] = fileName;
- i++;
- }
- }
- }
- }
- if (i > 0)
- {
- event.data = fileNames;
- }
- }
- else if (TextTransfer.getInstance().isSupportedType(event.dataType))
- {
- String[] texts = new String[ss.size()];
- Iterator iterator = ss.iterator();
- int i = 0;
- while (iterator.hasNext())
- {
- Object dragObject = iterator.next();
- if (dragObject instanceof IAdaptable)
- {
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) dragObject).getAdapter(ISystemViewElementAdapter.class);
- if (adapter != null)
- {
- texts[i] = adapter.getText(dragObject);
- i++;
- }
- }
- }
- if (i > 0)
- {
- event.data = texts;
- }
- }
- else if (EditorInputTransfer.getInstance().isSupportedType(event.dataType))
- {
- EditorInputTransfer.EditorInputData[] inputData = new EditorInputTransfer.EditorInputData[ss.size()];
- Iterator iterator = ss.iterator();
- int i = 0;
-
- IEditorRegistry editRegistry = RSEUIPlugin.getDefault().getWorkbench().getEditorRegistry();
-
- while (iterator.hasNext())
- {
- Object dragObject = iterator.next();
-
- Object adapterObj = ((IAdaptable)dragObject).getAdapter(ISystemRemoteElementAdapter.class);
- if (adapterObj != null)
- {
- ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter)adapterObj;
- if (adapter.canEdit(dragObject))
- {
- ISystemEditableRemoteObject editable = adapter.getEditableRemoteObject(dragObject);
- if (editable != null)
- {
- try
- {
-
- Shell shell = event.display.getActiveShell();
- if (editable.download(shell))
- {
- editable.addAsListener();
- editable.setLocalResourceProperties();
-
- IFile theFile = editable.getLocalResource();
-
- IEditorDescriptor preferredEditor = editRegistry.getDefaultEditor(theFile.getName()); // may be null
- if (preferredEditor == null || preferredEditor.isOpenExternal())
- {
- preferredEditor = getDefaultTextEditor();
-
- }
-
- FileEditorInput fileInput = new FileEditorInput(theFile);
- inputData[i] = EditorInputTransfer.createEditorInputData(preferredEditor.getId(), fileInput);
- i++;
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- }
- }
- if (i > 0)
- {
- event.data = inputData;
- }
- else
- {
- event.data = new EditorInputTransfer.EditorInputData[0];
- event.detail = DND.DROP_NONE;
- }
- }
- }
- }
-
- protected IEditorRegistry getEditorRegistry()
- {
- return RSEUIPlugin.getDefault().getWorkbench().getEditorRegistry();
- }
-
- protected IEditorDescriptor getDefaultTextEditor()
- {
- IEditorRegistry registry = getEditorRegistry();
- return registry.findEditor("org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$
- }
-
- private IResource getResource(IAdaptable dragObject)
- {
- IResource resource = null;
- ISystemViewElementAdapter viewAdapter = (ISystemViewElementAdapter) dragObject.getAdapter(ISystemViewElementAdapter.class);
- ISystemRemoteElementAdapter remoteAdapter = (ISystemRemoteElementAdapter)dragObject.getAdapter(ISystemRemoteElementAdapter.class);
-
- if (remoteAdapter != null)
- {
-
- if (remoteAdapter.canEdit(dragObject))
- {
- ISystemEditableRemoteObject editable = remoteAdapter.getEditableRemoteObject(dragObject);
- // corresponds to a file
- IFile file = editable.getLocalResource();
- if (!file.exists())
- {
- // this is a drag and drop to windows explorer
- // because we're dealing with file paths we need to force this to complete before allowing the drop
- // so instead of doing the job, I'm forcing the transfer on this thread
- LazyDownloadJob job = new LazyDownloadJob(editable);
- job.run(new NullProgressMonitor());
- //job.setPriority(Job.INTERACTIVE);
- //job.schedule();
- }
- resource = file;
- }
- else if (viewAdapter != null)
- {
- if (viewAdapter.hasChildren(dragObject))
- {
- IContainer parentFolder = null;
- // corresponds to a folder
- Object[] children = viewAdapter.getChildren(dragObject, new NullProgressMonitor());
- for (int i = 0; i < children.length; i++)
- {
- IAdaptable child = (IAdaptable)children[i];
- IResource childResource = getResource(child);
- if (childResource != null)
- {
- parentFolder = childResource.getParent();
- if (!parentFolder.exists())
- {
- try
- {
- parentFolder.touch(new NullProgressMonitor());
- }
- catch (Exception e)
- {
-
- }
-
- }
- }
- }
-
-
- resource = parentFolder;
- }
- }
- }
- return resource;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDataDropAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDataDropAdapter.java
deleted file mode 100644
index 3ae32d948..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDataDropAdapter.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * David McKnight (IBM) - [192704] work around drag&drop issues from Project Explorer
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- * David McKnight (IBM) - [234924] [ftp][dnd][Refresh] Copy/Paste file from Package Explorer doesn't refresh folder
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.MultiRule;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.internal.model.SystemScratchpad;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.part.EditorInputTransfer;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.part.PluginTransferData;
-
-
-/**
- * Drop adapter for dropping objects in the Systems views.
- *
- */
-public class SystemViewDataDropAdapter
-//extends PluginDropAdapter
-extends ViewerDropAdapter
-{
- protected Shell shell;
- protected long hoverStart = 0;
-
- protected static final long hoverThreshold = 1500;
- public static final char CONNECTION_DELIMITER = ':';
- public static final String RESOURCE_SEPARATOR = "|"; //$NON-NLS-1$
-
- protected int _sourceType = SystemDNDTransferRunnable.SRC_TYPE_RSE_RESOURCE;
- /**
- * Constructor for the drop adapter
- *
- */
- public SystemViewDataDropAdapter(StructuredViewer viewer)
- {
- super(viewer);
- setFeedbackEnabled(true);
- }
-
- /**
- * Method for determining whether the drop target is a valid target.
- * We could do extra validation on the source (drag) object(s), although
- * that could get expensive. The SWT drag and drop framework calls this
- * method.
- *
- */
- public boolean validateDrop(Object target, int operation, TransferData transferType)
- {
- if (target == null)
- {
- target = this.getViewer().getInput();
- }
- if (target instanceof IAdaptable)
- {
- ISystemDragDropAdapter adapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
- if (adapter != null)
- {
- return adapter.canDrop(target);
- }
- }
-
- return false;
- }
-
-
- // DKM - hack to see if project explorer resources can be dropped in RSE
- private boolean isLocalSelectionResources(PluginTransferData transferData)
- {
- byte[] result = transferData.getData();
-
- // get the sources
- String[] tokens = (new String(result)).split("\\"+SystemViewDataDropAdapter.RESOURCE_SEPARATOR); //$NON-NLS-1$
-
- ArrayList srcObjects = new ArrayList();
- for (int i = 0;i < tokens.length; i++)
- {
- String srcStr = tokens[i];
- if (srcStr.equals("org.eclipse.ui.navigator.ProjectExplorer")) //$NON-NLS-1$
- {
- return true;
- }
- }
- return false;
- }
-
- private ArrayList getRSESourceObjects(PluginTransferData transferData)
- {
- byte[] result = transferData.getData();
-
- // get the sources
- //StringTokenizer tokenizer = new StringTokenizer(new String(result), RESOURCE_SEPARATOR);
- String[] tokens = (new String(result)).split("\\"+SystemViewDataDropAdapter.RESOURCE_SEPARATOR); //$NON-NLS-1$
-
-
- ArrayList srcObjects = new ArrayList();
- for (int i = 0;i < tokens.length; i++)
- {
- String srcStr = tokens[i];
-
- {
- Object srcObject = getObjectFor(srcStr);
- srcObjects.add(srcObject);
- }
- }
- return srcObjects;
- }
-
- private ArrayList getSourceObjects(Object data)
- {
- ArrayList srcObjects = new ArrayList();
-
- if (srcObjects.isEmpty())
- {
- if (data instanceof PluginTransferData)
- {
- PluginTransferData transferData = (PluginTransferData) data;
- if (isLocalSelectionResources(transferData))
- {
- IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
- Iterator selIt = selection.iterator();
- while (selIt.hasNext())
- {
- srcObjects.add(selIt.next());
- }
- _sourceType = SystemDNDTransferRunnable.SRC_TYPE_ECLIPSE_RESOURCE;
- }
- else
- {
- srcObjects = getRSESourceObjects(transferData);
- _sourceType = SystemDNDTransferRunnable.SRC_TYPE_RSE_RESOURCE;
- }
- }
- // different kind of data
- else if (data instanceof IResource[])
- {
- IResource[] resources = (IResource[]) data;
- for (int i = 0; i < resources.length; i++)
- {
- srcObjects.add(resources[i]);
- }
- _sourceType = SystemDNDTransferRunnable.SRC_TYPE_ECLIPSE_RESOURCE;
- }
- else if (data instanceof EditorInputTransfer.EditorInputData[])
- {
- EditorInputTransfer.EditorInputData[] editorInput = (EditorInputTransfer.EditorInputData[])data;
- for (int i = 0; i < editorInput.length; i++)
- {
- IPersistableElement inData = editorInput[i].input.getPersistable();
- if (inData instanceof FileEditorInput){
- IFile file = ((FileEditorInput)inData).getFile();
- srcObjects.add(file);
- }
- }
- _sourceType = SystemDNDTransferRunnable.SRC_TYPE_ECLIPSE_RESOURCE;
- }
- else if (data instanceof String[])
- {
- String[] resources = (String[]) data;
- for (int i = 0; i < resources.length; i++)
- {
- String resource = resources[i];
- srcObjects.add(resource);
- }
- _sourceType = SystemDNDTransferRunnable.SRC_TYPE_OS_RESOURCE;
- }
- }
-
- return srcObjects;
- }
-
-
- /**
- * Called by SWT after the drop have been validated to perform the
- * drop transfer.
- *
- */
- public boolean performDrop(Object data)
- {
- boolean ok = true;
-
- ArrayList srcObjects = getSourceObjects(data);
-
- if (srcObjects.size() > 0)
- {
- Object target = getCurrentTarget();
- if (target == null)
- {
- target = getViewer().getInput();
- }
-
- List rulesList = new ArrayList();
- int j = 0;
- for (int i = 0; i < srcObjects.size(); i++)
- {
- if (srcObjects.get(i) instanceof ISchedulingRule)
- {
- rulesList.add(srcObjects.get(i));
- j++;
- }
- /** FIXME - can't be coupled with IRemoteFile
- else if (srcObjects.get(i) instanceof IRemoteFile)
- {
- rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)srcObjects.get(i)));
- j++;
- }
- */
- }
- /*
- if (target instanceof ISchedulingRule)
- {
- rulesList.add(target);
- j++;
- }
- */
- /** FIXME - can't be coupled with IRemoteFile
- else if (target instanceof IRemoteFile)
- {
- rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)target));
- }
-
- else if (target instanceof IAdaptable)
- {
- ISystemDragDropAdapter targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
-
- if (targetAdapter != null)
- {
- ISubSystem targetSubSystem = targetAdapter.getSubSystem(target);
- rulesList.add(targetSubSystem);
- j++;
- }
- }
- */
- MultiRule rule = null;
- ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
-
- if (j > 0) rule = new MultiRule(rules);
-
- SystemDNDTransferRunnable runnable = new SystemDNDTransferRunnable(target, srcObjects, getViewer(), _sourceType);
- // DKM - rules are causing problems at the moment
- runnable.setRule(rule);
-
- if (target instanceof SystemScratchpad)
- {
- runnable.run(new NullProgressMonitor());
- }
- else
- {
- runnable.schedule();
- }
- //ok = runnable.dropOkay();
- ok = true;
- }
- return ok;
- }
-
-
- /**
- * Method for decoding an source object ID to the actual source object.
- * We determine the profile, connection and subsystem, and then
- * we use the SubSystem.getObjectWithKey() method to get at the
- * object.
- *
- */
- private Object getObjectFor(String str)
- {
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- // first extract subsystem id
- int connectionDelim = str.indexOf(":"); //$NON-NLS-1$
- if (connectionDelim == -1) // not subsystem, therefore likely to be a connection
- {
- int profileDelim = str.indexOf("."); //$NON-NLS-1$
- if (profileDelim != -1)
- {
- String profileId = str.substring(0, profileDelim);
- String connectionId = str.substring(profileDelim + 1, str.length());
- ISystemProfile profile = registry.getSystemProfile(profileId);
- return registry.getHost(profile, connectionId);
- }
- }
-
-
- int subsystemDelim = str.indexOf(":", connectionDelim + 1); //$NON-NLS-1$
- if (subsystemDelim == -1) // not remote object, therefore likely to be a subsystem
- {
- return registry.getSubSystem(str);
- }
- else
- {
- String subSystemId = str.substring(0, subsystemDelim);
- String srcKey = str.substring(subsystemDelim + 1, str.length());
-
-
- ISubSystem subSystem = registry.getSubSystem(subSystemId);
- if (subSystem != null)
- {
- Object result = null;
- try
- {
- result = subSystem.getObjectWithAbsoluteName(srcKey);
- }
- catch (SystemMessageException e)
- {
- return e.getSystemMessage();
- }
- catch (Exception e)
- {
- }
- if (result != null)
- {
- return result;
- }
- else
- {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_FILE_NOTFOUND);
- msg.makeSubstitution(srcKey, subSystem.getHostAliasName());
- return msg;
- }
- }
- else
- {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_CONNECTION_NOTFOUND);
- msg.makeSubstitution(subSystemId);
- return msg;
- }
- }
- }
-
- protected IRunnableContext getRunnableContext(Shell shell)
- {
- IRunnableContext irc = RSEUIPlugin.getTheSystemRegistryUI().getRunnableContext();
- if (irc != null)
- {
- return irc;
- }
- else
- {
- /*
- // for other cases, use statusbar
- IWorkbenchWindow win = RSEUIPlugin.getActiveWorkbenchWindow();
- if (win != null)
- {
- Shell winShell = RSEUIPlugin.getActiveWorkbenchShell();
- if (winShell != null && !winShell.isDisposed() && winShell.isVisible())
- {
- RSEUIPlugin.logInfo("Using active workbench window as runnable context");
- shell = winShell;
- return win;
- }
- else
- {
- win = null;
- }
- }
- */
-
- irc = new ProgressMonitorDialog(shell);
- RSEUIPlugin.getTheSystemRegistryUI().setRunnableContext(shell, irc);
- return irc;
- }
- }
-
- public void dragOver(DropTargetEvent event)
- {
- super.dragOver(event);
- event.feedback &= ~DND.FEEDBACK_EXPAND;
- event.detail = DND.DROP_COPY;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDummyObject.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDummyObject.java
deleted file mode 100644
index ee61f3752..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewDummyObject.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-/**
- * Sometimes we need to supply a dummy object in our events just to prevent a crash.
- * In these cases, use this.
- */
-public class SystemViewDummyObject
-{
- private static SystemViewDummyObject _instance;
-
- /**
- * Constructor for SystemViewDummyObject.
- */
- public SystemViewDummyObject()
- {
- super();
- }
-
- /**
- * Return the singleton of this
- */
- public static SystemViewDummyObject getInstance()
- {
- if (_instance == null)
- _instance = new SystemViewDummyObject();
- return _instance;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java
deleted file mode 100644
index 611c12d14..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java
+++ /dev/null
@@ -1,593 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * David Dykstal (IBM) - [224671] [api] org.eclipse.rse.core API leaks non-API types
- * David Dykstal (IBM) - [226761] fix NPE in team view when expanding items
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import java.util.Arrays;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
-import org.eclipse.rse.core.filters.ISystemFilterString;
-import org.eclipse.rse.core.model.ISystemMessageObject;
-import org.eclipse.rse.core.model.ISystemModifiableContainer;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.model.SystemChildrenContentsType;
-import org.eclipse.rse.core.model.SystemMessageObject;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.SubSystemHelpers;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.validators.ValidatorFilterName;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ISystemPropertyConstants;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionFilter;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-/**
- * Default Adapter for displaying filter objects in tree views.
- * For some subsystems, these are children of SubSystem objects.
- * This class offers default behaviour but can be subclassed to refine the
- * behaviour. If this is done, you must register your subclass with the
- * platform's adapter manager in your plugin class's startup method.
- */
-public class SystemViewFilterAdapter extends AbstractSystemViewAdapter
-{
-
-
- //private static String translatedFilterString = null;
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
- private SystemComboBoxPropertyDescriptor filterStringsDescriptor;
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given filter object.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- //if (selection.size() != 1)
- // return; // does not make sense adding unique actions per multi-selection
- ISystemFilter filter = (ISystemFilter)selection.getFirstElement();
- if (filter.isTransient())
- return;
- ISubSystemConfiguration ssFactory = SubSystemHelpers.getParentSubSystemConfiguration(filter);
- ssFactory.setConnection(null);
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
- IAction[] actions = adapter.getFilterActions(menu, selection, shell, menuGroup, ssFactory, filter);
- if (actions != null)
- {
- for (int idx=0; idx<actions.length; idx++)
- {
- IAction action = actions[idx];
- menu.add(menuGroup, action);
- }
- }
- }
-
- private ISystemFilter getFilter(Object element)
- {
- return (ISystemFilter)element;
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- * @return the desired image descriptor
- */
- public ImageDescriptor getImageDescriptor(Object element) {
- ImageDescriptor filterImage = null;
- ISystemFilter filter = getFilter(element);
- if (filter.getProvider() != null) {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) filter.getProvider().getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- filterImage = adapter.getSystemFilterImage(filter);
- }
- }
- if (filterImage == null) {
- filterImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTER_ID);
- }
- return filterImage;
- }
-
- /**
- * Return the label for this object. Calls getName on the filter
- */
- public String getText(Object element)
- {
- return getFilter(element).getName();
- }
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- return getFilter(element).getName();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- ISystemFilter filter = getFilter(element);
- if (filter.isTransient())
- {
- return filter.getName();
- }
- else
- {
- return filter.getSystemFilterPoolManager().getName() + "." + filter.getParentFilterPool().getName() + "." + filter.getName(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- ISystemFilter filter = getFilter(element);
- if (filter.isTransient())
- return SystemResources.RESID_PP_FILTER_TYPE_VALUE;
- ISubSystemConfiguration ssParentFactory = SubSystemHelpers.getParentSubSystemConfiguration(filter);
- return ssParentFactory.getTranslatedFilterTypeProperty(filter);
- }
-
- /**
- * Return the parent of this object.
- * This will be either a SubSystem object, or a filter object.
- */
- public Object getParent(Object element)
- {
- ISystemFilter filter = getFilter(element);
- if (filter.isTransient())
- return filter.getSubSystem();
- return filter.getParentFilterContainer();
- }
-
- /**
- * Return the children of this filter.
- * This is a combination of nested filters and resolved filter objects.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- ISystemFilter filter = getFilter(element);
- // transient filters...
- if (filter.isTransient())
- {
- if (filter.isPromptable())
- return checkForEmptyList(processPromptingFilter(filter), element, true);
-
- Object[] children = null;
- String[] filterStrings = filter.getFilterStrings();
- // 50167pc: The following was a problem, as the parent in a SystemFilterSimpleImpl is not
- // to be trusted, since we tend to use the same instance for each connection in the list.
- ISubSystem ss = (ISubSystem)filter.getSubSystem();
- String preSelectName = null;
- try
- {
-// Shell shell = getShell();
- // hack to propogate type filters down from connection in select dialogs...
- ISystemViewInputProvider inputProvider = getInput();
- if ((inputProvider instanceof SystemSelectRemoteObjectAPIProviderImpl) &&
- (filterStrings != null) && (filterStrings.length > 0) )
- {
- SystemSelectRemoteObjectAPIProviderImpl ip = (SystemSelectRemoteObjectAPIProviderImpl)inputProvider;
- if (ip.filtersNeedDecoration(element))
- {
- String[] adorned = new String[filterStrings.length];
- for (int idx = 0; idx < filterStrings.length; idx++)
- adorned[idx] = ip.decorateFilterString(element, filterStrings[idx]);
- filterStrings = adorned;
- }
- preSelectName = ip.getPreSelectFilterChild();
- }
- if (filter instanceof ISystemModifiableContainer) {
- ISystemModifiableContainer containingFilter = (ISystemModifiableContainer) filter;
- // get children from cache if the children have been cached
- if (ss.getSubSystemConfiguration().supportsFilterCaching() && !containingFilter.isStale() &&
- containingFilter.hasContents(SystemChildrenContentsType.getInstance())) {
- children = containingFilter.getContents(SystemChildrenContentsType.getInstance());
- }
- // otherwise, get children and then cache
- else {
- children = checkForEmptyList(ss.resolveFilterStrings(filterStrings, monitor), element, true);
-
- if (ss.getSubSystemConfiguration().supportsFilterCaching()) {
- containingFilter.setContents(SystemChildrenContentsType.getInstance(), children);
- }
- }
- }
-
-
- if ((children !=null) && (preSelectName != null))
- {
- Object match = null;
- for (int idx=0; (match==null) && (idx<children.length); idx++)
- {
- Object child = children[idx];
- String objName = SystemAdapterHelpers.getViewAdapter(child, getViewer()).getName(child);
- if ((objName != null) && (objName.equals(preSelectName)))
- match = child;
- }
- //if (match != null) always reset even if it is null
- if (inputProvider instanceof SystemSelectRemoteObjectAPIProviderImpl)
- {
- ((SystemSelectRemoteObjectAPIProviderImpl) inputProvider).setPreSelectFilterChildObject(match);
- }
- }
- }
- catch (InterruptedException exc)
- {
- children = getCancelledMessageObject();
- }
- catch (Exception exc)
- {
- children = getFailedMessageObject();
- SystemBasePlugin.logError("Exception resolving filters' strings ",exc); //$NON-NLS-1$
- } // message already issued
-
- return children;
- }
-
- if (filter.isPromptable())
- return checkForEmptyList(null, element, false);
-
- // normal filters...
- //Vector strings = filter.getFilterStringsVector();
- ISystemFilterString[] filterStrings = filter.getSystemFilterStrings();
- ISystemFilter[] filters = filter.getSystemFilters();
- Vector vChildren = new Vector();
-
- // start with nested filters...
- for (int idx=0; idx < filters.length; idx++)
- vChildren.addElement(filters[idx]);
- // continue with resolved filter string objects...
- for (int idx=0; idx < filterStrings.length; idx++)
- {
- vChildren.addElement(filterStrings[idx]);
- }
-
- // convert whole thing to an array...
- Object[] children = new Object[vChildren.size()];
- for (int idx=0; idx<vChildren.size(); idx++)
- children[idx] = vChildren.elementAt(idx);
-
- return children;
- }
-
- /**
- * Processing a prompting filter...
- */
- private Object[] processPromptingFilter(ISystemFilter filter)
- {
- Object[] children = new SystemMessageObject[1];
- ISystemViewInputProvider inputProvider = getInput();
- if ( (inputProvider != null) && (inputProvider instanceof SystemSelectRemoteObjectAPIProviderImpl) )
- {
- try
- {
- SystemSelectRemoteObjectAPIProviderImpl ip = (SystemSelectRemoteObjectAPIProviderImpl)inputProvider;
- ISystemFilter newFilter = ip.createFilterByPrompting(filter, getShell());
- if (newFilter == null)
- {
- children = getCancelledMessageObject();
- }
- else // filter string successfully created!
- {
- //SystemFilterSimpleImpl simpleFilter = (SystemFilterSimpleImpl)filter;
- //SubSystem ss = (SubSystem)simpleFilter.getParent();
-
- // return "filter created successfully" message object for this node
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FILTERCREATED),
- ISystemMessageObject.MSGTYPE_OBJECTCREATED,filter);
-
- // select the new filter and expand it
- Viewer v = (Viewer)inputProvider.getViewer();
- if (v instanceof ISystemResourceChangeListener)
- {
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(newFilter, ISystemResourceChangeEvents.EVENT_SELECT_EXPAND, null);
- RSEUIPlugin.getTheSystemRegistryUI().postEvent((ISystemResourceChangeListener)v, event); // only expand in the current viewer, not all viewers!
- }
- }
- } catch (Exception exc)
- {
- children = getFailedMessageObject();
- SystemBasePlugin.logError("Exception prompting for filter ",exc); //$NON-NLS-1$
- }
- }
- //RSEUIPlugin.logDebugMessage(this.getClass().getName(),"returning children");
- return children;
- }
-
- /**
- * Return true if this object has children
- */
- public boolean hasChildren(IAdaptable element)
- {
- ISystemFilter filter = getFilter(element);
- if (filter.getFilterStringCount() > 0)
- return true;
- else if (filter.getSystemFilterCount() > 0)
- return true;
- else
- return false;
- }
-
- // Property sheet descriptors defining all the properties we expose in the Property Sheet
-
- /**
- * Return our unique property descriptors
- */
- protected IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- propertyDescriptorArray = new PropertyDescriptor[3];
- int idx = 0;
-
- // parent filter pool
- propertyDescriptorArray[idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL,SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
- // parent filter
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTER,SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
- // number filter strings
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILTERSTRINGS_COUNT,SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP);
- }
- return propertyDescriptorArray;
- }
- /**
- * Return our unique property values
- * The parent handles P_TEXT and P_TYPE only, and we augment that here.
- * @param key the name of the property as named by its property descriptor
- * @return the current value of the property
- */
- protected Object internalGetPropertyValue(Object key)
- {
- String name = (String)key;
- ISystemFilter filter = getFilter(propertySourceInput);
- // following not working yet...
- if (name.equals(ISystemPropertyConstants.P_FILTERSTRINGS))
- {
- String[] filterStrings = filter.getFilterStrings();
- filterStringsDescriptor.setValues(filterStrings);
- if ((filterStrings != null) && (filterStrings.length>0))
- return filterStrings[0];
- else
- return "null"; //$NON-NLS-1$
- }
- else if (name.equals(ISystemPropertyConstants.P_FILTERSTRINGS_COUNT))
- {
- int nbrFilterStrings = filter.getFilterStringCount();
- return Integer.toString(nbrFilterStrings);
- }
- else if (name.equals(ISystemPropertyConstants.P_PARENT_FILTER))
- {
- if (filter.isTransient())
- return getTranslatedNotApplicable();
- ISystemFilter parent = filter.getParentFilter();
- if (parent != null)
- return parent.getName();
- else
- return getTranslatedNotApplicable();
- }
- else if (name.equals(ISystemPropertyConstants.P_PARENT_FILTERPOOL))
- {
- if (filter.isTransient())
- return getTranslatedNotApplicable();
- ISystemFilterPool parent = filter.getParentFilterPool();
- if (parent != null)
- return parent.getName();
- else
- return null;
- }
- else
- return null;
- }
-
- // FOR COMMON DELETE ACTIONS
- public boolean showDelete(Object element)
- {
- return !getFilter(element).isTransient();
- }
- /**
- * Return true if this object is deletable by the user. If so, when selected,
- * the Edit->Delete menu item will be enabled.
- */
- public boolean canDelete(Object element)
- {
- return true;
- }
-
- /**
- * Perform the delete action.
- */
- public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception
- {
- ISystemFilter filter = getFilter(element);
- ISystemFilterPoolManager fpMgr = filter.getSystemFilterPoolManager();
- fpMgr.deleteSystemFilter(filter);
- return true;
- }
-
- // FOR COMMON RENAME ACTIONS
- public boolean showRename(Object element)
- {
- return !getFilter(element).isTransient();
- }
-
- /**
- * Return true if this object is renamable by the user. If so, when selected,
- * the Rename popup menu item will be enabled.
- */
- public boolean canRename(Object element)
- {
- return true;
- }
- /**
- * Perform the rename action.
- */
- public boolean doRename(Shell shell, Object element, String name, IProgressMonitor monitor) throws Exception
- {
- ISystemFilter filter = getFilter(element);
- ISystemFilterPoolManager fpMgr = filter.getSystemFilterPoolManager();
- fpMgr.renameSystemFilter(filter,name);
- return true;
- }
- /**
- * @param element either a filter for a rename action, or a filter pool for a "new" action.
- * @return a validator for verifying the new name is correct.
- */
- public ISystemValidator getNameValidator(Object element) {
- ISystemFilter filter = null;
- ISystemFilterPool pool = null;
- String[] filterNames = null;
- if (element instanceof ISystemFilter) {
- filter = (ISystemFilter) element;
- pool = filter.getParentFilterPool();
- if (pool != null)
- filterNames = pool.getSystemFilterNames();
- else {
- ISystemFilter parentFilter = filter.getParentFilter();
- filterNames = parentFilter.getSystemFilterNames();
- }
- } else {
- pool = (ISystemFilterPool) element;
- filterNames = pool.getSystemFilterNames();
- }
- Vector names = new Vector(filterNames.length);
- names.addAll(Arrays.asList(filterNames));
- ISystemValidator nameValidator = new ValidatorFilterName(filterNames);
- return nameValidator;
- }
-
- /**
- * Parent override.
- * <p>
- * Form and return a new canonical (unique) name for this object, given a candidate for the new
- * name. This is called by the generic multi-rename dialog to test that all new names are unique.
- * To do this right, sometimes more than the raw name itself is required to do uniqueness checking.
- * <p>
- * Returns mgrName.poolName.filterName, upperCased
- */
- public String getCanonicalNewName(Object element, String newName)
- {
- ISystemFilter filter = (ISystemFilter)element;
- if (!filter.isTransient())
- {
- String mgrName = filter.getSystemFilterPoolManager().getName();
- return (mgrName + "." + filter.getParentFilterPool().getName() + "." + newName).toUpperCase(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else
- return newName.toUpperCase();
- }
-
- // FOR COMMON REFRESH ACTIONS
- public boolean showRefresh(Object element)
- {
- return !getFilter(element).isTransient();
- }
-
- /**
- * Return true if we should show the refresh action in the popup for the given element.
- */
- public boolean showOpenViewActions(Object element)
- {
- return !getFilter(element).isTransient();
- }
-
- /**
- * Test an object to see if it has an attribute with a particular value.
- * From <code>IActionFilter</code> so the popupMenus extension point can use
- * &lt;filter&gt;, &lt;enablement&gt; or &lt;visibility&gt;.
- * We add support for the following attributes:
- * <ol>
- * <li>"filterType"
- * The value is tested against the non-translated filter type.
- * Not all subsystems support different types of filters.
- * <li>name="showChangeFilterStringsPropertyPage".
- * The value is tested against the call to the
- * subsystem configuration method showChangeFilterStringsPropertyPage(SystemFilter).
- * values should be <code>true</code> or <code>false</code>.
- * </ol>
- * @param target the object whose attribute we are testing
- * @param name the attribute to test.
- * @param value the value to test.
- * @return true if the attribute of the given name can be said to have the given value
- * @see IActionFilter#testAttribute(Object, String, String)
- */
- public boolean testAttribute(Object target, String name, String value) {
- boolean result = false;
- if (name.equalsIgnoreCase("filterType")) { //$NON-NLS-1$
- ISystemFilter filter = getFilter(target);
- String type = filter.getType();
- result = (type != null) && (type.length() > 0) && value.equals(type);
- } else if (name.equalsIgnoreCase("showChangeFilterStringPropertyPage")) { //$NON-NLS-1$
- ISystemFilter filter = getFilter(target);
- ISubSystemConfiguration ssf = SubSystemHelpers.getParentSubSystemConfiguration(filter);
- result = (ssf != null) && ssf.showChangeFilterStringsPropertyPage(filter) && value.equals("true"); //$NON-NLS-1$
- } else {
- result = super.testAttribute(target, name, value);
- }
- return result;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolAdapter.java
deleted file mode 100644
index a967f9acb..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolAdapter.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * David Dykstal (IBM) - [226761] fix NPE in team view when expanding items
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.SubSystemHelpers;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.validators.ValidatorFilterPoolName;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ISystemPropertyConstants;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-
-/**
- * Adapter for displaying SystemFilterPool objects in tree views.
- * These are the masters, and only shown in work-with for the master.
- * These are children of SubSystemConfiguration objects
- */
-public class SystemViewFilterPoolAdapter extends AbstractSystemViewAdapter
-{
- protected String translatedType;
- //protected Object parent;
-
- // for reset property support
- //private String original_userId, original_port;
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given subsystem object.
- * Calls the method getActions on the subsystem's factory, and places
- * all action objects returned from the call, into the menu.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- //if (selection.size() != 1)
- // return; // does not make sense adding unique actions per multi-selection
- ISystemFilterPool pool = ((ISystemFilterPool)selection.getFirstElement());
- ISubSystemConfiguration ssFactory = SubSystemHelpers.getParentSubSystemConfiguration(pool);
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
- IAction[] actions = adapter.getFilterPoolActions(menu, selection, shell, menuGroup, ssFactory, pool);
- if (actions != null)
- {
- for (int idx=0; idx<actions.length; idx++)
- {
- IAction action = actions[idx];
- menu.add(menuGroup, action);
- }
- }
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- * @return the desired image descriptor
- */
- public ImageDescriptor getImageDescriptor(Object element) {
- ImageDescriptor poolImage = null;
- ISystemFilterPool pool = (ISystemFilterPool) element;
- if (pool.getProvider() != null) {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) pool.getProvider().getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- poolImage = adapter.getSystemFilterPoolImage(pool);
- }
- }
- if (poolImage == null) {
- poolImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID);
- }
- return poolImage;
- }
-
- /**
- * Return the label for this object. Uses getName() on the filter pool object.
- */
- public String getText(Object element)
- {
- return ((ISystemFilterPool)element).getName();
- }
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- return ((ISystemFilterPool)element).getName();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- ISystemFilterPool filterPool = (ISystemFilterPool)element;
- return filterPool.getSystemFilterPoolManager().getName() + "." + filterPool.getName(); //$NON-NLS-1$
- }
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- if (translatedType == null)
- translatedType = SystemViewResources.RESID_PROPERTY_FILTERPOOL_TYPE_VALUE;
- return translatedType;
- }
-
- /**
- * Return the parent of this object. The parent of a filter pool is a subsystem factory,
- * in real life. But to a user, it is a subsystem.
- */
- public Object getParent(Object element)
- {
- ISystemFilterPool fp = (ISystemFilterPool)element;
- // hmm, this will only work if a given factory only has one subsystem object...
- ISubSystemConfiguration ssParentFactory = SubSystemHelpers.getParentSubSystemConfiguration(fp);
- return ssParentFactory.getSubSystems(false)[0];
- }
-
- /**
- * Return the children of this object.
- * For filter pools, this is a list of filters.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- ISystemFilterPool fp = (ISystemFilterPool)element;
- return fp.getSystemFilters();
- }
-
- /**
- * Return true if this object has children. That is, has filters.
- */
- public boolean hasChildren(IAdaptable element)
- {
- ISystemFilterPool fp = (ISystemFilterPool)element;
- return fp.getSystemFilterCount() > 0;
- }
-
- // Property sheet descriptors defining all the properties we expose in the Property Sheet
- /**
- * Return our unique property descriptors
- */
- protected IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- propertyDescriptorArray = new PropertyDescriptor[3];
- int idx = 0;
-
- // parent filter pool
- propertyDescriptorArray[idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_TOOLTIP);
-
- // parent filter pool's profile
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PROFILE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_TOOLTIP);
-
- // Related connection
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_RELATED_CONNECTION, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP);
-
- }
- return propertyDescriptorArray;
- }
- /**
- * Return our unique property values
- */
- protected Object internalGetPropertyValue(Object key)
- {
- String name = (String)key;
- ISystemFilterPool pool = (ISystemFilterPool)propertySourceInput;
- if (name.equals(ISystemPropertyConstants.P_PARENT_FILTERPOOL))
- return pool.getName();
- else if (name.equals(ISystemPropertyConstants.P_PROFILE))
- return pool.getSystemFilterPoolManager().getName();
- else if (name.equals(ISystemPropertyConstants.P_RELATED_CONNECTION))
- return (pool.getOwningParentName()==null) ? getTranslatedNotApplicable() : pool.getOwningParentName();
- else
- return null;
- }
-
- // FOR COMMON DELETE ACTIONS
- /**
- * Return true if this object is deletable by the user. If so, when selected,
- * the Edit->Delete menu item will be enabled.
- */
- public boolean canDelete(Object element)
- {
- ISystemFilterPool fp = (ISystemFilterPool)element;
- return fp.isDeletable();
- }
-
- /**
- * Perform the delete action.
- */
- public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception
- {
- ISystemFilterPool fp = (ISystemFilterPool)element;
- ISystemFilterPoolManager fpMgr = fp.getSystemFilterPoolManager();
- fpMgr.deleteSystemFilterPool(fp);
- return true;
- }
-
- // FOR COMMON RENAME ACTIONS
- /**
- * Return true if this object is renamable by the user. If so, when selected,
- * the Rename menu item will be enabled.
- */
- public boolean canRename(Object element)
- {
- if (!canDelete(element))
- return false;
- ISystemFilterPool fp = (ISystemFilterPool)element;
- return !fp.isNonRenamable();
- }
-
- /**
- * Perform the rename action. Assumes uniqueness checking was done already.
- */
- public boolean doRename(Shell shell, Object element, String name, IProgressMonitor monitor) throws Exception
- {
- ISystemFilterPool fp = (ISystemFilterPool)element;
- ISystemFilterPoolManager fpMgr = fp.getSystemFilterPoolManager();
- fpMgr.renameSystemFilterPool(fp,name);
- return true;
- }
- /**
- * Return a validator for verifying the new name is correct.
- */
- public ISystemValidator getNameValidator(Object element) {
- ISystemFilterPool fp = (ISystemFilterPool) element;
- ISystemFilterPoolManager mgr = fp.getSystemFilterPoolManager();
- String[] names = mgr.getSystemFilterPoolNames();
- ISystemValidator nameValidator = new ValidatorFilterPoolName(names);
- return nameValidator;
- }
-
- /**
- * Parent override.
- * <p>
- * Form and return a new canonical (unique) name for this object, given a candidate for the new
- * name. This is called by the generic multi-rename dialog to test that all new names are unique.
- * To do this right, sometimes more than the raw name itself is required to do uniqueness checking.
- * <p>
- * Returns mgrName.poolName, upperCased
- */
- public String getCanonicalNewName(Object element, String newName)
- {
- String mgrName = ((ISystemFilterPool)element).getSystemFilterPoolManager().getName();
- return (mgrName + "." + newName).toUpperCase(); //$NON-NLS-1$
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java
deleted file mode 100644
index d6ebd844e..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java
+++ /dev/null
@@ -1,416 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Tobias Schwarz (Wind River) - [181394] Include Context in getAbsoluteName() for filter and pool references
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
-import org.eclipse.rse.core.filters.ISystemFilterPoolManagerProvider;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManagerProvider;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.SubSystemHelpers;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.validators.ValidatorFilterPoolName;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ISystemPropertyConstants;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-
-/**
- * Adapter for displaying SystemFilterPool reference objects in tree views.
- * These are children of SubSystem objects
- */
-public class SystemViewFilterPoolReferenceAdapter
- extends AbstractSystemViewAdapter
-{
- protected String translatedType;
- //protected Object parent;
-
- // for reset property support
- //private String original_userId, original_port;
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given subsystem object.
- * Calls the method getActions on the subsystem's factory, and places
- * all action objects returned from the call, into the menu.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- //if (selection.size() != 1)
- // return; // does not make sense adding unique actions per multi-selection
- Object element = selection.getFirstElement();
- ISystemFilterPool pool = getFilterPool(element);
- ISubSystemConfiguration ssFactory = getSubSystemConfiguration(pool);
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- // Lazy Loading: By default, ISubSystemConfigurationAdapter will
- // only be available after its declaring bundle has been loaded,
- // which usually happens on "connect" of a subsystem. Before that
- // time, dynamically contributed actions will not be available.
- // Implementations that want their dynamic actions to be avaialble
- // earlier need to either declare them by static plugin.xml, or
- // provision for more eager loading of the bundle that declares
- // their adapter.
- IAction[] actions = adapter.getFilterPoolActions(menu, selection, shell, menuGroup, ssFactory, pool);
- if (actions != null) {
- for (int idx = 0; idx < actions.length; idx++) {
- IAction action = actions[idx];
- menu.add(menuGroup, action);
- }
- }
- actions = adapter.getFilterPoolReferenceActions(menu, selection, shell, menuGroup, ssFactory, (ISystemFilterPoolReference) element);
- if (actions != null) {
- // menu.addSeparator();
- for (int idx = 0; idx < actions.length; idx++) {
- IAction action = actions[idx];
- menu.add(menuGroup, action);
- }
- }
- }
- }
-
- private ISubSystemConfiguration getSubSystemConfiguration(ISystemFilterPool pool)
- {
- return SubSystemHelpers.getParentSubSystemConfiguration(pool);
- }
-
- /**
- * <i>Overridden from parent.</i><br>
- * Returns the subsystem that contains this object.
- */
- public ISubSystem getSubSystem(Object element)
- {
- ISystemFilterPoolReference ref = (ISystemFilterPoolReference)element;
- return (ISubSystem)ref.getProvider();
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element) {
- ImageDescriptor poolImage = null;
- ISystemFilterPool pool = getFilterPool(element);
- if (pool != null) {
- ISystemFilterPoolManagerProvider provider = pool.getProvider();
- if (provider != null) {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) provider.getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- // Lazy Loading: Customized filter pool images will only be
- // available once the bundle that declares the
- // ISubSystemConfigurationAdapter has been activated. Until
- // that time, a default image is shown. Clients who want
- // their customized images be available earlier need to
- // provision for more eager loading of their bundles at the
- // right time (e.g. when expanding the SubSystem node,
- // rather than when connecting).
- poolImage = adapter.getSystemFilterPoolImage(pool);
- }
- }
- }
- if (poolImage == null) {
- poolImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID);
- }
- return poolImage;
- }
-
- private ISystemFilterPool getFilterPool(Object element)
- {
- ISystemFilterPoolReference ref = (ISystemFilterPoolReference)element;
- ISystemFilterPool pool = ref.getReferencedFilterPool();
- return pool; // get master object
- }
-
- /**
- * @param element the filter pool reference masquerading as an object
- * @return the label for this filter pool reference.
- */
- public String getText(Object element) {
- ISystemFilterPoolReference reference = (ISystemFilterPoolReference) element;
- String result = reference.getName();
- ISystemFilterPool pool = getFilterPool(element);
- if (pool != null) {
- result = pool.getName();
- }
- return result;
- }
-
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- return getFilterPool(element).getName();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- //TODO consider caching the absolute name in the FilterPoolReference to avoid unnecessary String operations - the name won't ever change
- ISystemFilterPoolReference filterPoolRef = (ISystemFilterPoolReference)element;
- ISystemFilterPoolReferenceManagerProvider subSystem = filterPoolRef.getProvider();
- ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(subSystem);
- String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(subSystem) : ""; //$NON-NLS-1$
- String referenceName = filterPoolRef.getName();
- String managerName = filterPoolRef.getReferencedFilterPoolManagerName();
- String absoluteName = parentAbsoluteName + "." + managerName + "." + referenceName; //$NON-NLS-1$ //$NON-NLS-2$
- return absoluteName;
- }
-
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- if (translatedType == null)
- translatedType = SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_TYPE_VALUE;
- return translatedType;
- }
-
- /**
- * Return the parent of this object
- */
- public Object getParent(Object element)
- {
- ISystemFilterPoolReference fpr = (ISystemFilterPoolReference)element;
- return SubSystemHelpers.getParentSubSystem(fpr);
- }
-
- /**
- * Return the children of this object.
- * For filter pools, this is a list of filters.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
- ISubSystem ss = getSubSystem(element);
- return fpRef.getSystemFilterReferences(ss);
- }
-
- /**
- * Return true if this object has children
- */
- public boolean hasChildren(IAdaptable element) {
- int count = 0;
- ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
- if (fpRef != null) {
- ISystemFilterPool filterPool = fpRef.getReferencedFilterPool();
- if (filterPool != null) {
- count = filterPool.getSystemFilterCount();
- }
- }
- return count > 0;
- }
-
- // Property sheet descriptors defining all the properties we expose in the Property Sheet
- /**
- * Return our unique property descriptors
- */
- protected IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- propertyDescriptorArray = new PropertyDescriptor[3];
- int idx = 0;
-
- // parent filter pool
- propertyDescriptorArray[idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_TOOLTIP);
-
- // parent filter pool's profile
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PROFILE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_TOOLTIP);
-
- // Related connection
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_RELATED_CONNECTION, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP);
- }
- return propertyDescriptorArray;
- }
- /**
- * Return our unique property values
- */
- protected Object internalGetPropertyValue(Object key)
- {
- String name = (String)key;
- //SystemFilterPoolReference ref = getFilterPoolReference(propertySourceInput);
- ISystemFilterPool pool = getFilterPool(propertySourceInput);
- if (name.equals(ISystemPropertyConstants.P_PARENT_FILTERPOOL))
- return pool.getName();
- else if (name.equals(ISystemPropertyConstants.P_PROFILE))
- return pool.getSystemFilterPoolManager().getName();
- else if (name.equals(ISystemPropertyConstants.P_RELATED_CONNECTION))
- return (pool.getOwningParentName()==null) ? getTranslatedNotApplicable() : pool.getOwningParentName();
- else
- return null;
- }
-
- // FOR COMMON DELETE ACTIONS
- /**
- * Return true if this object is deletable by the user. If so, when selected,
- * the Edit->Delete menu item will be enabled.
- */
- public boolean canDelete(Object element)
- {
- ISystemFilterPool fp = getFilterPool(element);
- return fp.isDeletable();
- }
-
- /**
- * Perform the delete action.
- * This physically deletes the filter pool and all references.
- */
- public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception
- {
- ISystemFilterPool fp = getFilterPool(element);
- ISystemFilterPoolManager fpMgr = fp.getSystemFilterPoolManager();
- fpMgr.deleteSystemFilterPool(fp);
- //SubSystemConfiguration ssParentFactory = getSubSystemConfiguration(fp);
- //ssParentFactory.deleteFilterPool(fp);
- return true;
- }
-
- // FOR COMMON RENAME ACTIONS
- /**
- * Return true if this object is renamable by the user. If so, when selected,
- * the Rename menu item will be enabled.
- */
- public boolean canRename(Object element)
- {
- if (!canDelete(element))
- return false;
- ISystemFilterPool fp = getFilterPool(element);
- return !fp.isNonRenamable();
- }
-
- /**
- * Perform the rename action. Assumes uniqueness checking was done already.
- */
- public boolean doRename(Shell shell, Object element, String name, IProgressMonitor monitor) throws Exception
- {
- ISystemFilterPool fp = getFilterPool(element);
- ISystemFilterPoolManager fpMgr = fp.getSystemFilterPoolManager();
- fpMgr.renameSystemFilterPool(fp,name);
- //SubSystemConfiguration ssParentFactory = getSubSystemConfiguration(fp);
- //ssParentFactory.renameFilterPool(fp,name);
- return true;
- }
- /**
- * Return a validator for verifying the new name is correct.
- */
- public ISystemValidator getNameValidator(Object element) {
- ISystemFilterPool fp = null;
- if (element instanceof ISystemFilterPoolReference) {
- fp = getFilterPool(element);
- } else if (element instanceof ISystemFilterPool) {
- fp = (ISystemFilterPool) element;
- } else {
- throw new IllegalArgumentException();
- }
- ISystemFilterPoolManager mgr = fp.getSystemFilterPoolManager();
- String[] names = mgr.getSystemFilterPoolNames();
- ISystemValidator nameValidator = new ValidatorFilterPoolName(names);
- return nameValidator;
- }
- /**
- * Parent override.
- * <p>
- * Form and return a new canonical (unique) name for this object, given a candidate for the new
- * name. This is called by the generic multi-rename dialog to test that all new names are unique.
- * To do this right, sometimes more than the raw name itself is required to do uniqueness checking.
- * <p>
- * Returns mgrName.poolName, upperCased
- */
- public String getCanonicalNewName(Object element, String newName)
- {
- String mgrName = ((ISystemFilterPoolReference)element).getReferencedFilterPoolManagerName();
- return (mgrName + "." + newName).toUpperCase(); //$NON-NLS-1$
- }
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
-
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- * This just defaults to getName, but if that is not sufficient override it here.
- */
- public String getMementoHandle(Object element)
- {
- ISystemFilterPoolReference fpRef = (ISystemFilterPoolReference)element;
- return fpRef.getFullName();
- }
- /**
- * Return what to save to disk to identify this element when it is the input object to a secondary
- * Remote System Explorer perspective.
- */
- public String getInputMementoHandle(Object element)
- {
- Object parent = getParent(element);
- return SystemAdapterHelpers.getViewAdapter(parent, getViewer()).getInputMementoHandle(parent) + MEMENTO_DELIM + getMementoHandle(element);
- }
- /**
- * Return a short string to uniquely identify the type of resource. Eg "conn" for connection.
- * This just defaults to getType, but if that is not sufficient override it here, since that is
- * a translated string.
- */
- public String getMementoHandleKey(Object element)
- {
- return ISystemMementoConstants.MEMENTO_KEY_FILTERPOOLREFERENCE;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java
deleted file mode 100644
index 9c3b531a1..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java
+++ /dev/null
@@ -1,1049 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David Dykstal (IBM) - moved SystemsPreferencesManager to a new package
- * Tobias Schwarz (Wind River) - [181394] Include Context in getAbsoluteName() for filter and pool references
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Tobias Schwarz (Wind River) - [173267] "empty list" should not be displayed
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * Kevin Doyle (IBM) - [187707] Added separator between New Folder and New File in context menu
- * David McKnight (IBM) - [199566] Remove synchronzied from internalGetChildren
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * David McKnight (IBM) - [210563] error messages need to be shown if incurred during filter expansion
- * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading
- * David McKnight (IBM) - [232148] Invalid thread access exception from SystemViewFilterReferenceAdapter.internalGetChildren()
- * David McKnight (IBM) - [233494] Show in Table Action should be removed from promptable filters
- * David McKnight (IBM) - [238507] Promptable Filters refreshed after modifying filter strings
- * David McKnight (IBM) - [244824] filter not refreshed if child is "empty list" or system message node
- * David McKnight (IBM) - [249245] not showing inappropriate popup actions for: Refresh, Show In Table, Go Into, etc.
- * David McKnight (IBM) - [254614] Promptable filter's shouldn't require supportsCommands on the subsystem to be false
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterContainerReference;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemContainer;
-import org.eclipse.rse.core.model.ISystemMessageObject;
-import org.eclipse.rse.core.model.ISystemResourceSet;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.model.SystemChildrenContentsType;
-import org.eclipse.rse.core.model.SystemMessageObject;
-import org.eclipse.rse.core.model.SystemRemoteResourceSet;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.SubSystemHelpers;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.SystemPreferencesManager;
-import org.eclipse.rse.ui.filters.actions.SystemNewFilterAction;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.validators.ValidatorFilterName;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.rse.ui.view.ISystemPropertyConstants;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-
-/**
- * Adapter for displaying SystemFilterReference objects in tree views.
- * These are children of SystemFilterPoolReference and SystemFilterReference objects
- */
-public class SystemViewFilterReferenceAdapter
- extends AbstractSystemViewAdapter
-{
- //private static String translatedFilterString = null;
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
- //private SystemComboBoxPropertyDescriptor filterStringsDescriptor, filtersDescriptor;
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given filter object.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- //if (selection.size() != 1)
- // return; // does not make sense adding unique actions per multi-selection
- ISystemFilter filter = getFilter(selection.getFirstElement());
- ISubSystemConfiguration ssFactory = getSubSystemConfiguration(filter);
- ISubSystem currentSubSystem = getFilterReference(selection.getFirstElement()).getSubSystem();
- IHost currentConnection = currentSubSystem.getHost();
- ssFactory.setConnection(currentConnection);
- ssFactory.setCurrentSelection(selection.toArray());
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- // Lazy Loading: Specialized actions on filters are available only
- // after the bundle that declares the ISubSystemConfigurationAdapter
- // has been loaded, which typically is after connecting. We do not
- // load the bundle here because this code is executed as part of
- // showing a context menu. Subsystems who want their actions to be
- // available earlier need to provide them by static plugin.xml
- // markup or provision for more eager loading of their bundle, e.g.
- // through Platform.getAdapterManager().loadAdapter() at the right
- // time.
- IAction[] actions = adapter.getFilterActions(menu, selection, shell, menuGroup, ssFactory, filter);
- if (actions != null)
- {
- for (int idx = 0; idx < actions.length; idx++) {
- IAction action = actions[idx];
- if (action instanceof SystemNewFilterAction)
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_NEW, new Separator());
- menu.add(menuGroup, action);
- }
- }
- actions = adapter.getFilterReferenceActions(menu, selection, shell, menuGroup, ssFactory, getFilterReference(selection.getFirstElement()));
- if (actions != null)
- {
- for (int idx = 0; idx < actions.length; idx++) {
- IAction action = actions[idx];
- menu.add(menuGroup, action);
- }
- }
- }
- }
-
- private ISubSystemConfiguration getSubSystemConfiguration(ISystemFilter filter)
- {
- return SubSystemHelpers.getParentSubSystemConfiguration(filter);
- }
-
- /**
- * <i>Overridden from parent.</i><br>
- * Returns the subsystem that contains this object.
- */
- public ISubSystem getSubSystem(Object element)
- {
- if (element instanceof ISystemFilterReference)
- return (ISubSystem) (((ISystemFilterReference) element).getProvider());
- else
- return null;
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- //return RSEUIPlugin.getDefault().getImageDescriptor(ISystemConstants.ICON_SYSTEM_FILTER_ID);
- ImageDescriptor filterImage = null;
- ISystemFilter filter = getFilter(element);
- if (filter.getProvider() != null) // getProvider() returns the subsystem factory
- {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)filter.getProvider().getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- // Lazy Loading: Customized Filter Images will be available only
- // after the bundle that declares the
- // ISubSystemConfigurationAdapter has been loaded. Until that
- // time, a default filter image is used. Extenders who want to
- // see their filter images right away need to provision for
- // eager loading of their bundles at the right time (i.e. when
- // expanding the Subsystem node).
- filterImage = adapter.getSystemFilterImage(filter);
- }
- }
- if (filterImage == null)
- filterImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTER_ID);
- return filterImage;
- }
-
- private ISystemFilterReference getFilterReference(Object element)
- {
- return (ISystemFilterReference) element; // get referenced object
- }
-
- private ISystemFilter getFilter(Object element)
- {
- return getFilterReference(element).getReferencedFilter(); // get master object
- }
-
- /**
- * Return the label for this object. Uses getName() on the filter pool object.
- */
- public String getText(Object element)
- {
- return getFilter(element).getName();
- }
-
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- return getFilter(element).getName();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- //TODO consider caching the absolute name in the FilterReference to avoid unnecessary String operations - the name won't ever change
- ISystemFilterPoolReference filterPoolReference = getFilterReference(element).getParentSystemFilterReferencePool();
- ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(filterPoolReference);
- String parentAbsoluteName = (adapter != null) ? adapter.getAbsoluteName(filterPoolReference) : ""; //$NON-NLS-1$
- return parentAbsoluteName + "." + getName(element); //$NON-NLS-1$
- }
-
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- ISystemFilter filter = getFilter(element);
- ISubSystemConfiguration ssParentFactory = getSubSystemConfiguration(filter);
- return ssParentFactory.getTranslatedFilterTypeProperty(filter);
- }
-
- /**
- * Return the parent of this object
- */
- public Object getParent(Object element)
- {
- ISystemFilterReference fr = getFilterReference(element);
- ISystemFilterContainerReference parentContainer = fr.getParent();
- // if parent is a filter (eg, we are nested) that is always the parent...
- if (parentContainer instanceof ISystemFilterReference)
- return parentContainer;
- // else parent is a filter pool. The parent will be the pool only if
- // we are in "Show Filter Pools" mode, else it is the subsystem.
- boolean showFPs = SystemPreferencesManager.getShowFilterPools();
- if (showFPs)
- return parentContainer;
- else
- return fr.getProvider();
- //return fr.getParent();
- }
-
- /**
- * Return the children of this object.
- * For filters, this is one or more of:
- * <ul>
- * <li>filters if nested filters supported
- * <li>filter strings if user has elected to show filter strings in his preferences
- * <li>resolved objects for each filter string if user has elected NOT to show filter strings in his preferences
- * </ul>
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- return internalGetChildren(element, monitor);
- }
-
- /**
- * Gets all the children and then passes the children to the subsystem configuration adapter for filtering.
- * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#getChildren(org.eclipse.rse.ui.view.IContextObject, org.eclipse.core.runtime.IProgressMonitor)
- */
- public Object[] getChildren(IContextObject element, IProgressMonitor monitor) {
- Object[] children = getChildren(element.getModelObject(), monitor);
- ISubSystem subsystem = element.getSubSystem();
- ISubSystemConfiguration configuration = subsystem.getSubSystemConfiguration();
- Object adapter = Platform.getAdapterManager().getAdapter(configuration, ISubSystemConfigurationAdapter.class);
-
- if (adapter instanceof ISubSystemConfigurationAdapter)
- {
- children = ((ISubSystemConfigurationAdapter)adapter).applyViewFilters(element, children);
- }
-
- return children;
- }
-
- /*
- * Returns the children of the specified element. If a monitor is passed in then
- * the context is assumed to be modal and, as such, the modal version of ss.resolveFilterStrings
- * is called rather than the main thread version.
- */
- protected Object[] internalGetChildren(Object element, IProgressMonitor monitor)
- {
- Object[] children = null;
- final ISystemFilterReference fRef = getFilterReference(element);
- ISystemFilter referencedFilter = fRef.getReferencedFilter();
- boolean promptable = referencedFilter.isPromptable();
-
- final ISubSystem ss = fRef.getSubSystem();
- final ISubSystemConfiguration ssf = SubSystemHelpers.getParentSubSystemConfiguration(referencedFilter);
-
- // PROMPTING FILTER?...
- if (promptable)
- {
- final Object[] pchildren = new SystemMessageObject[1];
- final Object pelement = element;
- // promptable's need to be run on the main thread since they display dialogs
- Display.getDefault().syncExec(new Runnable()
- {
-
- public void run()
- {
- try
- {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssf.getAdapter(ISubSystemConfigurationAdapter.class);
-
- ISystemFilter newFilter = adapter.createFilterByPrompting(ssf, fRef, getShell());
- if (newFilter == null)
- {
- pchildren[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED), ISystemMessageObject.MSGTYPE_CANCEL, pelement);
- }
- else // filter successfully created!
- {
- // return "filter created successfully" message object for this node
- pchildren[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FILTERCREATED), ISystemMessageObject.MSGTYPE_OBJECTCREATED, pelement);
- // select the new filter reference...
- ISystemFilterReference sfr = fRef.getParentSystemFilterReferencePool().getExistingSystemFilterReference(ss, newFilter);
- ISystemViewInputProvider inputProvider = getInput();
- if ((sfr != null) && (inputProvider != null) && (inputProvider.getViewer() != null))
- {
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(sfr, ISystemResourceChangeEvents.EVENT_SELECT_EXPAND, null);
- Viewer v = (Viewer)inputProvider.getViewer();
- if (v instanceof ISystemResourceChangeListener)
- {
- //sr.fireEvent((ISystemResourceChangeListener)v, event); // only expand in the current viewer, not all viewers!
- RSEUIPlugin.getTheSystemRegistryUI().postEvent((ISystemResourceChangeListener) v, event); // only expand in the current viewer, not all viewers!
- }
- }
- }
- }
- catch (Exception exc)
- {
- pchildren[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED), ISystemMessageObject.MSGTYPE_ERROR, pelement);
- SystemBasePlugin.logError("Exception prompting for filter ", exc); //$NON-NLS-1$
- }
- //RSEUIPlugin.logDebugMessage(this.getClass().getName(),"returning children");
- }
- });
- return pchildren;
- }
-
- // NON-PROMPTING FILTER?...
- Object[] nestedFilterReferences = fRef.getSystemFilterReferences(ss);
- int nbrFilterStrings = referencedFilter.getFilterStringCount();
- if (nbrFilterStrings == 0)
- return nestedFilterReferences;
- else
- {
- /*
- // show filter strings
- if (ssf.showFilterStrings())
- {
- SystemFilterStringReference[] refFilterStrings = fRef.getSystemFilterStringReferences();
- if ((nestedFilterReferences == null) || (nestedFilterReferences.length == 0))
- return refFilterStrings;
- if ((refFilterStrings == null) || (refFilterStrings.length == 0))
- return nestedFilterReferences;
- int nbrChildren = nestedFilterReferences.length + refFilterStrings.length;
- children = new Object[nbrChildren];
- int idx=0;
- for (idx=0; idx<nestedFilterReferences.length; idx++)
- children[idx] = nestedFilterReferences[idx];
- for (int jdx=0; jdx<refFilterStrings.length; jdx++)
- children[idx++] = refFilterStrings[jdx];
- return children;
- }
- // resolve filter strings
- else
- */ {
- String[] filterStrings = referencedFilter.getFilterStrings();
-
- try
- {
-
- // hack to propogate type filters down from connection in select dialogs...
- ISystemViewInputProvider inputProvider = getInput();
- if ((inputProvider != null) && (inputProvider instanceof SystemSelectRemoteObjectAPIProviderImpl) &&
- (filterStrings != null) && (filterStrings.length > 0))
- {
- SystemSelectRemoteObjectAPIProviderImpl ip = (SystemSelectRemoteObjectAPIProviderImpl) inputProvider;
- if (ip.filtersNeedDecoration(element))
- {
- String[] adorned = new String[filterStrings.length];
- for (int idx = 0; idx < filterStrings.length; idx++)
- adorned[idx] = ip.decorateFilterString(element, filterStrings[idx]);
- filterStrings = adorned;
- }
- }
-
- boolean doQuery = true;
- if (!referencedFilter.isTransient() &&
- ssf.supportsFilterCaching() &&
- !fRef.isStale() &&
- fRef.hasContents(SystemChildrenContentsType.getInstance()))
- {
- doQuery = false;
- children = fRef.getContents(SystemChildrenContentsType.getInstance());
- if (children != null)
- {
- if (children.length == 0){
- doQuery = true;
- fRef.markStale(true);
- }
- else {
- // check for stale children
- for (int i = 0; i < children.length && !doQuery; i++)
- {
- Object child = children[i];
- if (child instanceof ISystemContainer)
- {
- if (((ISystemContainer)child).isStale())
- {
- doQuery = true;
- fRef.markStale(true);
- }
- }
- else if (child instanceof ISystemMessageObject){
- if (((ISystemMessageObject)child).isTransient()){
- doQuery = true;
- fRef.markStale(true);
- }
- }
- }
- }
- }
- }
- if (doQuery)
- {
- Object[] allChildren = null;
-
- if (monitor == null)
- {
- allChildren = ss.resolveFilterStrings(filterStrings, new NullProgressMonitor());
- }
- else
- {
- allChildren = ss.resolveFilterStrings(filterStrings, monitor);
- }
-
- if (allChildren == null)
- {
- // System.out.println("filter children == null!"); //$NON-NLS-1$
- }
- else
- {
- if (allChildren.length == 1 && allChildren[0] instanceof ISystemMessageObject)
- {
- // error to display
- return allChildren; // nothing to sort or cache - just show the error
- }
-
- if (nestedFilterReferences != null)
- {
- int nbrNestedFilters = nestedFilterReferences.length;
- children = new Object[nbrNestedFilters + allChildren.length];
- int idx = 0;
- for (idx = 0; idx < nbrNestedFilters; idx++)
- children[idx] = nestedFilterReferences[idx];
- for (int jdx = 0; jdx < allChildren.length; jdx++)
- children[idx++] = allChildren[jdx];
-
-
- if (!referencedFilter.isTransient() && ssf.supportsFilterCaching())
- {
- fRef.setContents(SystemChildrenContentsType.getInstance(), children);
- }
- }
- }
- }
-
- }
- catch (InterruptedException exc)
- {
- children = new SystemMessageObject[1];
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED), ISystemMessageObject.MSGTYPE_CANCEL, element);
- SystemBasePlugin.logDebugMessage(this.getClass().getName(), "Filter resolving cancelled by user."); //$NON-NLS-1$
- }
- catch (Exception exc)
- {
- children = new SystemMessageObject[1];
- children[0] = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED), ISystemMessageObject.MSGTYPE_ERROR, element);
- SystemBasePlugin.logError("Exception resolving filters' strings ", exc); //$NON-NLS-1$
- } // message already issued
-
- return checkForEmptyList(children, element, true);
- }
- }
- }
-
- /**
- * Return true if this object has children.
- * That is, if the referenced filter has nested filters or filter strings.
- */
- public boolean hasChildren(IAdaptable element)
- {
- ISystemFilterReference fRef = getFilterReference(element);
- ISystemFilter referencedFilter = fRef.getReferencedFilter();
-
- ISubSystemConfiguration factory = getSubSystemConfiguration(referencedFilter);
- if (factory.supportsFilterChildren())
- {
- int nbrNestedFilters = referencedFilter.getSystemFilterCount();
- int nbrFilterStrings = referencedFilter.getFilterStringCount();
- return (nbrNestedFilters > 0) || (nbrFilterStrings > 0);
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Return true if this object is a "prompting" object that prompts the user when expanded.
- * For such objects, we do not try to save and restore their expansion state on F5 or between
- * sessions.
- * <p>
- * Default is false unless this is a prompting filter
- */
- public boolean isPromptable(Object element)
- {
- boolean promptable = false;
- ISystemFilter filter = getFilter(element);
- promptable = filter.isPromptable();
- //if (!promptable && !SystemPreferencesManager.getPreferencesManager().getShowFilterStrings())
- if (!promptable)
- {
- //if (isCommandFilter(filter) || isJobFilter(filter))
- if (isCommandFilter(filter))
- promptable = true;
- }
- return promptable;
- }
-
- /**
- * <i>Overide of parent method.</i><br>
- * From <samp>IActionFilter</samp> so the popupMenus extension point can use &lt;filter&gt;, &lt;enablement&gt;
- * or &lt;visibility&gt;. We add support is for the following:
- * <ol>
- * <li>name="filterType". The value is tested against the non-translated filter type. Note all subsystems
- * support different types of filters.
- * <li>name="showChangeFilterStringsPropertyPage". The value is tested against the call to the subsystem factory method showChangeFilterStringsPropertyPage(SystemFilter).
- * Compares against "true" (default) or "false".
- * </ol>
- */
- public boolean testAttribute(Object target, String name, String value)
- {
- if (name.equalsIgnoreCase("filterType")) //$NON-NLS-1$
- {
- ISystemFilterReference ref = getFilterReference(target);
- String type = ref.getReferencedFilter().getType();
- if ((type == null) || (type.length() == 0))
- return false;
- else
- return value.equals(type);
- }
- else if (name.equalsIgnoreCase("showChangeFilterStringPropertyPage")) //$NON-NLS-1$
- {
- ISystemFilterReference ref = getFilterReference(target);
- ISubSystemConfiguration ssf = SubSystemHelpers.getParentSubSystemConfiguration(ref.getReferencedFilter());
- if (value.equals("true")) //$NON-NLS-1$
- return ssf.showChangeFilterStringsPropertyPage(ref.getReferencedFilter());
- else
- return !ssf.showChangeFilterStringsPropertyPage(ref.getReferencedFilter());
- }
- else
- return super.testAttribute(target, name, value);
- }
-
- // Property sheet descriptors defining all the properties we expose in the Property Sheet
- /**
- * Return our unique property descriptors
- */
- protected IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- int nbrOfProperties = 4;
- propertyDescriptorArray = new PropertyDescriptor[nbrOfProperties];
- int idx = 0;
- // parent filter pool
- propertyDescriptorArray[idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
- // parent filter
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTER, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
- // number filter strings
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILTERSTRINGS_COUNT, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP);
- // Related connection
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_CONNECTION_PRIVATE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_TOOLTIP);
- }
- return propertyDescriptorArray;
- }
- /**
- * Return our unique property values
- */
- protected Object internalGetPropertyValue(Object key)
- {
- String name = (String) key;
- ISystemFilter filter = getFilter(propertySourceInput);
- if (name.equals(ISystemPropertyConstants.P_FILTERSTRINGS_COUNT))
- {
- int nbrFilterStrings = filter.getFilterStringCount();
- return Integer.toString(nbrFilterStrings);
- }
- else if (name.equals(ISystemPropertyConstants.P_PARENT_FILTER))
- {
- ISystemFilter parent = filter.getParentFilter();
- if (parent != null)
- return parent.getName();
- else
- return getTranslatedNotApplicable();
- }
- else if (name.equals(ISystemPropertyConstants.P_PARENT_FILTERPOOL))
- {
- ISystemFilterPool parent = filter.getParentFilterPool();
- if (parent != null)
- return parent.getName();
- else
- return getTranslatedNotApplicable();
- }
- else if (name.equals(ISystemPropertyConstants.P_IS_CONNECTION_PRIVATE))
- {
- ISystemFilterPool parent = filter.getParentFilterPool();
- return (parent.getOwningParentName()==null) ? getTranslatedNo() : getTranslatedYes();
- }
- else
- return null;
- }
-
- // FOR COMMON DELETE ACTIONS
- /**
- * Return true if this object is deletable by the user. If so, when selected,
- * the Edit->Delete menu item will be enabled.
- */
- public boolean canDelete(Object element)
- {
- ISystemFilter filter = getFilter(element);
- return !filter.isNonDeletable(); // defect 43190
- //return true;
- }
-
- /**
- * Perform the delete action.
- * This physically deletes the filter pool and all references.
- */
- public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception
- {
- ISystemFilter filter = getFilter(element);
- ISystemFilterPoolManager fpMgr = filter.getSystemFilterPoolManager();
- fpMgr.deleteSystemFilter(filter);
- return true;
- }
-
- // FOR COMMON RENAME ACTIONS
- /**
- * Return true if this object is renamable by the user. If so, when selected,
- * the Rename menu item will be enabled.
- */
- public boolean canRename(Object element)
- {
- ISystemFilter filter = getFilter(element);
- return !filter.isNonRenamable(); // defect 43190
- //return true;
- }
-
- /**
- * Perform the rename action. Assumes uniqueness checking was done already.
- */
- public boolean doRename(Shell shell, Object element, String name, IProgressMonitor monitor) throws Exception
- {
- ISystemFilter filter = getFilter(element);
- ISystemFilterPoolManager fpMgr = filter.getSystemFilterPoolManager();
- fpMgr.renameSystemFilter(filter, name);
- return true;
- }
-
- /**
- * Return a validator for verifying the new name is correct.
- * @param element either a filter for a rename action, or a filter pool for a "new" action.
- */
- public ISystemValidator getNameValidator(Object element) {
- ISystemFilter filter = null;
- ISystemFilterPool pool = null;
- String[] filterNames = null;
- if (element instanceof ISystemFilterReference) {
- filter = getFilter(element);
- pool = filter.getParentFilterPool();
- if (pool != null)
- filterNames = pool.getSystemFilterNames();
- else {
- ISystemFilter parentFilter = filter.getParentFilter();
- filterNames = parentFilter.getSystemFilterNames();
- }
- } else if (element instanceof ISystemFilter) {
- filter = (ISystemFilter) element;
- pool = filter.getParentFilterPool();
- if (pool != null)
- filterNames = pool.getSystemFilterNames();
- else {
- ISystemFilter parentFilter = filter.getParentFilter();
- filterNames = parentFilter.getSystemFilterNames();
- }
- } else {
- pool = (ISystemFilterPool) element;
- filterNames = pool.getSystemFilterNames();
- }
- ISystemValidator nameValidator = new ValidatorFilterName(filterNames);
- return nameValidator;
- }
-
- /**
- * Parent override.
- * <p>
- * Form and return a new canonical (unique) name for this object, given a candidate for the new
- * name. This is called by the generic multi-rename dialog to test that all new names are unique.
- * To do this right, sometimes more than the raw name itself is required to do uniqueness checking.
- * <p>
- * Returns mgrName.poolName.filterName, upperCased
- */
- public String getCanonicalNewName(Object element, String newName)
- {
- ISystemFilterReference fRef = (ISystemFilterReference) element;
- ISystemFilter filter = fRef.getReferencedFilter();
- String mgrName = filter.getSystemFilterPoolManager().getName();
- return (mgrName + "." + filter.getParentFilterPool().getName() + "." + newName).toUpperCase(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Don't show "Open in new perspective" if this is promptable
- */
- public boolean showOpenViewActions(Object element)
- {
- ISystemFilter filter = getFilter(element);
- ISubSystemConfiguration ssParentFactory = getSubSystemConfiguration(filter);
- return !filter.isPromptable() && !ssParentFactory.supportsCommands();
- }
-
-
- /**
- * Don't show generic "Show in Table" if the factory asks not to
- */
- public boolean showGenericShowInTableAction(Object element)
- {
- ISystemFilter filter = getFilter(element);
- ISubSystemConfiguration ssParentFactory = getSubSystemConfiguration(filter);
- return ssParentFactory.showGenericShowInTableOnFilter() && !filter.isPromptable() && !ssParentFactory.supportsCommands();
- }
-
- /**
- * Return true if we should show the refresh action in the popup for the element.
- */
- public boolean showRefresh(Object element)
- {
- ISystemFilter filter = getFilter(element);
- ISubSystemConfiguration ssParentFactory = getSubSystemConfiguration(filter);
- return ssParentFactory.showRefreshOnFilter() && !filter.isPromptable() && !ssParentFactory.supportsCommands();
- }
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
-
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- * This just defaults to getName, but if that is not sufficient override it here.
- */
- public String getMementoHandle(Object element)
- {
- ISystemFilterReference fRef = getFilterReference(element);
- ISystemFilter referencedFilter = fRef.getReferencedFilter();
- ISystemFilterPool pool = referencedFilter.getParentFilterPool();
- String handle = pool.getReferenceName() + "="; //$NON-NLS-1$
- ISystemFilter parentFilter = referencedFilter.getParentFilter();
- while (parentFilter != null)
- {
- handle += parentFilter.getName() + ";"; //$NON-NLS-1$
- parentFilter = parentFilter.getParentFilter();
- }
- handle += referencedFilter.getName();
- return handle;
- }
- /**
- * Return what to save to disk to identify this element when it is the input object to a secondary
- * Remote System Explorer perspective.
- */
- public String getInputMementoHandle(Object element)
- {
- Object parent = ((ISystemFilterReference) element).getParent(); //getParent(element); // will be filter (nested) or filter pool
- ISystemViewElementAdapter parentAdapter = SystemAdapterHelpers.getViewAdapter(parent, getViewer());
- boolean showFPs = SystemPreferencesManager.getShowFilterPools();
- if (parent instanceof ISystemFilterPoolReference) // not a nested filter
- {
- if (!showFPs) // not showing the real parent in GUI?
- {
- parent = parentAdapter.getParent(parent); // get the subsystem parent of the filter pool reference
- parentAdapter = SystemAdapterHelpers.getViewAdapter(parent, getViewer()); // get the adapter for the subsystem parent
- }
- }
- return parentAdapter.getInputMementoHandle(parent) + MEMENTO_DELIM + getMementoHandle(element);
- }
-
- /**
- * Return a short string to uniquely identify the type of resource. Eg "conn" for connection.
- * This just defaults to getType, but if that is not sufficient override it here, since that is
- * a translated string.
- */
- public String getMementoHandleKey(Object element)
- {
- return ISystemMementoConstants.MEMENTO_KEY_FILTERREFERENCE;
- }
-
- /**
- * Somtimes we don't want to remember an element's expansion state, such as for temporarily inserted
- * messages. In these cases return false from this method. The default is true.
- * <p>
- * WE RETURN FALSE IF THIS IS A PROMPTABLE FILTER, COMMAND FILTER OR JOB FILTER.
- */
- public boolean saveExpansionState(Object element)
- {
- boolean savable = true;
- ISystemFilterReference fRef = getFilterReference(element);
- ISystemFilter referencedFilter = fRef.getReferencedFilter();
- boolean promptable = referencedFilter.isPromptable();
- if (promptable)
- savable = false;
- else
- {
- // I thought the types would be set for these filters, but it isn't! Phil.
- /*
- String type = referencedFilter.getType();
- if ((type!=null) && (type.equals("Command") || type.equals("Job")))
- savable = false;
- */
- if (isCommandFilter(referencedFilter))
- savable = false;
- }
- return savable;
- }
-
- /**
- * Return true if the given filter is from a command subsystem
- */
- public static boolean isCommandFilter(ISystemFilter filter)
- {
- ISubSystemConfiguration ssf = (ISubSystemConfiguration) filter.getProvider();
- return ssf.supportsCommands();
- }
-
- // ------------------------------------------
- // METHODS TO SUPPORT COMMON DRAG AND DROP FUNCTION...
- // ------------------------------------------
- /**
- * drag support is handled directly for filter references, rather than delegated here.
- */
- public boolean canDrag(Object element)
- {
- ISystemFilterReference fRef = getFilterReference(element);
- if (fRef != null)
- {
- if (getSubSystemConfiguration(fRef.getReferencedFilter()).supportsFilterStringExport())
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Can this object be added as part of the filter?
- */
- public boolean canDrop(Object element)
- {
- ISystemFilterReference fRef = getFilterReference(element);
- if (fRef != null)
- {
- ISubSystemConfiguration factory = getSubSystemConfiguration(fRef.getReferencedFilter());
- if (factory.supportsDropInFilters())
- {
- // if the drop is handled by the subsystem rather than this adapter, this will be true.
- if (factory.providesCustomDropInFilters())
- {
- return true;
- }
-
- if (!fRef.getReferencedFilter().isNonChangable())
- {
- if (factory.supportsMultiStringFilters())
- {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- public ISystemResourceSet doDrag(SystemRemoteResourceSet set, IProgressMonitor monitor)
- {
- return set;
- }
-
- /**
- * drag support is handled directory for filter references, rather than delegated here.
- */
- public Object doDrag(Object element, boolean sameSystemType, IProgressMonitor monitor)
- {
- return element;
- }
-
- /**
- * Add the absolute name of the from object to the list of filter strings for this filter
- */
- public Object doDrop(Object from, Object to, boolean sameSystemType, boolean sameSystem, int srcType, IProgressMonitor monitor)
- {
- if (sameSystemType)
- {
- ISystemFilterReference fRef = getFilterReference(to);
- ISystemFilter filter = fRef.getReferencedFilter();
-
- if (from instanceof ISystemFilterReference)
- {
- ISystemFilter srcFilter = ((ISystemFilterReference) from).getReferencedFilter();
- String[] filterStrings = srcFilter.getFilterStrings();
- for (int i = 0; i < filterStrings.length; i++)
- {
- filter.addFilterString(filterStrings[i]);
- }
- return fRef;
- }
- else if (from instanceof IAdaptable)
- {
- ISystemRemoteElementAdapter radapter = (ISystemRemoteElementAdapter) ((IAdaptable) from).getAdapter(ISystemRemoteElementAdapter.class);
-
- {
-
- String newFilterStr = radapter.getFilterStringFor(from);
- if (newFilterStr != null)
- {
- filter.addFilterString(newFilterStr);
- return fRef;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Validate that the source and target for the drag and drop operation are
- * compatable.
- */
- public boolean validateDrop(Object src, Object target, boolean sameSystem)
- {
- if (!sameSystem)
- {
- if (src instanceof IResource)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- if (target instanceof ISystemFilterReference)
- {
- ISystemFilterReference filterRef = (ISystemFilterReference) target;
- if (getSubSystemConfiguration(filterRef.getReferencedFilter()).supportsMultiStringFilters())
- {
- if (src instanceof ISystemFilterReference)
- {
- // yantzi: wswb2.1.2 (defect 50994) add check for filter types
- String srcType = ((ISystemFilterReference)src).getReferencedFilter().getType();
- String targetType = filterRef.getReferencedFilter().getType();
- if (targetType != null && srcType != null)
- {
- if (targetType.equals(srcType))
- {
- return true;
- }
- }
- else
- {
- return true;
- }
- }
- // check if src has a filter string
- else if (src instanceof IAdaptable)
- {
- ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter) ((IAdaptable) src).getAdapter(ISystemRemoteElementAdapter.class);
- if (adapter != null)
- {
- if (adapter.getFilterStringFor(src) != null)
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
-
- /*
- * Return whether deferred queries are supported.
- * Defer to the subsystem configuration.
- */
- public boolean supportsDeferredQueries(ISubSystem subSys)
- {
- return subSys.getSubSystemConfiguration().supportsDeferredQueries();
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterStringAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterStringAdapter.java
deleted file mode 100644
index d6b170e2d..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterStringAdapter.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * David Dykstal (IBM) - [226761] fix NPE in team view when expanding items
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
-import org.eclipse.rse.core.filters.ISystemFilterString;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ISystemPropertyConstants;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-
-/**
- * Default Adapter for displaying filter string objects in tree views.
- */
-public class SystemViewFilterStringAdapter extends AbstractSystemViewAdapter
-{
- //private static String translatedFilterString = null;
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given filter object.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- //if (selection.size() != 1)
- // return; // does not make sense adding unique actions per multi-selection
- ISystemFilterString filterString = getFilterString(selection.getFirstElement());
- if (filterString.getParentSystemFilter().isTransient())
- return;
- }
-
- private ISystemFilterString getFilterString(Object element)
- {
- return (ISystemFilterString)element;
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- * @return the desired image descriptor
- */
- public ImageDescriptor getImageDescriptor(Object element) {
- ImageDescriptor filterImage = null;
- ISystemFilterString filterString = getFilterString(element);
- if (filterString.getProvider() != null) {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) filterString.getProvider().getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- filterImage = adapter.getSystemFilterStringImage(filterString);
- }
- }
- if (filterImage == null) {
- filterImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERSTRING_ID);
- }
- return filterImage;
- }
-
- /**
- * Return the label for this object. Calls getName on the filter
- */
- public String getText(Object element)
- {
- return getFilterString(element).getString();
- }
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- return getFilterString(element).getString();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- ISystemFilterString filterString = getFilterString(element);
- ISystemFilter filter = filterString.getParentSystemFilter();
- return filter.getSystemFilterPoolManager().getName() + "." + filter.getParentFilterPool().getName() + "." + filter.getName() + "." + filterString.getString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- //SystemFilterString filterString = getFilterString(element);
- //if (filterString.getParentSystemFilter().isTransient())
- return SystemResources.RESID_PP_FILTERSTRING_TYPE_VALUE;
- //SubSystemConfiguration ssParentFactory = SubSystemHelpers.getParentSubSystemConfiguration(filterString.getParentSystemFilter());
- //return ssParentFactory.getTranslatedFilterStringTypeProperty(filterString);
- }
-
- /**
- * Return the parent of this object.
- * This will be either a SubSystem object, or a filter object.
- */
- public Object getParent(Object element)
- {
- ISystemFilterString filterString = getFilterString(element);
- return filterString.getParentSystemFilter();
- }
-
- /**
- * Return the children of this filter.
- * This returns an empty list.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- return null;
- }
-
-
- /**
- * Return true if this object has children. We return false;
- */
- public boolean hasChildren(IAdaptable element)
- {
- return false;
- }
-
- /**
- * Return our unique property descriptors
- */
- protected IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- propertyDescriptorArray = new PropertyDescriptor[3];
- // parent filter pool
- propertyDescriptorArray[0] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL,SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
- // parent filter
- propertyDescriptorArray[1] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTER,SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
- // filter string
- propertyDescriptorArray[2] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILTERSTRING,SystemViewResources.RESID_PROPERTY_FILTERSTRING_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRING_TOOLTIP);
- }
- return propertyDescriptorArray;
- }
- /**
- * Returns the current value for the named property.
- * The parent handles P_TEXT and P_TYPE only, and we augment that here.
- * @param key the name of the property as named by its property descriptor
- * @return the current value of the property
- */
- protected Object internalGetPropertyValue(Object key)
- {
- String name = (String)key;
- ISystemFilterString filterString = getFilterString(propertySourceInput);
-
- if (name.equals(ISystemPropertyConstants.P_FILTERSTRING))
- {
- return filterString.getString();
- }
- else if (name.equals(ISystemPropertyConstants.P_PARENT_FILTER))
- {
- return filterString.getParentSystemFilter().getName();
- }
- else if (name.equals(ISystemPropertyConstants.P_PARENT_FILTERPOOL))
- {
- if (filterString.getParentSystemFilter().isTransient())
- return getTranslatedNotApplicable();
- ISystemFilterPool parent = filterString.getParentSystemFilter().getParentFilterPool();
- if (parent != null)
- return parent.getName();
- else
- return null;
- }
- else
- return null;
- }
-
- // FOR COMMON DELETE ACTIONS
- public boolean showDelete(Object element)
- {
- return !getFilterString(element).getParentSystemFilter().isTransient();
- }
- /**
- * Return true if this object is deletable by the user. If so, when selected,
- * the Edit->Delete menu item will be enabled.
- */
- public boolean canDelete(Object element)
- {
- return true;
- }
-
- /**
- * Perform the delete action.
- */
- public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception {
- ISystemFilterString filterString = getFilterString(element);
- ISystemFilter filter = filterString.getParentSystemFilter();
- ISystemFilterPoolManager fpMgr = filterString.getSystemFilterPoolManager();
- String[] oldStrings = filter.getFilterStrings();
- List workingStrings = new ArrayList(oldStrings.length);
- for (int i = 0; i < oldStrings.length; i++) {
- String oldString = oldStrings[i];
- if (!filterString.equals(oldStrings[i])) {
- workingStrings.add(oldString);
- }
- }
- String[] newStrings = new String[workingStrings.size()];
- workingStrings.toArray(newStrings);
- fpMgr.updateSystemFilter(filter, filter.getName(), newStrings);
- return true;
- }
-
- // FOR COMMON RENAME ACTIONS
- public boolean showRename(Object element)
- {
- //return !getFilterString(element).getParentSystemFilter().isTransient();
- return false;
- }
-
- /**
- * Return true if this object is renamable by the user. If so, when selected,
- * the Rename popup menu item will be enabled.
- */
- public boolean canRename(Object element)
- {
- return false; //true;
- }
- /**
- * Perform the rename action.
- */
- public boolean doRename(Shell shell, Object element, String name, IProgressMonitor monitor) throws Exception
- {
- return true;
- }
-
- // FOR COMMON REFRESH ACTIONS
- public boolean showRefresh(Object element)
- {
- return false;
- }
-
- /**
- * Return true if we should show the refresh action in the popup for the given element.
- */
- public boolean showOpenViewActions(Object element)
- {
- return false;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewForm.java
deleted file mode 100644
index 09d9ab559..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewForm.java
+++ /dev/null
@@ -1,542 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Kevin Doyle (IBM) - [187553] - Removed code and related methods for toolbar/button bar.
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * David McKnight (IBM) - [187711] select SystemView APIs exposed by the ISystemTree interface
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- *******************************************************************************/
-package org.eclipse.rse.internal.ui.view;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.view.ISystemLongRunningRequestListener;
-import org.eclipse.rse.ui.view.ISystemTree;
-import org.eclipse.rse.ui.view.SystemLongRunningRequestEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-
-
-/**
- * This re-usable widget is for a single widget that displays a
- * toolbar underneath which is a systems view tree.
- */
-public class SystemViewForm extends Composite implements ISystemTree
-{
- private ToolBar toolbar = null;
- private ToolBarManager toolbarMgr = null;
- private Button refreshButton, getListButton;
- private SystemView tree = null;
- private ISystemMessageLine msgLine = null;
- private boolean showActions = true;
- private boolean deferLoading = false;
- private boolean requestInProgress = false;
- private ISystemViewInputProvider inputProvider = null;
- private ISystemViewInputProvider emptyProvider = new SystemEmptyListAPIProviderImpl();
- private Vector requestListeners = null;
- public static final int DEFAULT_WIDTH = 300;
- public static final int DEFAULT_HEIGHT = 300;
-
- // the following allows us to identify dialog/wizard hosting this widget so we can
- // disable it's close capability while a remote request is in place.
- protected Object caller;
- protected boolean callerInstanceOfWizardPage, callerInstanceOfSystemPromptDialog;
-
- // viewer filters
- protected ViewerFilter[] initViewerFilters = null;
-
- /**
- * Constructor
- * @param shell The owning window
- * @param parent The owning composite
- * @param style The swt style to apply to the overall composite. Typically SWT.NULL
- * @param inputProvider Who is supplying the roots for the system viewer?
- * @param singleSelectionMode Are users allowed to select multiple things at once?
- * @param msgLine where to show messages and tooltip text
- */
- public SystemViewForm(Shell shell, Composite parent, int style, ISystemViewInputProvider inputProvider,
- boolean singleSelectionMode, ISystemMessageLine msgLine)
- {
- this(shell, parent, style, inputProvider, singleSelectionMode, msgLine, 1, 1);
- }
- /**
- * Constructor when you want to span more than one column or row
- * @param shell The owning window
- * @param parent The owning composite
- * @param style The swt style to apply to the overall composite. Typically SWT.NULL
- * @param inputProvider Who is supplying the roots for the system viewer?
- * @param singleSelectionMode Are users allowed to select multiple things at once?
- * @param msgLine where to show messages and tooltip text
- * @param horizontalSpan how many columns in parent composite to span
- * @param verticalSpan how many rows in parent composite to span
- */
- public SystemViewForm(Shell shell, Composite parent, int style, ISystemViewInputProvider inputProvider,
- boolean singleSelectionMode, ISystemMessageLine msgLine,
- int horizontalSpan, int verticalSpan)
- {
- this(shell, parent, style, inputProvider, singleSelectionMode, msgLine, horizontalSpan, verticalSpan, null);
- }
-
- /**
- * Constructor when you want to span more than one column or row
- * @param shell The owning window
- * @param parent The owning composite
- * @param style The swt style to apply to the overall composite. Typically SWT.NULL
- * @param inputProvider Who is supplying the roots for the system viewer?
- * @param singleSelectionMode Are users allowed to select multiple things at once?
- * @param msgLine where to show messages and tooltip text
- * @param horizontalSpan how many columns in parent composite to span
- * @param verticalSpan how many rows in parent composite to span
- * @param initViewerFilters the initial viewer filters to apply.
- */
- public SystemViewForm(Shell shell, Composite parent, int style, ISystemViewInputProvider inputProvider,
- boolean singleSelectionMode, ISystemMessageLine msgLine,
- int horizontalSpan, int verticalSpan, ViewerFilter[] initViewerFilters)
- {
- super(parent, style);
- this.inputProvider = inputProvider;
- this.msgLine = msgLine;
- callerInstanceOfWizardPage = (caller instanceof WizardPage);
- callerInstanceOfSystemPromptDialog = (caller instanceof SystemPromptDialog);
- prepareComposite(1, horizontalSpan, verticalSpan);
-
- // set viewer filters
- this.initViewerFilters = initViewerFilters;
-
- createSystemView(shell, inputProvider, singleSelectionMode);
-
- }
-
- /**
- * Return the toolbar widget manager
- */
- public ToolBarManager getToolBarManager()
- {
- return toolbarMgr;
- }
- /**
- * Return the system view tree viewer
- */
- public ISystemTree getSystemTree()
- {
- return tree;
- }
- /**
- * Return the system view tree viewer tree widget
- */
- public Tree getTreeControl()
- {
- return tree.getTree();
- }
-
- /**
- * Set the tree's tooltip text
- */
- public void setToolTipText(String tip)
- {
- tree.getTree().setToolTipText(tip);
- }
-
- /**
- * Refresh contents
- */
- public void refresh()
- {
- tree.refreshAll();
- }
-
- /**
- * Reset contents
- */
- public void reset(ISystemViewInputProvider inputProvider)
- {
- this.inputProvider = inputProvider;
- if (deferLoading)
- {
- tree.setSelection(null);
- tree.setInputProvider(emptyProvider);
- }
- else
- {
- tree.setSelection(null);
- tree.setInputProvider(inputProvider);
- }
- }
-
- /*
- * Turn off right-click actions
- *
- NOW SET VIA INPUT PROVIDER METHODS
- public void setShowActions(boolean show)
- {
- this.showActions = show;
- if (tree != null)
- tree.setShowActions(show);
- }*/
-
- /**
- * Disable/Enable all the child controls.
- */
- public void setEnabled(boolean enabled)
- {
- if (toolbar != null)
- toolbar.setEnabled(enabled);
- tree.setEnabled(enabled);
- //if ((tree != null) && (tree.getTree() != null))
- // tree.getTree().setEnabled(enabled);
- //super.setEnabled(enabled);
- }
- /**
- * Register a listener interested in an item is selected in the system view
- * @see #removeSelectionChangedListener(ISelectionChangedListener)
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener)
- {
- tree.addSelectionChangedListener(listener);
- }
- /**
- * Remove a previously set system view selection listener.
- * @see #addSelectionChangedListener(ISelectionChangedListener)
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener)
- {
- tree.removeSelectionChangedListener(listener);
- }
- /**
- * Add a listener that is informed when a remote list request starts and stops.
- * This allows for the listener to do things like disable the Close button
- */
- public void addListRequestListener(ISystemLongRunningRequestListener listener)
- {
- if (requestListeners == null)
- requestListeners = new Vector();
- requestListeners.addElement(listener);
- }
- /**
- * Add a listener that is informed when a remote list request starts and stops.
- * This allows for the listener to do things like disable the Close button
- */
- public void removeListRequestListener(ISystemLongRunningRequestListener listener)
- {
- if (requestListeners != null)
- requestListeners.removeElement(listener);
- }
-
- /**
- * Return the selection of the tree viewer
- */
- public ISelection getSelection()
- {
- return tree.getSelection();
- }
-
-
- // --------------------------------------------
- // ISystemTree methods to facilitate our GUI...
- // ... all these are delegated to the SystemView tree
- // --------------------------------------------
- /**
- * Returns true if any of the selected items are currently expanded
- */
- public boolean areAnySelectedItemsExpanded()
- {
- return tree.areAnySelectedItemsExpanded();
- }
- /**
- * Returns true if any of the selected items are expandable but not yet expanded
- */
- public boolean areAnySelectedItemsExpandable()
- {
- return tree.areAnySelectedItemsExpandable();
- }
- /**
- * 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.
- * <p>
- * Designed to be as fast as possible by going directly to the SWT widgets
- */
- public boolean sameParent()
- {
- return tree.sameParent();
- }
- /**
- * This is called to accurately get the parent object for the current selection
- * for this viewer.
- * <p>
- * 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.
- */
- public Object getSelectedParent()
- {
- return tree.getSelectedParent();
- }
- /**
- * This returns the element immediately before the first selected element in this tree level.
- * Often needed for enablement decisions for move up actions.
- */
- public Object getPreviousElement()
- {
- return tree.getPreviousElement();
- }
- /**
- * This returns the element immediately after the last selected element in this tree level
- * Often needed for enablement decisions for move down actions.
- */
- public Object getNextElement()
- {
- return tree.getNextElement();
- }
-
- /**
- * This is called to walk the tree back up to the roots and return the visible root
- * node for the first selected object.
- */
- public Object getRootParent()
- {
- return tree.getRootParent();
- }
- /**
- * This returns an array containing each element in the tree, up to but not including the root.
- * The array is in reverse order, starting at the leaf and going up.
- */
- public Object[] getElementNodes(Object element)
- {
- return tree.getElementNodes(element);
- }
- /**
- * Helper method to determine if a given object is currently selected.
- * Does consider if a child node of the given object is currently selected.
- */
- public boolean isSelectedOrChildSelected(Object parentElement)
- {
- return tree.isSelectedOrChildSelected(parentElement);
- }
-
- /**
- * Return the number of immediate children in the tree, for the given tree node
- */
- public int getChildCount(Object element)
- {
- return tree.getChildCount(element);
- }
-
- /**
- * Called when a property is updated and we need to inform the Property Sheet viewer.
- * There is no formal mechanism for this so we simulate a selection changed event as
- * this is the only event the property sheet listens for.
- */
- public void updatePropertySheet()
- {
- tree.updatePropertySheet();
- }
-
- /**
- * Called to select an object within the tree, and optionally expand it
- */
- public void select(Object element, boolean expand)
- {
- tree.select(element, expand);
- }
-
- /**
- * Returns the tree item of the first selected object. Used for setViewerItem in a resource
- * change event.
- */
- public Item getViewerItem()
- {
- return tree.getViewerItem();
- }
-
- /**
- * Returns true if it is ok to close the dialog or wizard page. Returns false if there
- * is a remote request currently in progress.
- */
- public boolean okToClose()
- {
- return !requestInProgress; //d43433
- }
-
- // -----------------------
- // INTERNAL-USE METHODS...
- // -----------------------
- /**
- * Prepares this composite control and sets the default layout data.
- * @param Number of columns the new group will contain.
- */
- protected Composite prepareComposite(int numColumns,
- int horizontalSpan, int verticalSpan)
- {
- Composite composite = this;
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- composite.setLayout(layout);
- //GridData
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- data.widthHint = DEFAULT_WIDTH;
- data.heightHint = DEFAULT_HEIGHT;
- data.horizontalSpan = horizontalSpan;
- data.verticalSpan = verticalSpan;
- composite.setLayoutData(data);
- return composite;
- }
-
- protected void createSystemView(Shell shell, ISystemViewInputProvider inputProvider, boolean singleSelectionMode)
- {
- // TREE
- int style = (singleSelectionMode ? SWT.SINGLE : SWT.MULTI) | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
- tree = new SystemView(shell, this, style, deferLoading ? emptyProvider : inputProvider, msgLine, initViewerFilters);
- GridData treeData = new GridData();
- treeData.horizontalAlignment = GridData.FILL;
- treeData.verticalAlignment = GridData.FILL;
- treeData.grabExcessHorizontalSpace = true;
- treeData.grabExcessVerticalSpace = true;
- treeData.widthHint = 300;
- treeData.heightHint= 200;
- tree.getTree().setLayoutData(treeData);
- tree.setShowActions(showActions);
- }
-
- protected void addOurMouseListener()
- {
- MouseListener mouseListener = new MouseAdapter()
- {
- public void mouseDown(MouseEvent e)
- {
- //requestActivation();
- }
- };
- toolbar.addMouseListener(mouseListener);
- }
-
- /**
- * Fire long running request listener event
- */
- protected void fireRequestStartEvent()
- {
- if (requestListeners != null)
- {
- SystemLongRunningRequestEvent event = new SystemLongRunningRequestEvent();
- for (int idx=0; idx<requestListeners.size(); idx++)
- ((ISystemLongRunningRequestListener)requestListeners.elementAt(idx)).startingLongRunningRequest(event);
- }
- }
-
- /**
- * Fire long running request listener event
- */
- protected void fireRequestStopEvent()
- {
- if (requestListeners != null)
- {
- SystemLongRunningRequestEvent event = new SystemLongRunningRequestEvent();
- for (int idx=0; idx<requestListeners.size(); idx++)
- ((ISystemLongRunningRequestListener)requestListeners.elementAt(idx)).endingLongRunningRequest(event);
- }
- }
-
-
-
- /**
- * wrapper method to satisfy the ISystemTree interface
- */
- public void createTreeItems(TreeItem widget, Object[] children)
- {
- tree.createTreeItems(widget, children);
- }
-
- /**
- * wrapper method to satisfy the ISystemTree interface
- */
- public List findAllRemoteItemReferences(Object element,
- Object elementObject, List matches) {
- return tree.findAllRemoteItemReferences(element, elementObject, matches);
- }
-
- /**
- * wrapper method to satisfy the ISystemTree interface
- */
- public Item findFirstRemoteItemReference(Object remoteObject,
- Item parentItem) {
- return tree.findFirstRemoteItemReference(remoteObject, parentItem);
- }
-
- /**
- * wrapper method to satisfy the ISystemTree interface
- */
- public Tree getTree() {
- return tree.getTree();
- }
-
- /**
- * wrapper method to satisfy the ISystemTree interface
- */
- public ISystemFilterReference revealAndExpand(ISubSystem parentSubSystem,
- ISystemFilter filter) {
- return tree.revealAndExpand(parentSubSystem, filter);
- }
- public void addDoubleClickListener(IDoubleClickListener listener) {
- tree.addDoubleClickListener(listener);
- }
- public void addFilter(ViewerFilter filter) {
- tree.addFilter(filter);
-
- }
- public void expandTo(Object parentObject, Object remoteObject) {
- tree.expandTo(parentObject, remoteObject);
-
- }
- public void expandTo(String filterString) {
- tree.expandTo(filterString);
-
- }
- public boolean isExpandable(Object elementOrTreePath) {
- return tree.isExpandable(elementOrTreePath);
- }
- public void setAutoExpandLevel(int level) {
- tree.setAutoExpandLevel(level);
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewLabelAndContentProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewLabelAndContentProvider.java
deleted file mode 100644
index e54897537..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewLabelAndContentProvider.java
+++ /dev/null
@@ -1,498 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2006, 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * Martin Oberhuber (Wind River) - [197550] Fix NPE when refreshing Pending items
- * David McKnight (IBM) - [236505] Remote systems dialog not working
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-
-import java.util.Hashtable;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.model.SystemMessageObject;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.internal.ui.RSEImageMap;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.operations.SystemDeferredTreeContentManager;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.progress.PendingUpdateAdapter;
-
-
-/**
- * Provides tree contents for objects that have the ISystemViewElement
- * adapter registered. Also provides label contents, so can be used for
- * both a content and label provider for TreeViewers.
- * <p>
- * This has a general flavor, which is used in most cases, and also has
- * a specialized flavor for universal file systems, which allows restricting
- * the list to files only or folders only. It also allows further subsetting by
- * setting an input filter or filter string.
- */
-public class SystemViewLabelAndContentProvider extends LabelProvider
- implements ITreeContentProvider, ILabelProvider, ITableLabelProvider
- // ,IResourceChangeListener
-{
- private static final Object[] NO_OBJECTS = new Object[0];
-
- protected Viewer viewer;
- private boolean filesOnly, foldersOnly;
- private String filterString = null;
- private Hashtable resolvedChildrenPerFolder = null; // local cache to improve performance
- private boolean _enableDeferredQueries = true;
- private SystemDeferredTreeContentManager manager;
-
- /**
- * Constructor
- */
- public SystemViewLabelAndContentProvider()
- {
- // System.out.println("inside ctor for LCProvider " + this);
- }
- /**
- * Constructor to restrict to remote folders or files
- */
- public SystemViewLabelAndContentProvider(boolean foldersOnly, boolean filesOnly)
- {
- this();
- this.foldersOnly = foldersOnly;
- this.filesOnly = filesOnly;
- }
- /**
- * Set a filter string to subset the list by. For example, "A*.java" or "java,class,"
- * Only valid if filesOnly or foldersOnly mode. If the latter, its recorded and used
- * the next time files are requested from any folder.
- */
- public void setFilterString(String filterString)
- {
- this.filterString = filterString;
-
- flushCache();
- }
- /**
- * Get the current filter string being used to subset the list by.
- * Will be null unless setFilterString has previously been called.
- */
- public String getFilterString()
- {
- return filterString;
- }
-
-
-
- /**
- * Flush the in-memory cache which remembers the result of the last
- * getChildren request when we are in files-only or folders-only
- * mode. Only applies when the two-boolean constructor is used.
- */
- public void flushCache()
- {
- resolvedChildrenPerFolder = null;
- }
-
- /**
- * Return the current viewer we are associated with
- */
- public Viewer getViewer()
- {
- return viewer;
- }
-
- /**
- * The visual part that is using this content provider is about
- * to be disposed. Deallocate all allocated SWT resources.
- */
- public void dispose()
- {
- // AS LONG AS WE DON'T SUPPORT IWORKSPACE OBJECT THIS IS NOT NEEDED.
- // WE LEAVE IT IN BECAUSE IT IS HARMLESS AND MIGHT BE OF VALUE SOMEDAY.
- if (viewer != null)
- {
- Object obj = viewer.getInput();
- if (obj != null)
- {
- if (obj instanceof IWorkspace)
- {
- //IWorkspace workspace = (IWorkspace) obj;
- //workspace.removeResourceChangeListener(this);
- }
- else if (obj instanceof IContainer)
- {
- //IWorkspace workspace = ((IContainer) obj).getWorkspace();
- //workspace.removeResourceChangeListener(this);
- }
- }
- }
- }
-
-
- /**
- * Returns the implementation of ISystemViewElement for the given
- * object. Returns null if the adapter is not defined or the
- * object is not adaptable.
- */
- protected ISystemViewElementAdapter getViewAdapter(Object o)
- {
- if (o instanceof IContextObject)
- {
- o = ((IContextObject)o).getModelObject();
- }
- ISystemViewElementAdapter adapter = null;
- if (o == null)
- {
- SystemBasePlugin.logWarning("ERROR: null passed to getAdapter in SystemViewLabelAndContentProvider"); //$NON-NLS-1$
- }
- else
- {
- if (o instanceof IAdaptable)
- {
- adapter = (ISystemViewElementAdapter)((IAdaptable)o).getAdapter(ISystemViewElementAdapter.class);
- }
- else
- {
- adapter = (ISystemViewElementAdapter)Platform.getAdapterManager().getAdapter(o,ISystemViewElementAdapter.class);
- }
- if (adapter == null)
- {
- if (!(o instanceof PendingUpdateAdapter))
- {
- SystemBasePlugin.logWarning("ADAPTER IS NULL FOR ELEMENT OF TYPE: " + o.getClass().getName()); //$NON-NLS-1$
- }
- }
- }
- if ((adapter!=null) && (viewer != null))
- {
- Shell shell = null;
- if (viewer instanceof ISystemShellProvider)
- shell = ((ISystemShellProvider)viewer).getShell();
- else
- shell = viewer.getControl().getShell();
- adapter.setShell(shell);
- //System.out.println("Inside getAdapter for LCProvider "+this+", setting viewer of adapter to "+viewer);
- adapter.setViewer(viewer);
- if (viewer.getInput() instanceof ISystemViewInputProvider)
- {
- ISystemViewInputProvider inputProvider = (ISystemViewInputProvider)viewer.getInput();
- //inputProvider.setShell(shell); this is now done in the getInput() method of viewer.
- adapter.setInput(inputProvider);
- }
- }
- else if (viewer == null)
- SystemBasePlugin.logWarning("VIEWER IS NULL FOR SYSTEMVIEWLABELANDCONTENTPROVIDER"); //$NON-NLS-1$
- return adapter;
- }
-
- /**
- * Cancel any jobs that are fetching content from the given location.
- * @param location
- */
- public void cancelJobs(Object location)
- {
- if (manager != null) {
- manager.cancel(location);
- }
- }
-
- protected boolean supportsDeferredQueries()
- {
- //IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
- //return store.getBoolean(ISystemPreferencesConstants.USE_DEFERRED_QUERIES);
- //return true; // DKM now enforcing deferred queries
- return _enableDeferredQueries;
- }
-
- public void setEnableDeferredQueries(boolean enable)
- {
- _enableDeferredQueries = enable;
- }
-
-
- /**
- * @see ITreeContentProvider
- */
- public Object[] getChildren(Object object)
- {
- Object element = object;
- if (object instanceof IContextObject)
- {
- element = ((IContextObject)object).getModelObject();
- }
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (supportsDeferredQueries())
- {
- // The adapter needs to be checked to be not null, otherwise
- // we run into an NPE here.
- if (manager != null && adapter != null)
- {
- ISubSystem ss = null;
- if (object instanceof IContextObject)
- {
- ss = ((IContextObject)object).getSubSystem();
- }
- else
- {
- ss = adapter.getSubSystem(object);
- }
- if (ss != null && adapter.supportsDeferredQueries(ss))
- {
- // if (ss.isConnected())
- {
-
- Object[] children = manager.getChildren(object, getViewer());
- if (children != null)
- {
- // This will be a placeholder to indicate
- // that the real children are being fetched
- return children;
- }
- }
- }
- }
- }
-
-
- //System.out.println("inside getChildren for landcProvider");
- //System.out.println("...element = " + element);
- //System.out.println("...adapter = " + adapter);
- if (adapter != null)
- {
- // we first test to see if this is an expand-to filter in effect for this
- // object, and if so use it...
- if ((viewer instanceof SystemView) && (((SystemView)viewer).getSystemViewPart() != null) &&
- (adapter instanceof ISystemRemoteElementAdapter))
- {
- String expandToFilter = ((SystemView)viewer).getExpandToFilter(element);
- if (expandToFilter != null)
- return adapter.getChildrenUsingExpandToFilter(element, expandToFilter);
- }
- Object[] children = null;
- // The re-usable Eclipse GUI widgets are not very efficient.
- // The are always re-asking for children, which for remote requests
- // causes a lot of flashing and unnecessary trips to the host.
- // To overcome this, once we successfully resolve a request,
- // we remember the result so on the subsequent request for the
- // same files or folders, we can return that remembered cache.
- // The tricky part is what to key each request by. We use the element
- // as the key ... this is the parent folder which children are being
- // asked for. However, for the same folder we will be asked for
- // folders and files in separate requests. It turns out this is not
- // not a problem though, because a separate instance of us is used
- // for files versus folders so each maintains its own cache.
-
- if ((filesOnly || foldersOnly) && (resolvedChildrenPerFolder != null))
- {
- children = (Object[])resolvedChildrenPerFolder.get(element);
- if (children != null) // found cached list?
- return children; // return it to caller
- }
-
- if (object instanceof IContextObject)
- {
- children = adapter.getChildren((IContextObject)object, new NullProgressMonitor());
- }
- else
- {
- children = adapter.getChildren((IAdaptable)object, new NullProgressMonitor());
- }
-
-
- if ((filesOnly || foldersOnly) &&
- // an array of one SystemMessageObject item implies some kind of error, so don't cache...
- ((children.length != 1) || !(children[0] instanceof SystemMessageObject)) )
- {
- if (resolvedChildrenPerFolder == null)
- resolvedChildrenPerFolder = new Hashtable();
- resolvedChildrenPerFolder.put(element, children);
- }
-
- return children;
- }
- return NO_OBJECTS;
- }
- /**
- * @see ITreeContentProvider
- */
- public Object[] getElements(Object element)
- {
- return getChildren(element);
- }
- /**
- * @see ITreeContentProvider
- */
- public Object getParent(Object element)
- {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (adapter != null)
- return adapter.getParent(element);
- return null;
- }
- /**
- * hasChildren method comment.
- * This method has been optimized over its original code so
- * that we don't actually retrieve all the children (horrors!)
- * just to decide if it has children. For performance reasons we
- * just assume if it can have children it does. That means we always
- * get a plus but that is way better than a very slow remote
- * system query just to decide if we want a plus or not!
- */
- public boolean hasChildren(Object element)
- {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (adapter!=null) {
- if (element instanceof IContextObject)
- {
- return adapter.hasChildren((IContextObject)element);
- }
- else
- {
- return adapter.hasChildren((IAdaptable)element);
- }
- }
- else
- {
- if (element instanceof IContextObject) {
- element = ((IContextObject)element).getModelObject();
- }
- if (manager != null && manager.isDeferredAdapter(element)) {
- return manager.mayHaveChildren(element);
- }
- }
- return false;
- }
-
- /**
- * inputChanged method comment.
- * AS LONG AS WE DON'T SUPPORT IWORKSPACE OBJECT THIS IS NOT NEEDED.
- * WE LEAVE IT IN BECAUSE IT IS HARMLESS AND MIGHT BE OF VALUE SOMEDAY.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- //System.out.println("Inside LCProvider "+this+". viewer = " + viewer);
- this.viewer = viewer;
- if (newInput instanceof IWorkspace)
- {
- //IWorkspace workspace = (IWorkspace)newInput;
- //workspace.addResourceChangeListener(this);
- }
- else if (newInput instanceof IContainer)
- {
- //IWorkspace workspace = ((IContainer)newInput).getWorkspace();
- //workspace.addResourceChangeListener(this);
- }
- if (viewer instanceof AbstractTreeViewer)
- {
- manager = new SystemDeferredTreeContentManager(this, (AbstractTreeViewer) viewer);
- }
- }
-
- public Image getColumnImage(Object element, int columnIndex)
- {
- return getImage(element);
- }
- public String getColumnText(Object element, int columnIndex)
- {
- return getText(element);
- }
- public Image getImage(Object element)
- {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- //System.out.println("Inside getImage. element = " + element + ", adapter = " + adapter);
- if (adapter == null)
- return null;
-
- ImageDescriptor descriptor = adapter.getImageDescriptor(element);
-
- if (descriptor == null)
- return null;
-
- //add any annotations to the image descriptor
- descriptor = decorateImage(descriptor, element);
- //obtain the cached image corresponding to the descriptor
- Image image = RSEImageMap.get(descriptor);
- if (image == null)
- {
- image = descriptor.createImage();
- RSEImageMap.put(descriptor, image);
- }
-
- return image;
- }
- /**
- * Returns the label text for the given object.
- */
- public String getText(Object element)
- {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- //System.out.println("INSIDE GETTEXT FOR SVLandCprovider: " + element + ", adapter = " + adapter);
- if (adapter == null)
- {
- IWorkbenchAdapter wadapter = (IWorkbenchAdapter)((IAdaptable) element).getAdapter(IWorkbenchAdapter.class);
-
- if (wadapter == null)
- {
- return super.getText(element);
- }
- return wadapter.getLabel(element);
- }
- //return the decorated label (FROM WorkbenchLabelProvider)
- return decorateText(adapter.getText(element), element);
- }
-
- /**
- * Returns an image descriptor that is based on the given descriptor,
- * but decorated with additional information relating to the state
- * of the provided object.
- *
- * Subclasses may reimplement this method to decorate an object's
- * image.
- * @see org.eclipse.jface.resource.ImageDescriptor
- */
- protected ImageDescriptor decorateImage(ImageDescriptor input, Object element)
- {
- return input;
- }
- /**
- * Returns a label that is based on the given label,
- * but decorated with additional information relating to the state
- * of the provided object.
- *
- * Subclasses may implement this method to decorate an object's
- * label.
- */
- protected String decorateText(String input, Object element)
- {
- return input;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewMenuListener.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewMenuListener.java
deleted file mode 100644
index fb4a2ce7c..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewMenuListener.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.rse.internal.ui.actions.SystemSubMenuManager;
-import org.eclipse.rse.ui.Mnemonics;
-import org.eclipse.rse.ui.actions.ISystemViewMenuListener;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.swt.events.ArmEvent;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * A class that listens for menu show events for the purpose of applying mnemonics
- * to the menu items.
- */
-public class SystemViewMenuListener
-implements ISystemViewMenuListener
-{
-
-
- protected boolean menuListenerAdded = false;
- protected boolean menuMnemonicsAdded = false;
- protected boolean doOnce = false;
- protected boolean armListeners = false;
- protected Mnemonics m = new Mnemonics();
- protected ISystemMessageLine msgLine;
-
- /**
- * Default constructor
- */
- public SystemViewMenuListener()
- {
- }
- /**
- * Constructor for a persistent menu (vs a popup that's fresh each time)
- */
- public SystemViewMenuListener(boolean doOnce)
- {
- this.doOnce = doOnce;
- }
- /**
- * Enable tooltip text for the menu items too?
- * Requires a message line to display the text on.
- */
- public void setShowToolTipText(boolean set, ISystemMessageLine msgLine)
- {
- this.armListeners = set;
- this.msgLine = msgLine;
- }
-
- // ---------------------
- // IMenuListener methods
- // ---------------------
- /**
- * Called when the context menu is about to open.
- */
- public void menuAboutToShow(IMenuManager menu)
- {
- if (!menuListenerAdded)
- {
- if (menu instanceof MenuManager)
- {
- Menu m = ((MenuManager)menu).getMenu();
- if (m != null)
- {
- menuListenerAdded = true;
- m.addMenuListener(this);
- }
- }
- }
- }
-
- // --------------------
- // MenuListener methods
- // --------------------
- /**
- * Menu hidden
- */
- public void menuHidden(MenuEvent event)
- {
-
- }
- /**
- * Menu shown
- */
- public void menuShown(MenuEvent event)
- {
- if (!menuMnemonicsAdded || !doOnce)
- {
- m.clear();
- Menu menu = (Menu)event.getSource();
- m.setMnemonics(menu);
- if (armListeners) {
- setArmListener(menu);
- }
- menuMnemonicsAdded = true;
- if (doOnce)
- ((Menu)event.getSource()).removeMenuListener(this);
- }
- }
-
- private void setArmListener(Menu menu) {
- MenuItem[] items = menu.getItems();
- for (int i = 0; i < items.length; i++) {
- MenuItem menuItem = items[i];
- setArmListener(menuItem);
- }
- }
-
- private void setArmListener(MenuItem item) {
- item.addArmListener(this);
- Menu menu = item.getMenu();
- if (menu != null) {
- setArmListener(menu);
- }
- }
-
- // --------------------
- // ArmListener methods
- // --------------------
- /**
- * Menu item is currently selected by user. Try to show tooltip text.
- */
- public void widgetArmed(ArmEvent event)
- {
- if (msgLine == null)
- return;
- msgLine.clearMessage();
- Widget w = event.widget;
- //System.out.println("inside widgetArmed. w = "+w.getClass().getName());
- if (w instanceof MenuItem)
- {
- MenuItem mi = (MenuItem)w;
- Object data = mi.getData();
- //System.out.println("... data = "+data+", msgLine null? "+(msgLine==null));
- if (data != null)
- {
- String tip = null; //data.getClass().getName();
- if (data instanceof ActionContributionItem)
- tip = ((ActionContributionItem)data).getAction().getToolTipText();
- else if (data instanceof SystemSubMenuManager)
- tip = ((SystemSubMenuManager)data).getToolTipText();
- if (tip != null)
- msgLine.setMessage(tip);
- }
- }
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewMessageAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewMessageAdapter.java
deleted file mode 100644
index ddcf5cdc9..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewMessageAdapter.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.model.ISystemMessageObject;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-
-
-/**
- * Adapter for displaying temporary message objects when an expand fails or is cancelled.
- * <p>
- */
-public class SystemViewMessageAdapter
- extends AbstractSystemViewAdapter
-{
-
- /**
- * Add actions to context menu.
- * We don't add any for message objects, at this point.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- ISystemMessageObject msg = (ISystemMessageObject)element;
- int type = msg.getType();
- if (type==ISystemMessageObject.MSGTYPE_ERROR)
- return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_ERROR_ID);
- else if (type==ISystemMessageObject.MSGTYPE_CANCEL)
- return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_INFO_TREE_ID);
- // DY: icon vetoed by UCD
- // return RSEUIPlugin.getDefault().getImageDescriptor(ISystemConstants.ICON_SYSTEM_CANCEL_ID);
- else if (type==ISystemMessageObject.MSGTYPE_EMPTY)
- return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_EMPTY_ID);
- else if (type==ISystemMessageObject.MSGTYPE_OBJECTCREATED)
- return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_OK_ID);
- else
- return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_INFO_TREE_ID);
- }
-
- /**
- * Return the label for this object. Uses getMessage() on the given ISystemMessageObject object.
- */
- public String getText(Object element)
- {
- ISystemMessageObject msg = (ISystemMessageObject)element;
- return msg.getMessage();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- return getText(element);
- }
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- return SystemViewResources.RESID_PROPERTY_MESSAGE_TYPE_VALUE;
- }
-
- /**
- * Return the parent of this object.
- */
- public Object getParent(Object element)
- {
- ISystemMessageObject msg = (ISystemMessageObject)element;
- return msg.getParent();
- }
-
- /**
- * Return the children of this object. Not applicable for us.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- return null;
- }
-
- /**
- * Return true if this object has children. Always false for us.
- */
- public boolean hasChildren(IAdaptable element)
- {
- return false;
- }
- /**
- * Return our unique property descriptors
- */
- protected IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
-
- return null;
- }
- /**
- * Return our unique property values
- */
- public Object internalGetPropertyValue(Object key)
- {
- return null;
- }
- /**
- * Don't show delete
- */
- public boolean showDelete(Object element)
- {
- return false;
- }
-
- /**
- * Don't show rename
- */
- public boolean showRename(Object element)
- {
- return false;
- }
-
- /**
- * Don't show refresh
- */
- public boolean showRefresh(Object element)
- {
- return false;
- }
-
- /**
- * Don't show "Open in new perspective"
- */
- public boolean showOpenViewActions(Object element)
- {
- return false;
- }
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
-
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- * This just defaults to getName, but if that is not sufficient override it here.
- */
- public String getMementoHandle(Object element)
- {
- return getName(element);
- }
- /**
- * Return a short string to uniquely identify the type of resource. Eg "conn" for connection.
- * This just defaults to getType, but if that is not sufficient override it here, since that is
- * a translated string.
- */
- public String getMementoHandleKey(Object element)
- {
- return "Msg"; //$NON-NLS-1$
- }
-
- /**
- * Somtimes we don't want to remember an element's expansion state, such as for temporarily inserted
- * messages. In these cases return false from this method. The default is true.
- * <p>
- * WE RETURN FALSE.
- */
- public boolean saveExpansionState(Object element)
- {
- return false;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewNewConnectionPromptAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewNewConnectionPromptAdapter.java
deleted file mode 100644
index 8b84716ce..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewNewConnectionPromptAdapter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.actions.SystemRunAction;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * Adapter class for new connection prompt objects.
- */
-public class SystemViewNewConnectionPromptAdapter extends SystemViewPromptableAdapter {
-
- /**
- * @see org.eclipse.rse.internal.ui.view.SystemViewPromptableAdapter#getRunAction(org.eclipse.swt.widgets.Shell)
- */
- protected SystemRunAction getRunAction(Shell shell) {
- return (new SystemRunAction(SystemResources.ACTION_NEWCONN_LABEL, SystemResources.ACTION_NEWCONN_TOOLTIP,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWCONNECTION_ID), shell));
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPart.java
deleted file mode 100644
index 73791babd..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPart.java
+++ /dev/null
@@ -1,2053 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Kevin Doyle (IBM) - [180875] - Added double click listener that handles opening of files
- * David Dykstal (IBM) - moved SystemPreferencesManager to a new package
- * Martin Oberhuber (Wind River) - Replace SystemRegistry by ISystemRegistry
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
- * Martin Oberhuber (Wind River) - [185552] Remove remoteSystemsViewPreferencesActions extension point
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
- * Martin Oberhuber (Wind River) - [190195] Cannot enable new connection prompt in system view
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * David Dykstal (IBM) - [191311] enable global properties action
- * Martin Oberhuber (Wind River) - [196936] Hide disabled system types
- * Martin Oberhuber (Wind River) - [197025] Wait for model complete before restoring initial state
- * Martin Oberhuber (Wind River) - [197025][197167] Improved wait for model complete
- * David McKnight (IBM) - [199424] restoring memento state asynchronously
- * David McKnight (IBM) - [187711] Link with Editor handled by extension
- * David Dykstal (IBM) - [226728] NPE during init with clean workspace
- * David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
- * David Dykstal (IBM) - [216858] Need the ability to Import/Export RSE connections for sharing
- * Kevin Doyle (IBM) - [186769] Enable Contributions to Drop Down menu of Remote Systems view -> Preferences
- * David McKnight (IBM) - [244807] System view does not handle restore from cache
- * Li Ding (IBM) - [256135] Subsystem not restored in system view tree if subsystem configuration does not support filter
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemPreferenceChangeEvent;
-import org.eclipse.rse.core.events.ISystemPreferenceChangeEvents;
-import org.eclipse.rse.core.events.ISystemPreferenceChangeListener;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.filters.ISystemFilterStringReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.internal.core.RSEInitJob;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.actions.SystemCollapseAllAction;
-import org.eclipse.rse.internal.ui.actions.SystemImportConnectionAction;
-import org.eclipse.rse.internal.ui.actions.SystemPreferenceQualifyConnectionNamesAction;
-import org.eclipse.rse.internal.ui.actions.SystemPreferenceRestoreStateAction;
-import org.eclipse.rse.internal.ui.actions.SystemPreferenceShowFilterPoolsAction;
-import org.eclipse.rse.internal.ui.actions.SystemShowPreferencesPageAction;
-import org.eclipse.rse.internal.ui.actions.SystemWorkWithProfilesAction;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemPreferencesConstants;
-import org.eclipse.rse.ui.RSESystemTypeAdapter;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.SystemPreferencesManager;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction;
-import org.eclipse.rse.ui.actions.SystemNewConnectionAction;
-import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction;
-import org.eclipse.rse.ui.actions.SystemRefreshAction;
-import org.eclipse.rse.ui.actions.SystemRefreshAllAction;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.view.ContextObject;
-import org.eclipse.rse.ui.view.IRSEViewPart;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.IViewLinker;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IElementFactory;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.ui.part.ISetSelectionTarget;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.ui.views.framelist.FrameList;
-/**
- * This is the desktop view wrapper of the System View viewer.
- */
-public class SystemViewPart
- extends ViewPart
- implements ISetSelectionTarget, IShellProvider, ISystemMessageLine, IElementFactory, IPersistableElement, IAdapterFactory, ISystemPreferenceChangeListener, ISelectionChangedListener, IRSEViewPart
-{
-
-
-
- protected SystemView systemView;
- protected ISystemViewInputProvider input = null;
- protected String message, errorMessage;
- protected SystemMessage sysErrorMessage;
- protected IStatusLineManager statusLine = null;
- protected boolean inputIsRoot = true;
-
-
- protected FrameList frameList;
- protected SystemViewPartGotoActionGroup gotoActionGroup;
-
- // link with editor stuff
- protected boolean _isLinkingEnabled = false;
-
- // view linker is used when a link with editor is required
- protected IViewLinker _viewLinker;
-
- // remember-state variables...
-
- protected IMemento fMemento;
- protected IAdapterManager platformManager;
- // preference toggle actions that need to be updated when preferences change
- protected SystemPreferenceQualifyConnectionNamesAction qualifyConnectionNamesAction;
- protected SystemPreferenceShowFilterPoolsAction showFilterPoolsAction;
- protected SystemPreferenceRestoreStateAction restoreStateAction;
- //protected SystemPreferenceShowFilterStringsAction showFilterStringsAction;
- protected static SystemWorkWithProfilesAction wwProfilesAction;
- // copy and paste actions
- protected SystemCopyToClipboardAction _copyAction;
- protected SystemPasteFromClipboardAction _pasteAction;
-
- // Persistence tags.
- static final String TAG_RELEASE = "release"; //$NON-NLS-1$
- static final String TAG_SELECTION = "selection"; //$NON-NLS-1$
- static final String TAG_EXPANDED_TO = "expandedTo"; //$NON-NLS-1$
- static final String TAG_EXPANDED = "expanded"; //$NON-NLS-1$
- static final String TAG_ELEMENT = "element"; //$NON-NLS-1$
- static final String TAG_PATH = "path"; //$NON-NLS-1$
- static final String TAG_FILTER = "filter"; //$NON-NLS-1$
- static final String TAG_INPUT = "svInput"; //$NON-NLS-1$
- static final String TAG_VERTICAL_POSITION = "verticalPosition"; //$NON-NLS-1$
- static final String TAG_HORIZONTAL_POSITION = "horizontalPosition"; //$NON-NLS-1$
- static final String TAG_SHOWFILTERPOOLS = "showFilterPools"; //$NON-NLS-1$
- static final String TAG_SHOWFILTERSTRINGS = "showFilterStrings"; //$NON-NLS-1$
- static final String TAG_LINKWITHEDITOR = "linkWithEditor"; //$NON-NLS-1$
-
- public static final String MEMENTO_DELIM = "///"; //$NON-NLS-1$
-
- // constants
- public static final String ID = "org.eclipse.rse.ui.view.systemView"; // matches id in plugin.xml, view tag //$NON-NLS-1$
-
- /**
- * SystemViewPart constructor.
- */
- public SystemViewPart()
- {
- super();
- //RSEUIPlugin.logDebugMessage(this.getClass().getName(),"INSIDE CTOR FOR SYSTEMVIEWPART.");
- }
- /**
- * Easy access to the TreeViewer object
- */
- public SystemView getSystemView()
- {
- return systemView;
- }
-
- public Viewer getRSEViewer()
- {
- return systemView;
- }
-
- /**
- * When an element is added/deleted/changed/etc and we have focus, this
- * method is called. See SystemStaticHelpers.selectReveal method.
- */
- public void selectReveal(ISelection selection)
- {
- systemView.setSelection(selection, true);
- }
-
- /**
- * Returns the name for the given element.
- * Used as the name for the current frame.
- */
- protected String getFrameName(Object element)
- {
- return ((ILabelProvider) getSystemView().getLabelProvider()).getText(element);
- }
-
- /**
- * Returns the tool tip text for the given element.
- * Used as the tool tip text for the current frame, and for the view title tooltip.
- */
- protected String getFrameToolTipText(Object element)
- {
- return ((ILabelProvider) getSystemView().getLabelProvider()).getText(element);
- }
-
- public boolean isLinkingEnabled()
- {
- return _isLinkingEnabled;
- }
-
- public void setLinkingEnabled(boolean flag, IViewLinker viewLinker)
- {
- _isLinkingEnabled = flag;
- if (_isLinkingEnabled)
- {
- _viewLinker = viewLinker;
- IWorkbenchWindow activeWindow = SystemBasePlugin.getActiveWorkbenchWindow();
- IWorkbenchPage activePage = activeWindow.getActivePage();
- IEditorPart editor = activePage.getActiveEditor();
- if (editor != null)
- {
- editorActivated(editor);
- }
- }
- }
-
- /**
- * An editor has been activated. Sets the selection in this navigator
- * to be the editor's input, if linking is enabled.
- *
- * @param editor the active editor
- */
- protected void editorActivated(IEditorPart editor)
- {
- if (!_isLinkingEnabled)
- return;
-
- if (_viewLinker != null){
- _viewLinker.linkEditorToView(editor, systemView);
- }
- }
- /**
- * Updates the title text and title tool tip.
- * Called whenever the input of the viewer changes.
- */
- protected void updateTitle()
- {
- //IAdaptable inputObj = getSite().getPage().getInput();
- Object inputObj = getSystemView().getInput();
- SystemBasePlugin.logInfo("Inside updateTitle. inputObject class type: " + inputObj.getClass().getName()); //$NON-NLS-1$
-
- {
- setTitleToolTip(getFrameToolTipText(input));
- String viewName = getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
- if (inputObj instanceof IHost)
- {
- IHost conn = (IHost) inputObj;
- setPartName(viewName + " : " + conn.getAliasName()); //$NON-NLS-1$
- }
- else if (inputObj instanceof ISubSystem)
- {
- ISubSystem ss = (ISubSystem) inputObj;
- setPartName(viewName + " : " + ss.getName()); //$NON-NLS-1$
- }
- else if (inputObj instanceof ISystemFilterPoolReference)
- {
- ISystemFilterPoolReference sfpr = (ISystemFilterPoolReference) inputObj;
- setPartName(viewName + " : " + sfpr.getName()); //$NON-NLS-1$
- }
- else if (inputObj instanceof ISystemFilterReference)
- {
- ISystemFilterReference sfr = (ISystemFilterReference) inputObj;
- setPartName(viewName + " : " + sfr.getName()); //$NON-NLS-1$
- }
- else if (inputObj instanceof ISystemFilterStringReference)
- {
- ISystemFilterStringReference sfsr = (ISystemFilterStringReference) inputObj;
- setPartName(viewName + " : " + sfsr.getString()); //$NON-NLS-1$
- }
- else
- {
- setPartName(viewName);
- setTitleToolTip(""); //$NON-NLS-1$
- }
- }
- }
-
- /*
- * Set our input provider that will be used to populate the tree view
- *
- public void setInputProvider(ISystemViewInputProvider input)
- {
- RSEUIPlugin.logDebugMessage(this.getClass().getName(),"INSIDE SETINPUTPROVIDER FOR SYSTEMVIEWPART.");
- this.input = input;
- }*/
- /**
- * Creates the SWT controls for a part.
- * Called by Eclipse framework.
- */
- public void createPartControl(Composite parent)
- {
- //RSEUIPlugin.logInfo("INSIDE CREATEPARTCONTROL FOR SYSTEMVIEWPART.");
- if (input == null)
- //input = RSECorePlugin.getTheSystemRegistry();
- input = getInputProvider();
- systemView = new SystemView(getShell(), parent, input, this);
- frameList = createFrameList();
-
- gotoActionGroup = new SystemViewPartGotoActionGroup(this);
- IActionBars actionBars = getActionBars();
- if (actionBars != null)
- {
- actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), systemView.getDeleteAction());
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), systemView.getSelectAllAction());
- actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), systemView.getPropertyDialogAction());
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), systemView.getRefreshAction());
- actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), systemView.getRenameAction());
-
- statusLine = actionBars.getStatusLineManager();
- }
-
- // register global edit actions
- Clipboard clipboard = RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard();
-
- CellEditorActionHandler editorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
-
- _copyAction = new SystemCopyToClipboardAction(systemView.getShell(), clipboard);
- _pasteAction = new SystemPasteFromClipboardAction(systemView.getShell(), clipboard);
-
- editorActionHandler.setCopyAction(_copyAction);
- editorActionHandler.setPasteAction(_pasteAction);
- editorActionHandler.setDeleteAction(systemView.getDeleteAction());
- editorActionHandler.setSelectAllAction(systemView.getSelectAllAction());
-
- systemView.addSelectionChangedListener(this);
- //hook the part focus to the viewer's control focus.
- //hookFocus(systemView.getControl());
-
- systemView.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- handleDoubleClick(event);
- }
- });
-
- //prime the selection
- //selectionChanged(null, getSite().getDesktopWindow().getSelectionService().getSelection());
-
- boolean showConnectionActions = true;
- fillLocalToolBar(showConnectionActions);
-
- // -----------------------------
- // Enable right-click popup menu
- // -----------------------------
- getSite().registerContextMenu(systemView.getContextMenuManager(), systemView);
-
- // ----------------------------------------------------------------------
- // Enable property sheet updates when tree items are selected.
- // Note for this to work each item in the tree must either implement
- // IPropertySource, or support IPropertySource.class as an adapter type
- // in its AdapterFactory.
- // ----------------------------------------------------------------------
- getSite().setSelectionProvider(systemView);
- // listen to editor events for linking
- getSite().getPage().addPartListener(partListener);
-
- SystemWidgetHelpers.setHelp(parent, RSEUIPlugin.HELPPREFIX + "sysv0000"); //$NON-NLS-1$
-
- // ----------------------
- // Restore previous state
- // ----------------------
- final RSEInitJob initRSEJob = RSEInitJob.getInstance();
- if (initRSEJob == null) {
- //Already initialized - Profiles are loaded, we can restore state right away without blocking
- restoreInitialState();
- } else {
- //Wait until model fully restored, then fire a callback to restore state.
- //Remember current display, since we're definitely on the display thread here
- final Display display = Display.getCurrent();
- Job waitForRestoreCompleteJob = new Job("WaitForRestoreComplete") { //$NON-NLS-1$
- protected IStatus run(IProgressMonitor monitor) {
- try {
- //Wait for initRSEJob.
- initRSEJob.waitForCompletion();
- //callback
- display.asyncExec(new Runnable() {
- public void run() {
- restoreInitialState();
- }
- });
- } catch(InterruptedException e) {
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- }
- };
- waitForRestoreCompleteJob.setSystem(true);
- waitForRestoreCompleteJob.schedule();
- }
- }
-
- /**
- * Restore initial state of the SystemView. Can only be done
- * once the RSE Model has been fully restored, so this may
- * need to run in a callback.
- */
- private void restoreInitialState() {
- if ((fMemento != null) && (input instanceof ISystemRegistry))
- restoreState(fMemento);
- //fMemento = null;
-
- // Register for preference change events
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- registry.addSystemPreferenceChangeListener(this);
-
- // if this is the primary RSE view, and there are no user-defined
- // connections, auto-expand the New Connection prompt...
- if ((input == RSECorePlugin.getTheSystemRegistry()) && (RSECorePlugin.getTheSystemRegistry().getHosts().length == 1))
- {
- // assume this is the primary RSE view
-
- // WE GET ALL THE WAY HERE, BUT THESE LINES OF CODE ARE INEFFECTIVE FOR SOME REASON!!
-
- if (systemView.getTree().getItemCount() > 0) {
- TreeItem firstItem = systemView.getTree().getItems()[0];
- systemView.setSelection(new StructuredSelection(firstItem.getData()));
- systemView.setExpandedState(firstItem.getData(), true);
- }
- }
- }
-
- /**
- * Handles double clicks in viewer.
- * Opens editor if file double-clicked.
- */
- protected void handleDoubleClick(DoubleClickEvent event) {
- if (!systemView.enabledMode) {
- //event.doit = false;
- return;
- }
- IStructuredSelection s = (IStructuredSelection) event.getSelection();
- Object element = s.getFirstElement();
- if (element == null) return;
- ISystemViewElementAdapter adapter = systemView.getViewAdapter(element);
- if (adapter != null)
- adapter.handleDoubleClick(element);
-
- }
-
- /**
- * Creates the frame source and frame list, and connects them.
- */
- protected FrameList createFrameList()
- {
- SystemViewPartFrameSource frameSource = new SystemViewPartFrameSource(this);
- FrameList frameList = new FrameList(frameSource);
- frameSource.connectTo(frameList);
- return frameList;
- }
- /**
- * Return the FrameList object for this view part
- */
- public FrameList getFrameList()
- {
- return frameList;
- }
-
- /**
- * Return the Goto action group
- */
- public SystemViewPartGotoActionGroup getGotoActionGroup()
- {
- return gotoActionGroup;
- }
-
- /**
- * Return the shell for this view part
- */
- public Shell getShell()
- {
- if (systemView != null)
- return systemView.getTree().getShell();
- else
- return getSite().getShell();
- }
- /**
- * Return the action bars for this view part
- */
- public IActionBars getActionBars()
- {
- return getViewSite().getActionBars();
- }
-
- /**
- * @see IWorkbenchPart#setFocus()
- */
- public void setFocus()
- {
- //System.out.println("INSIDE SETFOCUS FOR SYSTEMVIEWPART. SYSTEMVIEW NULL? " + (systemView==null));
- IWorkbench wb = PlatformUI.getWorkbench();
- wb.getActiveWorkbenchWindow().getShell().setFocus();
- systemView.getControl().setFocus();
- /* the following was an attempt to fix problem with scrollbar needing two clicks to activate. didn't help.
- if (!SystemPreferencesGlobal.getGlobalSystemPreferences().getRememberState())
- {
- TreeItem[] roots = systemView.getTree().getItems();
- if ((roots != null) && (roots.length>0))
- systemView.setSelection(new StructuredSelection(roots[0].getData()));
- }
- */
-
- }
-
- public void selectionChanged(SelectionChangedEvent e)
- {
- IStructuredSelection sel = (IStructuredSelection) e.getSelection();
- _copyAction.setEnabled(_copyAction.updateSelection(sel));
- _pasteAction.setEnabled(_pasteAction.updateSelection(sel));
- //systemView.getPropertyDialogAction();
- if (_isLinkingEnabled)
- {
- linkToEditor(sel);
- }
- }
-
-
- // link back to editor
- protected void linkToEditor(IStructuredSelection selection)
- {
- if (_viewLinker != null)
- {
- Object obj = selection.getFirstElement();
- IWorkbenchPage page = getSite().getPage();
- _viewLinker.linkViewToEditor(obj, page);
- }
- }
-
-
- /**
- * Fills the local tool bar with actions.
- */
- protected void fillLocalToolBar(boolean showConnectionActions)
- {
- IActionBars actionBars = getViewSite().getActionBars();
- SystemRefreshAction refreshAction = new SystemRefreshAction(getShell());
- refreshAction.setId(ActionFactory.REFRESH.getId());
- refreshAction.setActionDefinitionId("org.eclipse.ui.file.refresh"); //$NON-NLS-1$
- refreshAction.setSelectionProvider(systemView);
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
-
- // Note: Keep the group marker and separators in place! ISV's needs
- // them to find their places within the toolbar. Re-use as
- // much constants from the remote system view context menu as possible.
- // This in particular makes orientating and contributing via plugin.xml
- // much easier.
-
- IToolBarManager toolBarMgr = actionBars.getToolBarManager();
- if (showConnectionActions)
- {
- toolBarMgr.add(new GroupMarker(ISystemContextMenuConstants.GROUP_NEW_NONCASCADING));
- SystemNewConnectionAction newConnAction = new SystemNewConnectionAction(getShell(), false, systemView); // false implies not from popup menu
- toolBarMgr.add(newConnAction);
- }
-
- toolBarMgr.add(new GroupMarker(ISystemContextMenuConstants.GROUP_BUILD));
- refreshAction.setSelectionProvider(systemView);
- toolBarMgr.add(refreshAction);
-
- toolBarMgr.add(new Separator(ISystemContextMenuConstants.GROUP_GOTO));
- SystemViewPartGotoActionGroup gotoActions = new SystemViewPartGotoActionGroup(this);
- gotoActions.fillActionBars(actionBars);
-
- // defect 41203
- toolBarMgr.add(new Separator(ISystemContextMenuConstants.GROUP_EXPAND));
- SystemCollapseAllAction collapseAllAction = new SystemCollapseAllAction(getShell());
- collapseAllAction.setSelectionProvider(systemView);
- toolBarMgr.add(collapseAllAction);
-
- IMenuManager menuMgr = actionBars.getMenuManager();
- populateSystemViewPulldownMenu(menuMgr, getShell(), showConnectionActions, this, systemView);
-
- // [179181] [api] Dynamic system type provider need a hook to add dynamic system type specific toolbar groups.
- IRSESystemType[] systemTypes = SystemWidgetHelpers.getValidSystemTypes(null);
- for (int i = 0; i < systemTypes.length; i++) {
- IRSESystemType systemType = systemTypes[i];
- Object adapter = systemType.getAdapter(RSESystemTypeAdapter.class);
- if (adapter instanceof RSESystemTypeAdapter) {
- ((RSESystemTypeAdapter)adapter).addCustomToolbarGroups(this);
- }
- }
- }
-
- /**
- * Pulldown the local toolbar menu with actions
- */
- public static void populateSystemViewPulldownMenu(IMenuManager menuMgr, Shell shell, boolean showConnectionActions, IWorkbenchPart viewPart, ISelectionProvider sp)
- {
- SystemRefreshAllAction refreshAllAction = new SystemRefreshAllAction(shell);
- //SystemCascadingUserIdPerSystemTypeAction userIdPerSystemTypeAction = new SystemCascadingUserIdPerSystemTypeAction(shell); d51541
- SystemPreferenceShowFilterPoolsAction showFilterPoolsAction = new SystemPreferenceShowFilterPoolsAction(shell);
- SystemPreferenceQualifyConnectionNamesAction qualifyConnectionNamesAction = null;
- SystemPreferenceRestoreStateAction restoreStateAction = new SystemPreferenceRestoreStateAction(shell);
-
- if (viewPart instanceof SystemViewPart)
- {
- ((SystemViewPart) viewPart).showFilterPoolsAction = showFilterPoolsAction; // set non-static field
- ((SystemViewPart) viewPart).restoreStateAction = restoreStateAction; // set non-static field
- }
-
- if (showConnectionActions)
- {
- boolean fromPopup = false;
- boolean wantIcon = false;
- SystemNewConnectionAction newConnectionAction = new SystemNewConnectionAction(shell, fromPopup, wantIcon, sp);
- SystemImportConnectionAction importConnectionAction = new SystemImportConnectionAction();
- importConnectionAction.setShell(shell);
- importConnectionAction.setText(SystemResources.RESID_IMPORT_CONNECTION_LABEL_LONG);
- SystemWorkWithProfilesAction wwProfilesAction = new SystemWorkWithProfilesAction(shell);
- menuMgr.add(newConnectionAction);
- menuMgr.add(importConnectionAction);
- menuMgr.add(new Separator());
- menuMgr.add(wwProfilesAction);
- menuMgr.add(new Separator());
- // moved Qualify Connection Names from here for d51541
- //menuMgr.add(new Separator()); d51541
- }
- menuMgr.add(refreshAllAction);
- menuMgr.add(new Separator());
- if (showConnectionActions)
- {
- qualifyConnectionNamesAction = new SystemPreferenceQualifyConnectionNamesAction(shell);
- if (viewPart instanceof SystemViewPart)
- ((SystemViewPart) viewPart).qualifyConnectionNamesAction = qualifyConnectionNamesAction;
- menuMgr.add(qualifyConnectionNamesAction); // moved here for d51541
- }
- //menuMgr.add(userIdPerSystemTypeAction.getSubMenu()); d51541
- menuMgr.add(showFilterPoolsAction);
- menuMgr.add(restoreStateAction); // d51541
-
- // Now display any contributed action shortcuts for bringing up
- // a particular preference page...
- MenuManager subMenu = new MenuManager(SystemResources.ACTION_CASCADING_PREFERENCES_LABEL, ISystemContextMenuConstants.MENU_PREFERENCES);
- menuMgr.add(subMenu);
-
- // The initial "RSE" Preference page action is added hardcoded.
- // This comes from the former SystemCascadingPreferencesAction.
- // FIXME will be moved to using command/hander extension point as per
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=186769
- SystemShowPreferencesPageAction action = new SystemShowPreferencesPageAction();
- action.setPreferencePageID("org.eclipse.rse.ui.preferences.RemoteSystemsPreferencePage"); //$NON-NLS-1$
- action.setText(SystemResources.ACTION_SHOW_PREFERENCEPAGE_LABEL);
- action.setToolTipText(SystemResources.ACTION_SHOW_PREFERENCEPAGE_TOOLTIP);
- action.setHelp("org.eclipse.rse.ui.aprefrse"); //$NON-NLS-1$
- subMenu.add(action);
- subMenu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_ADDITIONS));
-
- SystemViewMenuListener menuListener = new SystemViewMenuListener(true); // true says this is a persistent menu
- if (viewPart instanceof ISystemMessageLine)
- menuListener.setShowToolTipText(true, (ISystemMessageLine) viewPart);
- menuMgr.addMenuListener(menuListener);
-
- }
-
- /**
- *
- */
- public void dispose()
- {
- super.dispose();
- if (platformManager != null)
- unregisterWithManager(platformManager);
- RSECorePlugin.getTheSystemRegistry().removeSystemPreferenceChangeListener(this);
- getSite().getPage().removePartListener(partListener);
- //System.out.println("INSIDE DISPOSE FOR SYSTEMVIEWPART.");
- }
-
- /**
- * Returns the initial input provider for the viewer.
- * Tries to deduce the appropriate input provider based on current input.
- */
- protected ISystemViewInputProvider getInputProvider()
- {
- IAdaptable inputObj = getSite().getPage().getInput();
- inputIsRoot = false;
- ISystemViewInputProvider inputProvider = RSECorePlugin.getTheSystemRegistry();
- if (inputObj != null)
- {
- platformManager = Platform.getAdapterManager();
- if (inputObj instanceof IHost)
- {
- IHost conn = (IHost) inputObj;
- inputProvider = new SystemViewAPIProviderForConnections(conn);
- setPartName(getTitle() + " : " + conn.getAliasName()); //$NON-NLS-1$
- }
- else if (inputObj instanceof ISubSystem)
- {
- ISubSystem ss = (ISubSystem) inputObj;
- inputProvider = new SystemViewAPIProviderForSubSystems(ss);
- setPartName(getTitle() + " : " + ss.getName()); //$NON-NLS-1$
- }
- else if (inputObj instanceof ISystemFilterPoolReference)
- {
- ISystemFilterPoolReference sfpr = (ISystemFilterPoolReference) inputObj;
- inputProvider = new SystemViewAPIProviderForFilterPools(sfpr);
- setPartName(getTitle() + " : " + sfpr.getName()); //$NON-NLS-1$
- }
- else if (inputObj instanceof ISystemFilterReference)
- {
- ISystemFilterReference sfr = (ISystemFilterReference) inputObj;
- inputProvider = new SystemViewAPIProviderForFilters(sfr);
- setPartName(getTitle() + " : " + sfr.getName()); //$NON-NLS-1$
- }
- else if (inputObj instanceof ISystemFilterStringReference)
- {
- ISystemFilterStringReference sfsr = (ISystemFilterStringReference) inputObj;
- inputProvider = new SystemViewAPIProviderForFilterStrings(sfsr);
- setPartName(getTitle() + " : " + sfsr.getString()); //$NON-NLS-1$
- }
- else
- {
- platformManager = null;
- inputIsRoot = true;
- }
-
- if (platformManager != null)
- registerWithManager(platformManager, inputObj);
- //msg = "INSIDE GETINPUTPROVIDER FOR SYSTEMVIEWPART: inputObj="+inputObj+", input class="+inputObj.getClass().getName()+", inputProvider="+inputProvider;
- }
- else
- {
- //msg = "INSIDE GETINPUTPROVIDER FOR SYSTEMVIEWPART: inputObj is null, inputProvider="+inputProvider;
- }
- //RSEUIPlugin.logDebugMessage(this.getClass().getName(),msg);
- //System.out.println("INSIDE getInputProvider. inputProvider = "+inputProvider);
- return inputProvider;
- }
-
- // --------------------------------------------
- // ISystemPreferenceChangeListener interface...
- // --------------------------------------------
- public void systemPreferenceChanged(ISystemPreferenceChangeEvent event)
- {
- if ((event.getType() == ISystemPreferenceChangeEvents.EVENT_QUALIFYCONNECTIONNAMES) && (qualifyConnectionNamesAction != null))
- qualifyConnectionNamesAction.setChecked(SystemPreferencesManager.getQualifyConnectionNames());
- else if ((event.getType() == ISystemPreferenceChangeEvents.EVENT_SHOWFILTERPOOLS) && (showFilterPoolsAction != null))
- showFilterPoolsAction.setChecked(SystemPreferencesManager.getShowFilterPools());
- else if ((event.getType() == ISystemPreferenceChangeEvents.EVENT_RESTORESTATE) && (restoreStateAction != null))
- restoreStateAction.setChecked(SystemPreferencesManager.getRememberState());
-
- //else if ((event.getType() == ISystemPreferenceChangeEvents.EVENT_SHOWFILTERSTRINGS) &&
- // (showFilterStringsAction != null))
- // showFilterStringsAction.setChecked(SystemPreferencesManager.getPreferencesManager().getShowFilterStrings());
-
- }
-
- // -------------------------------
- // ISystemMessageLine interface...
- // -------------------------------
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage()
- {
- errorMessage = null;
- sysErrorMessage = null;
- if (statusLine != null)
- statusLine.setErrorMessage(errorMessage);
- }
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage()
- {
- message = null;
- if (statusLine != null)
- statusLine.setMessage(message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage()
- {
- return errorMessage;
- }
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null<code> is returned.
- */
- public String getMessage()
- {
- return message;
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message)
- {
- this.errorMessage = message;
- if (statusLine != null)
- statusLine.setErrorMessage(message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public SystemMessage getSystemErrorMessage()
- {
- return sysErrorMessage;
- }
-
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(SystemMessage message)
- {
- sysErrorMessage = message;
- setErrorMessage(message.getLevelOneText());
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(Throwable exc)
- {
- setErrorMessage(exc.getMessage());
- }
-
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message)
- {
- this.message = message;
- if (statusLine != null)
- statusLine.setMessage(message);
- }
- /**
- *If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(SystemMessage message)
- {
- setMessage(message.getLevelOneText());
- }
-
- // -------------------------------------------
- // MEMENTO SUPPORT (SAVING/RESTORING STATE)...
- // -------------------------------------------
- /**
- * Initializes this view with the given view site. A memento is passed to
- * the view which contains a snapshot of the views state from a previous
- * session. Where possible, the view should try to recreate that state
- * within the part controls.
- * <p>
- * The parent's default implementation will ignore the memento and initialize
- * the view in a fresh state. Subclasses may override the implementation to
- * perform any state restoration as needed.
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException
- {
- init(site);
- fMemento = memento;
- //System.out.println("INSIDE INIT");
- }
-
- /**
- * Returns the image descriptor with the given relative path.
- */
- protected ImageDescriptor getNavigatorImageDescriptor(String relativePath)
- {
- return RSEUIPlugin.getDefault().getImageDescriptorFromIDE(relativePath); // more reusable
- /*
- String iconPath = "icons/full/"; //$NON-NLS-1$
- try
- {
- AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
- URL installURL = plugin.getDescriptor().getInstallURL();
-
- URL url = new URL(installURL, iconPath + relativePath);
- ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
- return descriptor;
- }
- catch (MalformedURLException e)
- {
- // should not happen
- return ImageDescriptor.getMissingImageDescriptor();
- }*/
- }
-
- /**
- * Method declared on IViewPart.
- */
- public void saveState(IMemento memento)
- {
- //System.out.println("INSIDE SAVESTATE");
- if (!SystemPreferencesManager.getRememberState())
- return;
- if (systemView == null)
- {
- // part has not been created
- if (fMemento != null) //Keep the old state;
- memento.putMemento(fMemento);
- return;
- }
-
- if (_isLinkingEnabled)
- {
- memento.putString(TAG_LINKWITHEDITOR, "t"); //$NON-NLS-1$
- }
- else
- {
- memento.putString(TAG_LINKWITHEDITOR, "f"); //$NON-NLS-1$
- }
-
- // We record the current release for future in case anything significant changes from release to release
- memento.putString(TAG_RELEASE, RSECorePlugin.CURRENT_RELEASE_NAME);
-
- // We record the current preferences for show filter string and show filter pools.
- // We do this to ensure the states match on restore. If they don't we will be in trouble
- // restoring expansion state and hence will abandon it.
-
- memento.putString(TAG_SHOWFILTERPOOLS, SystemPreferencesManager.getShowFilterPools() ? "t" : "f"); //$NON-NLS-1$ //$NON-NLS-2$
- //memento.putString(TAG_SHOWFILTERSTRINGS, SystemPreferencesManager.getPreferencesManager().getShowFilterStrings() ? "t" : "f");
-
- String inputMemento = memento.getString("factoryID"); // see IWorkbenchWindow ... this is only clue I can figure out! //$NON-NLS-1$
- if (inputMemento != null)
- {
- saveInputState(memento);
- return;
- }
-
- Tree tree = systemView.getTree();
-
- // SAVE EXPAND-TO HASHTABLE
- Hashtable expandToFilters = systemView.getExpandToFilterTable();
- if ((expandToFilters != null) && (expandToFilters.size() > 0))
- {
- IMemento expandedMem = memento.createChild(TAG_EXPANDED_TO);
- Enumeration keys = expandToFilters.keys();
- while (keys.hasMoreElements())
- {
- Object key = keys.nextElement();
- Object value = expandToFilters.get(key);
- if (value != null)
- {
- IMemento elementMem = expandedMem.createChild(TAG_ELEMENT);
- elementMem.putString(TAG_PATH, (String) key);
- elementMem.putString(TAG_FILTER, (String) value);
- }
- }
- }
-
- // SAVE EXPANSION STATE
- //Object expandedElements[]= systemView.getExpandedElements();
- Object expandedElements[] = systemView.getVisibleExpandedElements();
- if ((expandedElements != null) && (expandedElements.length > 0))
- {
- IMemento expandedMem = memento.createChild(TAG_EXPANDED);
- for (int i = 0; i < expandedElements.length; i++)
- {
- Object o = expandedElements[i];
- ISystemViewElementAdapter adapter = systemView.getViewAdapter(o);
- //ISystemRemoteElementAdapter radapter = systemView.getRemoteAdapter(o);
- //if (adapter.saveExpansionState(o) && (radapter==null))
- if (adapter.saveExpansionState(o))
- {
- IMemento elementMem = expandedMem.createChild(TAG_ELEMENT);
- elementMem.putString(TAG_PATH, getMementoHandle(o, adapter));
- //System.out.println("Added to saved expansion list: " + getMementoHandle(o, adapter));
- }
- }
- }
-
- // SAVE SELECTION STATE
- Object elements[] = ((IStructuredSelection) systemView.getSelection()).toArray();
- if ((elements != null) && (elements.length > 0))
- {
- IMemento selectionMem = memento.createChild(TAG_SELECTION);
- for (int i = 0; i < elements.length; i++)
- {
- Object o = elements[i];
- ISystemViewElementAdapter adapter = systemView.getViewAdapter(o);
- //ISystemRemoteElementAdapter radapter = systemView.getRemoteAdapter(o);
- //if (adapter.saveExpansionState(o) && (radapter==null))
- if (adapter.saveExpansionState(o))
- {
- IMemento elementMem = selectionMem.createChild(TAG_ELEMENT);
- elementMem.putString(TAG_PATH, getMementoHandle(o, adapter));
- }
- }
- }
-
- //save vertical position
- ScrollBar bar = tree.getVerticalBar();
- int position = bar != null ? bar.getSelection() : 0;
- memento.putString(TAG_VERTICAL_POSITION, String.valueOf(position));
- //save horizontal position
- bar = tree.getHorizontalBar();
- position = bar != null ? bar.getSelection() : 0;
- memento.putString(TAG_HORIZONTAL_POSITION, String.valueOf(position));
-
- }
-
- /**
- * Defer to the adapter to get the memento handle key plus the memento handle for
- * each part leading up to the current object.
- */
- protected String getMementoHandle(Object o, ISystemViewElementAdapter adapter)
- {
- StringBuffer idBuffer = new StringBuffer(adapter.getMementoHandleKey(o));
- Object[] elementNodes = systemView.getElementNodes(o);
- if (elementNodes != null)
- {
- for (int idx = elementNodes.length - 1; idx >= 0; idx--)
- {
- o = elementNodes[idx];
- adapter = systemView.getViewAdapter(o);
- idBuffer.append(MEMENTO_DELIM + adapter.getMementoHandle(o));
- }
- }
- //System.out.println("MEMENTO HANDLE: " + idBuffer.toString());
- return idBuffer.toString();
- }
-
- /**
- * Our own method for restoring state
- */
- protected void restoreState(IMemento memento)
- {
- RestoreStateRunnable restoreAction = new RestoreStateRunnable(memento);
- restoreAction.setRule(RSECorePlugin.getTheSystemRegistry());
- restoreAction.schedule();
-
- /* DKM - Moved to RestoreStateRunnable
- * - resolves invalid shell problem at startup
- * *
- //System.out.println("SYSTEMVIEWPART: restoreState");
- if (!SystemPreferencesManager.getPreferencesManager().getRememberState())
- return;
-
- // restore the show filter pools and show filter strings settings as they were when this was saved
- boolean showFilterPools = false;
- boolean showFilterStrings = false;
- String savedValue = memento.getString(TAG_SHOWFILTERPOOLS);
- if (savedValue != null)
- showFilterPools = savedValue.equals("t");
- else
- showFilterPools = SystemPreferencesManager.getPreferencesManager().getShowFilterPools();
-
- savedValue = memento.getString(TAG_SHOWFILTERSTRINGS); // historical
- if (savedValue != null)
- showFilterStrings = savedValue.equals("t");
- //else
- //showFilterStrings = SystemPreferencesManager.getPreferencesManager().getShowFilterStrings();
-
- IMemento childMem = null;
-
- // restore expand-to hashtable state
- childMem= memento.getChild(TAG_EXPANDED_TO);
- if (childMem != null)
- {
- IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT);
- Hashtable ht = new Hashtable();
- for (int i= 0; i < elementMem.length; i++)
- {
- String key = elementMem[i].getString(TAG_PATH);
- String value = elementMem[i].getString(TAG_FILTER);
- if ((key != null) && (value != null))
- ht.put(key, value);
- }
- if (ht.size() > 0)
- systemView.setExpandToFilterTable(ht);
- }
-
- // restore expansion state
- childMem= memento.getChild(TAG_EXPANDED);
- if (childMem != null)
- {
- ArrayList elements= new ArrayList();
- Vector remoteElements = new Vector();
- IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT);
- // walk through list of expanded nodes, breaking into 2 lists: non-remote and remote
- for (int i= 0; i < elementMem.length; i++)
- {
- Object element= getObjectFromMemento(showFilterPools, showFilterStrings, elementMem[i].getString(TAG_PATH));
- if (element != null)
- if (element instanceof RemoteObject) // this is a remote object
- {
- remoteElements.add(element);
- //System.out.println("Added to remote expansion list: " + element);
- }
- else
- {
- elements.add(element);
- //System.out.println("Added to non-remote expansion list: " + element);
- }
- }
- // expand non-remote...
- systemView.setExpandedElements(elements.toArray());
- // expand remote...
- if (remoteElements.size() > 0)
- {
- SystemResourceChangeEvent event = null;
- for (int idx=0; idx<remoteElements.size(); idx++)
- {
- RemoteObject ro = (RemoteObject)remoteElements.elementAt(idx);
- //event = new SystemResourceChangeEvent(ro.name,ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE,
- // SystemViewDummyObject.getInstance()); // This tells SystemView to expand this remote object, but don't select a child
- //systemView.systemResourceChanged(event);
- systemView.refreshRemoteObject(ro.name, SystemViewDummyObject.getInstance(), true);
- }
- }
- }
-
- // restoreSelection
- childMem= memento.getChild(TAG_SELECTION);
- if (childMem != null)
- {
- ArrayList list= new ArrayList();
- Vector remoteElements = new Vector();
- IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT);
- for (int i= 0; i < elementMem.length; i++)
- {
- Object element= getObjectFromMemento(showFilterPools, showFilterStrings, elementMem[i].getString(TAG_PATH));
- if (element != null)
- if (element instanceof RemoteObject) // this is a remote object
- remoteElements.add(element);
- else
- list.add(element);
- //System.out.println("Added to selection list: " + element);
- }
- systemView.setSelection(new StructuredSelection(list));
- if (remoteElements.size() > 0)
- {
- Vector v = new Vector();
- for (int idx=0; idx<remoteElements.size(); idx++)
- {
- RemoteObject ro = (RemoteObject)remoteElements.elementAt(idx);
- v.addElement(ro.name);
- }
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(v,ISystemResourceChangeEvents.EVENT_SELECT_REMOTE,null);
- systemView.systemResourceChanged(event);
- }
- }
- Tree tree= systemView.getTree();
- //restore vertical position
- ScrollBar bar= tree.getVerticalBar();
- if (bar != null)
- {
- try
- {
- String posStr= memento.getString(TAG_VERTICAL_POSITION);
- if (posStr != null)
- {
- int position;
- position= new Integer(posStr).intValue();
- bar.setSelection(position);
- }
- } catch (NumberFormatException e)
- {
- }
- }
- //restore vertical position
- bar= tree.getHorizontalBar();
- if (bar != null)
- {
- try
- {
- String posStr= memento.getString(TAG_HORIZONTAL_POSITION);
- if (posStr != null)
- {
- int position;
- position= new Integer(posStr).intValue();
- bar.setSelection(position);
- }
- } catch (NumberFormatException e)
- {
- }
- }
- */
- }
-
- /**
- * protected method to deconstruct an expanded/selected memento into an actual object
- */
- protected Object getObjectFromMemento(boolean showFilterPools, boolean showFilterStrings, String memento)
- {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
-
- ISystemProfile profile = null;
- IHost conn = null;
- String ssfId = null;
- ISubSystemConfiguration ssf = null;
- ISubSystem subsystem = null;
- ISystemFilterPoolReference fpRef = null;
- ISystemFilterReference fRef = null;
- ISystemFilterStringReference fsRef = null;
- RemoteObject remoteObject = null;
-
- //System.out.println("PARSING MEMENTO: " + memento);
-
- if (memento == null)
- return null;
-
- Vector v = tokenize(memento, MEMENTO_DELIM);
-
- String elementType = ""; //$NON-NLS-1$
- String ssName = null;
- //String connName = null;
- //String subsystemName = null;
- // 0. element type
- // 1. connections
- // 2. subsystems
- // 3. filter pools (optional)
- // 4. filters
- // 5. filter strings (optional)
- // 6. remote objects
- // 1. connections
- // 2. subsystems
- // 3. filters
- // 4. filter strings (optional)
- // 5. remote objects
- // 1. connections
- // 2. subsystems
- // 3. filter pools (optional)
- // 4. filters
- // 5. remote objects
- // 1. connections
- // 2. subsystems
- // 3. filters
- // 4. remote objects
-
- int index = 0;
- for (int idx = 0; idx < v.size(); idx++)
- {
- String token = (String) v.elementAt(idx);
- switch (idx)
- {
- // type of element
- case 0 :
- elementType = token;
- break;
- // connection
- case 1 :
- index = token.indexOf('.');
- if (index > 0)
- {
- profile = sr.getSystemProfile(token.substring(0, index));
- if (profile != null)
- conn = sr.getHost(profile, token.substring(index + 1));
- }
- break;
- // subsystem
- case 2 :
- index = token.indexOf('=');
- ssfId = index != -1 ? token.substring(0, index) : null;
- ssName = token.substring(index + 1);
- if (ssfId != null)
- ssf = sr.getSubSystemConfiguration(ssfId);
- if ((ssf != null) && (conn != null))
- {
- ISubSystem[] subsystems = ssf.getSubSystems(conn, true); // force to life
- if (subsystems != null)
- for (int ssidx = 0;(subsystem == null) && (ssidx < subsystems.length); ssidx++)
- if (subsystems[ssidx].getName().equals(ssName))
- subsystem = subsystems[ssidx];
- }
- break;
- // filter pool or filter (depends on showFilterPools)
- case 3 :
-
- if (!(subsystem.getSubSystemConfiguration().supportsFilters())) {
- remoteObject = new RemoteObject(token, subsystem, null, null);
- break;
- }
-
- if (showFilterPools)
- {
- if (subsystem != null)
- {
- String poolName = token;
- ISystemFilterPoolReference[] refs = subsystem.getFilterPoolReferenceManager().getSystemFilterPoolReferences();
- if (refs != null)
- for (int refidx = 0;(fpRef == null) && (refidx < refs.length); refidx++)
- {
- if (refs[refidx].getFullName().equals(poolName))
- fpRef = refs[refidx];
- }
- }
- }
- else
- {
- index = token.indexOf('=');
- if (index != -1)
- {
- String filterName = token.substring(index + 1);
- String poolName = token.substring(0, index);
- if (subsystem != null)
- {
- ISystemFilterPoolReference[] refs = subsystem.getFilterPoolReferenceManager().getSystemFilterPoolReferences();
- if (refs != null)
- for (int refidx = 0;(fpRef == null) && (refidx < refs.length); refidx++)
- if (refs[refidx].getFullName().equals(poolName))
- fpRef = refs[refidx];
- }
-
- // TODO: handle nested filters. in this case they are separated by ';'. See SystemFilterReferenceAdapter's getMementoHandle()
- if (fpRef != null)
- {
- ISystemFilterReference[] refs = fpRef.getSystemFilterReferences(subsystem);
- if (refs != null)
- for (int refidx = 0;(fRef == null) && (refidx < refs.length); refidx++)
- if (refs[refidx].getName().equals(filterName))
- fRef = refs[refidx];
- }
- }
- }
- break;
- // filter or filter string (depends on showFilterPools) or remote object (depends on showFilterStrings)
- case 4 :
-
- if (!(subsystem.getSubSystemConfiguration().supportsFilters())) {
- remoteObject = new RemoteObject(token, subsystem, null, null);
- break;
- }
-
- if (showFilterPools) // definitely a filter
- {
- index = token.indexOf('=');
- String filterName = token.substring(index + 1);
-// String poolName = token.substring(0, index);
- // TODO: handle nested filters. in this case they are separated by ';'. See SystemFilterReferenceAdapter's getMementoHandle()
- if (fpRef != null) // should have already been parsed in case 3
- {
- ISystemFilterReference[] refs = fpRef.getSystemFilterReferences(subsystem);
- if (refs != null)
- for (int refidx = 0;(fRef == null) && (refidx < refs.length); refidx++)
- if (refs[refidx].getName().equals(filterName))
- fRef = refs[refidx];
- }
- }
- else if (showFilterStrings) // children of filters are filter strings or resolved remote objects
- {
- // at this point we know the parent filter reference as that was parsed in case 3
- if (fRef != null)
- {
- ISystemFilterStringReference[] refs = fRef.getSystemFilterStringReferences();
- if (refs != null)
- for (int refidx = 0;(fsRef == null) && (refidx < refs.length); refidx++)
- if (refs[refidx].getString().equals(token))
- fsRef = refs[refidx];
- }
- }
- else // if both pools and strings are turned off, then at level four we are definitely dealing with remote objects
- {
- if ((subsystem != null) && (fRef != null))
- remoteObject = new RemoteObject(token, subsystem, fRef, fsRef);
- }
-
- break;
- // filter string (depends on showFilterStrings) or remote object
- case 5 :
-
- if (!(subsystem.getSubSystemConfiguration().supportsFilters())) {
- remoteObject = new RemoteObject(token, subsystem, null, null);
- break;
- }
-
- if (showFilterPools && showFilterStrings) // definitely a filter string
- {
- // at this point we know the parent filter reference as that was parsed in case 4
- if (fRef != null)
- {
- ISystemFilterStringReference[] refs = fRef.getSystemFilterStringReferences();
- if (refs != null)
- for (int refidx = 0;(fsRef == null) && (refidx < refs.length); refidx++)
- if (refs[refidx].getString().equals(token))
- fsRef = refs[refidx];
- }
- }
- else // definitely remote
- {
- if ((subsystem != null) && (fRef != null))
- remoteObject = new RemoteObject(token, subsystem, fRef, fsRef);
- }
-
- break;
- default : // definitely a remote object
-
- if (!(subsystem.getSubSystemConfiguration().supportsFilters())) {
- remoteObject = new RemoteObject(token, subsystem, null, null);
- break;
- }
-
- if ((subsystem != null) && (fRef != null))
- remoteObject = new RemoteObject(token, subsystem, fRef, fsRef);
- }
- }
-
- if (elementType.equals(ISystemMementoConstants.MEMENTO_KEY_CONNECTION))
- return conn;
- else if (elementType.equals(ISystemMementoConstants.MEMENTO_KEY_SUBSYSTEM))
- return subsystem;
- else if (elementType.equals(ISystemMementoConstants.MEMENTO_KEY_FILTERPOOLREFERENCE))
- return fpRef;
- else if (elementType.equals(ISystemMementoConstants.MEMENTO_KEY_FILTERREFERENCE))
- return fRef;
- else if (elementType.equals(ISystemMementoConstants.MEMENTO_KEY_FILTERSTRINGREFERENCE))
- return fsRef;
- else
- return remoteObject;
-
- //return null;
- }
-
- /**
- * Parse a string into tokens. Unlike StringTokenizer, this supports delimiter strings versus
- * only delimiter characters
- */
- public static Vector tokenize(String inputString, String delimiter)
- {
- Vector v = new Vector();
- StringBuffer token = new StringBuffer();
- String lastToken = null;
- int inpLen = inputString.length();
- int delimLen = delimiter.length();
- char delimChar1 = delimiter.charAt(0);
- for (int idx = 0; idx < inpLen; idx++)
- {
- int remLen = inpLen - idx;
- char currChar = inputString.charAt(idx);
- if ((currChar == delimChar1) && (remLen >= delimLen) && inputString.substring(idx, idx + delimLen).equals(delimiter))
- {
- lastToken = token.toString();
- v.addElement(lastToken);
- //System.out.println("...token: " + token);
- token.setLength(0);
- idx += delimLen - 1;
- }
- else
- token.append(currChar);
- }
- if (token.length() > 0)
- {
- lastToken = token.toString();
- v.addElement(lastToken);
- //System.out.println("...token: " + token);
- }
- return v;
- }
-
- protected class ShowRestoredRemoteObject implements Runnable
- {
- private Object _restoredObject;
- private Object[] _children;
- public ShowRestoredRemoteObject(Object restoredObject, Object[] children)
- {
- _restoredObject = restoredObject;
- _children = children;
- }
-
- public void run()
- {
- Vector matches = new Vector();
- systemView.findAllRemoteItemReferences(_restoredObject, _restoredObject, matches);
- if (matches.size() > 0){
- TreeItem item = (TreeItem)matches.get(0);
- systemView.createTreeItems(item, _children);
- item.setExpanded(true);
- }
-
- }
- }
-
-
- protected class RestoreRemoteObjects extends Job
- {
- private Vector _remoteObjectsToRestore;
- private List _cacheSubSystemList;
- private Vector _remoteObjectsToSelect;
-
- public RestoreRemoteObjects(Vector remoteObjects, List cacheSubSystemList, Vector remoteObjectsToSelect)
- {
- super("Restore Remote Objects"); //$NON-NLS-1$
- _remoteObjectsToRestore = remoteObjects;
- _cacheSubSystemList = cacheSubSystemList;
- _remoteObjectsToSelect = remoteObjectsToSelect;
- }
-
- protected IStatus run(IProgressMonitor monitor)
- {
- IStatus status = doRestore(monitor);
- if (status.isOK()){
- status = doSelect(monitor);
- }
- return status;
- }
-
- protected IStatus doSelect(IProgressMonitor monitor)
- {
- Vector v = new Vector();
- for (int i = 0; i < _remoteObjectsToSelect.size(); i++){
-
- Object object = _remoteObjectsToSelect.get(i);
- if (object instanceof RemoteObject)
- {
- RemoteObject robject = (RemoteObject)object;
- v.addElement(robject.name);
- }
- }
- SystemResourceChangeEvent event = new SystemResourceChangeEvent(v, ISystemResourceChangeEvents.EVENT_SELECT_REMOTE, null);
- systemView.systemResourceChanged(event);
-
- return Status.OK_STATUS;
- }
-
-
- protected IStatus doRestore(IProgressMonitor monitor)
- {
- for (int i = 0; i < _remoteObjectsToRestore.size(); i++){
-
- if (monitor.isCanceled()){
- return Status.CANCEL_STATUS;
- }
-
- Object object = _remoteObjectsToRestore.get(i);
- if (object instanceof RemoteObject)
- {
- RemoteObject robject = (RemoteObject)object;
-
- ISubSystem ss = robject.subsystem;
-
- // yantzi: artemis 6.0: notify subsystems that this is a restore from memento so they
- // can optionally use the cache if desired
- if (ss != null && ss.supportsCaching())
- {
- ss.getCacheManager().setRestoreFromMemento(true);
- }
-
- if (!ss.isOffline()){
- String path = robject.name;
- ISystemFilterReference fref = robject.fRef;
-
- try
- {
- Object actualObject = ss.getObjectWithAbsoluteName(path, monitor);
-
- if (actualObject instanceof IAdaptable)
- {
- // get the adapter
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)actualObject).getAdapter(ISystemViewElementAdapter.class);
-
- // get the context
- ContextObject contextObject = new ContextObject(actualObject, ss, fref);
-
- // get the children
- Object[] children = adapter.getChildren(contextObject, monitor);
-
- ShowRestoredRemoteObject showRunnable = new ShowRestoredRemoteObject(actualObject, children);
- Display.getDefault().asyncExec(showRunnable);
- }
-
- }
- catch (Exception e)
- {
- // unexpected
- }
-
- // yantzi: artemis 6.0: reset restore from memento flag
- if (ss != null && ss.supportsCaching())
- {
- ss.getCacheManager().setRestoreFromMemento(false);
- }
- }
- }
- else if (object instanceof ISystemFilterReference)
- {
-
- ISystemFilterReference fref = (ISystemFilterReference)object;
- ISubSystem ss = fref.getSubSystem();
-
- boolean isRestoringCache = ss.getCacheManager() != null && ss.getCacheManager().isRestoreFromMemento();
-
- if (!ss.isOffline()){
- if (!ss.isConnected() && !isRestoringCache){
- try
- {
- ss.connect(monitor, false);
- }
- catch (Exception e){
- return Status.CANCEL_STATUS;
- }
- }
- if (ss.isConnected() || isRestoringCache)
- {
- // get the adapter
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)object).getAdapter(ISystemViewElementAdapter.class);
-
- // get the context
- ContextObject contextObject = new ContextObject(fref, ss, fref);
-
- // get the children
- Object[] children = adapter.getChildren(contextObject, monitor);
-
- ShowRestoredRemoteObject showRunnable = new ShowRestoredRemoteObject(fref, children);
- Display.getDefault().asyncExec(showRunnable);
- }
- }
- }
- }
- boolean restoreFromCache = RSEUIPlugin.getDefault().getPreferenceStore().getBoolean(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE);
- // yantzi: artemis 6.0, restore memento flag for affected subsystems
- if (restoreFromCache)
- {
- for (int i = 0; i < _cacheSubSystemList.size(); i++)
- {
- ((ISubSystem) _cacheSubSystemList.get(i)).getCacheManager().setRestoreFromMemento(false);
- }
- }
-
- return Status.OK_STATUS;
- }
- }
-
- protected class RemoteObject
- {
- public String name;
- public ISubSystem subsystem;
- public ISystemFilterReference fRef;
- public ISystemFilterStringReference fsRef;
-
- public RemoteObject(String name, ISubSystem ss, ISystemFilterReference fRef, ISystemFilterStringReference fsRef)
- {
- this.name = name;
- this.subsystem = ss;
- this.fRef = fRef;
- this.fsRef = fsRef;
- }
-
- public String toString()
- {
- return "Remote object: " + name; //$NON-NLS-1$
- }
-
- public boolean equals(RemoteObject compared)
- {
- if (name.equals(compared.name) &&
- subsystem == compared.subsystem &&
- fRef == compared.fRef)
- return true;
-
- return false;
- }
- }
-
- protected IPartListener partListener = new IPartListener()
- {
- public void partActivated(IWorkbenchPart part)
- {
- if (part instanceof IEditorPart)
- editorActivated((IEditorPart) part);
- }
- public void partBroughtToTop(IWorkbenchPart part)
- {
- }
- public void partClosed(IWorkbenchPart part)
- {
- }
- public void partDeactivated(IWorkbenchPart part)
- {
- }
- public void partOpened(IWorkbenchPart part)
- {
- }
- };
-
- public class RestoreStateRunnable extends UIJob
- {
- protected IMemento _memento;
- public RestoreStateRunnable(IMemento memento)
- {
- super("Restore RSE Tree"); //$NON-NLS-1$
- _memento = memento;
-
- }
-
- public IStatus runInUIThread(IProgressMonitor monitor)
- {
- IMemento memento = _memento;
- //System.out.println("SYSTEMVIEWPART: restoreState");
- if (!SystemPreferencesManager.getRememberState())
- return Status.CANCEL_STATUS;
-
- // restore the show filter pools and show filter strings settings as they were when this was saved
- boolean showFilterPools = false;
- boolean showFilterStrings = false;
-
-
- String savedValue = memento.getString(TAG_SHOWFILTERPOOLS);
- if (savedValue != null)
- showFilterPools = savedValue.equals("t"); //$NON-NLS-1$
- else
- showFilterPools = SystemPreferencesManager.getShowFilterPools();
- savedValue = memento.getString(TAG_SHOWFILTERSTRINGS); // historical
- if (savedValue != null)
- showFilterStrings = savedValue.equals("t"); //$NON-NLS-1$
- //else
- //showFilterStrings = SystemPreferencesManager.getPreferencesManager().getShowFilterStrings();
-
- IMemento childMem = null;
-
- // restore expand-to hashtable state
- childMem = memento.getChild(TAG_EXPANDED_TO);
- if (childMem != null)
- {
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
- Hashtable ht = new Hashtable();
- for (int i = 0; i < elementMem.length; i++)
- {
- String key = elementMem[i].getString(TAG_PATH);
- String value = elementMem[i].getString(TAG_FILTER);
- if ((key != null) && (value != null))
- ht.put(key, value);
- }
- if (ht.size() > 0)
- systemView.setExpandToFilterTable(ht);
- }
- // restore expansion state
- childMem = memento.getChild(TAG_EXPANDED);
- Vector remoteElementsToRestore = new Vector();
- List cacheSubSystemList = new ArrayList();
- if (childMem != null)
- {
- ArrayList elements = new ArrayList();
-
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
-
- // yantzi: artemis6.0, keep track subsystems which have their memento flag set in order
- // to restore system view from cache (if the subsystem supports this)
-
- ISubSystem cacheSubSystem;
- boolean restoreFromCache = RSEUIPlugin.getDefault().getPreferenceStore().getBoolean(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE);
-
- // walk through list of expanded nodes, breaking into 2 lists: non-remote and remote
- for (int i = 0; i < elementMem.length; i++)
- {
- Object element = getObjectFromMemento(showFilterPools, showFilterStrings, elementMem[i].getString(TAG_PATH));
- if (element != null)
- if (element instanceof RemoteObject) // this is a remote object
- {
- remoteElementsToRestore.add(element);
- //System.out.println("Added to remote expansion list: " + element);
- }
- else if (element instanceof ISystemFilterReference)
- {
- remoteElementsToRestore.add(element); // filters trigger asynchronous queries, so best to expand this with remote items
-
- if (restoreFromCache)
- {
- // yantzi: artemis 6.0, see comment above
- cacheSubSystem = ((ISystemFilterReference)element).getSubSystem();
- if (cacheSubSystem.supportsCaching() && cacheSubSystem.getCacheManager() != null)
- {
- cacheSubSystem.getCacheManager().setRestoreFromMemento(true);
- cacheSubSystemList.add(cacheSubSystem);
- }
- }
- }
- else
- {
- elements.add(element);
- //System.out.println("Added to non-remote expansion list: " + element);
- }
- }
- // expand non-remote...
- systemView.setExpandedElements(elements.toArray());
- }
-
- // restoreSelection
- childMem = memento.getChild(TAG_SELECTION);
-
- Vector remoteElementsToSelect = new Vector();
- if (childMem != null)
- {
- ArrayList list = new ArrayList();
-
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
- for (int i = 0; i < elementMem.length; i++)
- {
- Object element = getObjectFromMemento(showFilterPools, showFilterStrings, elementMem[i].getString(TAG_PATH));
- if (element != null)
- if (element instanceof RemoteObject) // this is a remote object
- remoteElementsToSelect.add(element);
- else
- list.add(element);
- //System.out.println("Added to selection list: " + element);
- }
- if (list.size()>0) {
- systemView.setSelection(new StructuredSelection(list));
- }
- }
-
- if (remoteElementsToRestore.size() > 0)
- {
- RestoreRemoteObjects restoreRemoteJob = new RestoreRemoteObjects(remoteElementsToRestore, cacheSubSystemList, remoteElementsToSelect);
- restoreRemoteJob.schedule();
- }
-
- Tree tree = systemView.getTree();
- //restore vertical position
- ScrollBar bar = tree.getVerticalBar();
- if (bar != null)
- {
- try
- {
- String posStr = memento.getString(TAG_VERTICAL_POSITION);
- if (posStr != null)
- {
- int position;
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- //restore vertical position
- bar = tree.getHorizontalBar();
- if (bar != null)
- {
- try
- {
- String posStr = memento.getString(TAG_HORIZONTAL_POSITION);
- if (posStr != null)
- {
- int position;
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
-
-
- String linkWithEditor = memento.getString(TAG_LINKWITHEDITOR);
- if (linkWithEditor != null)
- {
- if (linkWithEditor.equals("t")) //$NON-NLS-1$
- _isLinkingEnabled = true;
- else
- _isLinkingEnabled = false;
- }
- else
- {
- _isLinkingEnabled = false;
- }
-
-
-
- return Status.OK_STATUS;
- }
-
- }
-
- // THE FOLLOWING ARE TO ENABLE PERSISTENCE OF NON-PRIMARY REMOTE SYSTEM EXPLORER VIEWS OPENED UP BY THE
- // USER RIGHT CLICKING AND SELECTING "OPEN IN NEW PERSPECTIVE".
-
- // --------------------------
- // IElementFactory methods...
- // --------------------------
- /**
- * Given the memento created by saveState, for the input to the perspective, recreate the input object
- * at startup time.
- * See the extension point for "org.eclipse.ui.elementFactories" in plugin.xml
- */
- public IAdaptable createElement(IMemento memento)
- {
- //System.out.println("INSIDE CREATEELEMENT IN SYSTEMVIEWPART. TAG_INPUT STRING = "+memento.getString(TAG_INPUT));
- IAdaptable element = null;
- Object object = null;
-
- // restore the show filter pools and show filter strings settings as they were when this was saved
- boolean showFilterPools = false;
- boolean showFilterStrings = false;
- String savedValue = memento.getString(TAG_SHOWFILTERPOOLS);
- if (savedValue != null)
- showFilterPools = savedValue.equals("t"); //$NON-NLS-1$
- else
- showFilterPools = SystemPreferencesManager.getShowFilterPools();
-
- savedValue = memento.getString(TAG_SHOWFILTERSTRINGS);
- if (savedValue != null)
- showFilterStrings = savedValue.equals("t"); //$NON-NLS-1$
- //else
- // showFilterStrings = SystemPreferencesManager.getPreferencesManager().getShowFilterStrings();
-
- object = getObjectFromMemento(showFilterPools, showFilterStrings, memento.getString(TAG_INPUT));
-
- // For now we don't allow secondary perspectives to be opened on remote objects, so we are lucky!
- if (object instanceof RemoteObject)
- {
- }
- else if (object instanceof IAdaptable)
- element = (IAdaptable) object;
- //System.out.println("... RETURNING "+element);
- return element;
- }
-
- // ------------------------------
- // IPersistableElement methods...
- // ------------------------------
- /**
- * Return the element factory ID as declared in the extension point for "org.eclipse.ui.elementFactories" in plugin.xml
- */
- public String getFactoryId()
- {
- //System.out.println("INSIDE GETFACTORYID IN SYSTEMVIEWPART");
- return "org.eclipse.rse.systemview.elementfactory"; //$NON-NLS-1$
- }
-
- /*
- * The workbench is closing, and we are being asked to save the state of the input object in one of the secondary perspectives
- *
- public void saveState(IMemento memento)
- {
-
- }*/
-
- /**
- * The workbench is closing, and we are being asked to save the state of the input object in one of the secondary perspectives.
- * This method is called by our saveState when it detects this is a save for the input vs a page save.
- */
- protected void saveInputState(IMemento memento)
- {
- //System.out.println("INSIDE SAVEINPUTSTATE IN SYSTEMVIEWPART");
- IAdaptable inputObj = getSite().getPage().getInput();
- ISystemViewElementAdapter adapter = systemView.getViewAdapter(inputObj);
- if ((adapter != null) && (adapter.saveExpansionState(inputObj)))
- {
- String handle = getInputMementoHandle(inputObj, adapter);
- if (handle != null)
- {
- //System.out.println("... saving memento string: "+handle);
- memento.putString(TAG_INPUT, handle);
- }
- }
- }
- protected String getInputMementoHandle(Object o, ISystemViewElementAdapter adapter)
- {
- StringBuffer idBuffer = new StringBuffer(adapter.getMementoHandleKey(o));
- idBuffer.append(MEMENTO_DELIM + adapter.getInputMementoHandle(o));
- return idBuffer.toString();
- }
-
- // --------------------------------
- // IAdapterFactory methods...
- // --------------------------------
- /**
- * @see IAdapterFactory#getAdapterList()
- */
- public Class[] getAdapterList()
- {
- return new Class[] { IPersistableElement.class };
- }
-
- /**
- * Called by our plugin's startup method to register our adaptable object types
- * with the platform. We prefer to do it here to isolate/encapsulate all factory
- * logic in this one place.
- */
- public void registerWithManager(IAdapterManager manager, Object input)
- {
- //System.out.println("INSIDE REGISTERWITHMANAGER IN SYSTEMVIEWPART");
- // these are all the object types we allow the user to select "Open in New Perspective" on...
- manager.registerAdapters(this, input.getClass());
- }
- /**
- * Called by our plugin's startup method to register our adaptable object types
- * with the platform. We prefer to do it here to isolate/encapsulate all factory
- * logic in this one place.
- */
- public void unregisterWithManager(IAdapterManager manager)
- {
- //System.out.println("INSIDE UNREGISTERWITHMANAGER IN SYSTEMVIEWPART");
- // these are all the object types we allow the user to select "Open in New Perspective" on...
- manager.unregisterAdapters(this);
- }
-
- /**
- * @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptableObject, Class adapterType)
- {
- //System.out.println("INSIDE GETADAPTER IN SYSTEMVIEWPART. adaptableObject = "+adaptableObject+", adapterType = "+adapterType.getName());
- // we don't try to restore these secondary perspectives unless user has elected to do so...
- if (!SystemPreferencesManager.getRememberState())
- return null;
- else
- return this;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPartFrameSource.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPartFrameSource.java
deleted file mode 100644
index 0650836d7..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPartFrameSource.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.ui.views.framelist.TreeFrame;
-import org.eclipse.ui.views.framelist.TreeViewerFrameSource;
-
-/**
- * Enables frameset for the Remote System Explorer view part
- */
-class SystemViewPartFrameSource extends TreeViewerFrameSource
-{
-
- // has same interface as org.eclipse.ui.views.navigator.NavigatorFrameSource
-
- private SystemViewPart fSystemViewPart;
-
- SystemViewPartFrameSource(SystemViewPart viewPart)
- {
- super(viewPart.getSystemView());
- fSystemViewPart = viewPart;
- }
-
- protected TreeFrame createFrame(Object input)
- {
- TreeFrame frame = super.createFrame(input);
- frame.setName(fSystemViewPart.getFrameName(input));
- frame.setToolTipText(fSystemViewPart.getFrameToolTipText(input));
- return frame;
- }
-
- /**
- * Also updates the title of the Remote Systems view part
- */
- protected void frameChanged(TreeFrame frame)
- {
- super.frameChanged(frame);
- fSystemViewPart.updateTitle();
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPartGotoActionGroup.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPartGotoActionGroup.java
deleted file mode 100644
index afc81cf81..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPartGotoActionGroup.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.rse.internal.ui.GenericMessages;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.views.framelist.BackAction;
-import org.eclipse.ui.views.framelist.ForwardAction;
-import org.eclipse.ui.views.framelist.FrameList;
-import org.eclipse.ui.views.framelist.UpAction;
-
-
-
-/**
- * Enables typical frameset actions for Remote System Explorer view part
- */
-public class SystemViewPartGotoActionGroup extends ActionGroup
-{
-
- protected SystemViewPart fSystemViewPart;
- protected BackAction backAction;
- protected ForwardAction forwardAction;
- //private GoIntoAction goIntoAction;
- protected UpAction upAction;
-
-
- /**
- * Constructor
- */
- public SystemViewPartGotoActionGroup(SystemViewPart viewPart)
- {
- fSystemViewPart = viewPart;
- makeActions();
- }
-
- /**
- * Returns the RSE view part associated with this action group
- */
- public SystemViewPart getSystemViewPart()
- {
- return fSystemViewPart;
- }
-
- protected void makeActions()
- {
- FrameList frameList = fSystemViewPart.getFrameList();
- //goIntoAction = new GoIntoAction(frameList);
- backAction = new BackAction(frameList);
- forwardAction = new ForwardAction(frameList);
- upAction = new UpAction(frameList);
- }
-
- public void fillContextMenu(IMenuManager menu)
- {
- // we actually don't call this! See instead SystemCascadingGoToAction
- //menu.add(goIntoAction); // done in SystemView
- MenuManager gotoMenu =
- new MenuManager(GenericMessages.ResourceNavigator_goto);
- menu.add(gotoMenu);
- gotoMenu.add(backAction);
- gotoMenu.add(forwardAction);
- gotoMenu.add(upAction);
- }
-
- public void fillActionBars(IActionBars actionBars)
- {
- //actionBars.setGlobalActionHandler(
- // ActionFactory.GO_INTO,
- // goIntoAction);
- actionBars.setGlobalActionHandler(
- ActionFactory.BACK.getId(),
- backAction);
- actionBars.setGlobalActionHandler(
- ActionFactory.FORWARD.getId(),
- forwardAction);
- actionBars.setGlobalActionHandler(ActionFactory.UP.getId(),upAction);
-
- IToolBarManager toolBar = actionBars.getToolBarManager();
- toolBar.add(backAction);
- toolBar.add(forwardAction);
- toolBar.add(upAction);
- }
-
- public void updateActionBars()
- {
- getContext().getSelection();
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPromptableAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPromptableAdapter.java
deleted file mode 100644
index 8e413ef34..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPromptableAdapter.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.internal.ui.actions.SystemRunAction;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.model.ISystemPromptableObject;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.swt.widgets.Shell;
-
-
-
-/**
- * Adapter for displaying special-case prompt objects in the system views.
- * These are objects that, when expanded, launch a wizard to create something.
- */
-public class SystemViewPromptableAdapter
- extends AbstractSystemViewAdapter
-{
- protected SystemRunAction runAction;
-
- /**
- * Return the actions to show in the popup menu for the current selection
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- ISystemPromptableObject object = (ISystemPromptableObject)selection.getFirstElement();
- if ((object != null) && !object.hasChildren())
- {
- if (runAction == null)
- runAction = getRunAction(shell);
- menu.add(menuGroup, runAction);
- }
- }
-
- /**
- * Only called if the selected object has no children.
- * @param shell the shell.
- * @return the run action.
- */
- protected SystemRunAction getRunAction(Shell shell) {
- return (new SystemRunAction(shell));
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- return ((ISystemPromptableObject)element).getImageDescriptor();
- }
-
- /**
- * Return the label for this object.
- */
- public String getText(Object element)
- {
- return ((ISystemPromptableObject)element).getText();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- return getText(element);
- }
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- return ((ISystemPromptableObject)element).getType();
- }
-
- /**
- * Return the parent of this object.
- */
- public Object getParent(Object element)
- {
- return ((ISystemPromptableObject)element).getParent();
- }
-
- /**
- * Return the children of this object. Not applicable for us.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- // Note: Do _not_ call promptable.run(getShell()) here. It leads only to
- // senseless invocations of the new connection wizard dialog on refreshs!
- // It cannot be a desirable effect of refreshing the system view to create
- // new connections. We leave the invocation of the dialog to the double
- // click handler and the context menu.
- ISystemPromptableObject promptable = (ISystemPromptableObject)element;
- return promptable.getChildren();
- }
-
- /**
- * Return true if this object has children.
- * We return true, as either we'll expand and prompt, or expand and show child prompts
- */
- public boolean hasChildren(IAdaptable element)
- {
- ISystemPromptableObject promptable = (ISystemPromptableObject)element;
- return promptable.hasChildren();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#handleDoubleClick(java.lang.Object)
- */
- public boolean handleDoubleClick(Object element) {
- ISystemPromptableObject promptable = (ISystemPromptableObject)element;
- promptable.run(getShell());
- return true;
- }
-
- /**
- * Return our unique property descriptors
- */
- protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- return null;
- }
- /**
- * Return our unique property values
- */
- public Object internalGetPropertyValue(Object key)
- {
- return null;
- }
- /**
- * Don't show delete
- */
- public boolean showDelete(Object element)
- {
- return false;
- }
-
- /**
- * Don't show rename
- */
- public boolean showRename(Object element)
- {
- return false;
- }
-
- /**
- * Do show refresh, expand and collapse, but only if there are children
- */
- public boolean showRefresh(Object element)
- {
- ISystemPromptableObject promptable = (ISystemPromptableObject)element;
- return promptable.hasChildren();
- }
-
- /**
- * Don't show "Open in new perspective"
- */
- public boolean showOpenViewActions(Object element)
- {
- return false;
- }
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
-
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- * This just defaults to getName, but if that is not sufficient override it here.
- */
- public String getMementoHandle(Object element)
- {
- return getName(element);
- }
- /**
- * Return a short string to uniquely identify the type of resource. Eg "conn" for connection.
- * This just defaults to getType, but if that is not sufficient override it here, since that is
- * a translated string.
- */
- public String getMementoHandleKey(Object element)
- {
- return "Prompt"; //$NON-NLS-1$
- }
-
- /**
- * Somtimes we don't want to remember an element's expansion state, such as for temporarily inserted
- * messages. In these cases return false from this method. The default is true.
- * <p>
- * WE RETURN FALSE.
- */
- public boolean saveExpansionState(Object element)
- {
- return false;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewResources.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewResources.java
deleted file mode 100644
index 37718f4c2..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewResources.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
- * David McKnight (IBM) - [216252] [nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
- * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
- * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.osgi.util.NLS;
-
-
-/**
- * Constants used throughout the SystemView plugin
- */
-public class SystemViewResources extends NLS {
- private static String BUNDLE_NAME = "org.eclipse.rse.internal.ui.view.SystemViewResources"; //$NON-NLS-1$
-
- // -------------------------
- // Property names...
- // -------------------------
- // Property sheet values: Common
- public static String RESID_PROPERTY_NBRCHILDREN_LABEL;
- public static String RESID_PROPERTY_NBRCHILDREN_TOOLTIP;
-
- // Property sheet values: Connections
- public static String RESID_PROPERTY_PROFILE_TYPE_VALUE;
-
- public static String RESID_PROPERTY_PROFILESTATUS_LABEL;
- public static String RESID_PROPERTY_PROFILESTATUS_TOOLTIP;
-
- public static String RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL;
-
- public static String RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL;
-
- public static String RESID_PROPERTY_CONNECTION_TYPE_VALUE;
-
- public static String RESID_PROPERTY_SYSTEMTYPE_LABEL;
- public static String RESID_PROPERTY_SYSTEMTYPE_TOOLTIP;
-
- public static String RESID_PROPERTY_CONNECTIONSTATUS_LABEL;
- public static String RESID_PROPERTY_CONNECTIONSTATUS_TOOLTIP;
- public static String RESID_PROPERTY_CONNECTIONSTATUS_CONNECTED_VALUE;
-
- public static String RESID_PROPERTY_CONNECTIONSTATUS_DISCONNECTED_VALUE;
-
-
- public static String RESID_PROPERTY_HOSTNAME_LABEL;
- public static String RESID_PROPERTY_HOSTNAME_TOOLTIP;
-
- public static String RESID_PROPERTY_DEFAULTUSERID_LABEL;
- public static String RESID_PROPERTY_DEFAULTUSERID_TOOLTIP;
-
- public static String RESID_PROPERTY_CONNDESCRIPTION_LABEL;
- public static String RESID_PROPERTY_CONNDESCRIPTION_TOOLTIP;
-
- public static String RESID_PROPERTY_PROFILE_LABEL;
- public static String RESID_PROPERTY_PROFILE_TOOLTIP;
-
-
- // Property sheet values: SubSystems
- public static String RESID_PROPERTY_SUBSYSTEM_TYPE_VALUE;
-
- public static String RESID_PROPERTY_USERID_LABEL;
- public static String RESID_PROPERTY_USERID_TOOLTIP;
-
- public static String RESID_PROPERTY_PORT_LABEL;
- public static String RESID_PROPERTY_PORT_TOOLTIP;
-
- public static String RESID_PROPERTY_CONNECTED_TOOLTIP;
- public static String RESID_PROPERTY_CONNECTED_LABEL;
-
- public static String RESID_PROPERTY_VRM_LABEL;
- public static String RESID_PROPERTY_VRM_TOOLTIP;
-
- // Property sheet values: Filter Pools
- public static String RESID_PROPERTY_FILTERPOOL_TYPE_VALUE;
-
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_TYPE_VALUE;
-
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_LABEL;
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_TOOLTIP;
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_LABEL;
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_TOOLTIP;
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL;
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP;
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_LABEL;
- public static String RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_TOOLTIP;
-
- // Property sheet values: Filters
- public static String RESID_PROPERTY_FILTERSTRING_LABEL;
- public static String RESID_PROPERTY_FILTERSTRING_TOOLTIP;
-
- public static String RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL;
- public static String RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP;
-
- public static String RESID_PROPERTY_FILTERPARENTFILTER_LABEL;
- public static String RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP;
-
- public static String RESID_PROPERTY_FILTERPARENTPOOL_LABEL;
- public static String RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP;
-
- // files - still needed outside of files.ui
- public static String RESID_PROPERTY_FILE_TYPE_FILE_VALUE;
- public static String RESID_PROPERTY_FILE_TYPE_FOLDER_VALUE;
- public static String RESID_PROPERTY_FILE_TYPE_ROOT_VALUE;
-
- public static String RESID_PROPERTY_FILE_PATH_LABEL;
- public static String RESID_PROPERTY_FILE_PATH_TOOLTIP;
-
-
- // Property sheet values: Messages
- public static String RESID_PROPERTY_MESSAGE_TYPE_VALUE;
-
- // Property sheet values: Categories in Team view
- public static String RESID_PROPERTY_TEAM_CATEGORY_TYPE_VALUE;
- public static String RESID_PROPERTY_TEAM_SSFACTORY_TYPE_VALUE;
- public static String RESID_PROPERTY_TEAM_PROPERTYSET_TYPE_VALUE;
-
- // Miscellaneous / common
- public static String RESID_SCRATCHPAD;
- public static String RESID_REMOTE_SCRATCHPAD;
-
- public static String RESID_FETCHING;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, SystemViewResources.class);
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewResources.properties b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewResources.properties
deleted file mode 100644
index f8babdf3d..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewResources.properties
+++ /dev/null
@@ -1,117 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 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 available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Initial Contributors:
-# The following IBM employees contributed to the Remote System Explorer
-# component that contains this file: David McKnight, Kushal Munir,
-# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
-# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
-#
-# Contributors:
-# David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
-# David McKnight (IBM) - [216252] [nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
-# David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
-# Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View
-###############################################################################
-
-# NLS_MESSAGEFORMAT_VAR
-# NLS_ENCODING=UTF-8
-
-#COMMON PROPERTIES
-RESID_PROPERTY_NBRCHILDREN_LABEL=Number of children
-RESID_PROPERTY_NBRCHILDREN_TOOLTIP=Number of children currently under this parent
-
-#CONNECTION PROPERTIES
-RESID_PROPERTY_SYSTEMTYPE_LABEL=Remote system type
-RESID_PROPERTY_SYSTEMTYPE_TOOLTIP=System type of remote host
-RESID_PROPERTY_PROFILE_TYPE_VALUE=Profile
-RESID_PROPERTY_PROFILESTATUS_LABEL=Status
-RESID_PROPERTY_PROFILESTATUS_TOOLTIP=Active status of this profile. Connections and filters are shown for active profiles only
-RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL=Active
-RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL=Not active
-RESID_PROPERTY_CONNECTION_TYPE_VALUE=Connection
-RESID_PROPERTY_CONNECTIONSTATUS_LABEL=Connection status
-RESID_PROPERTY_CONNECTIONSTATUS_TOOLTIP=Connection status of subsystems
-RESID_PROPERTY_CONNECTIONSTATUS_CONNECTED_VALUE=Some subsystems connected
-RESID_PROPERTY_CONNECTIONSTATUS_DISCONNECTED_VALUE=No subsystems connected
-
-RESID_PROPERTY_HOSTNAME_LABEL=Host name
-RESID_PROPERTY_HOSTNAME_TOOLTIP=Host name or IP address of remote system
-
-RESID_PROPERTY_DEFAULTUSERID_LABEL=Default User ID
-RESID_PROPERTY_DEFAULTUSERID_TOOLTIP=Default user ID when no user ID in subsystem
-
-RESID_PROPERTY_CONNDESCRIPTION_LABEL=Description
-RESID_PROPERTY_CONNDESCRIPTION_TOOLTIP=Description of this connection
-
-RESID_PROPERTY_PROFILE_LABEL=Parent profile
-RESID_PROPERTY_PROFILE_TOOLTIP=Profile that owns this connection
-
-
-#SUBSYSTEM PROPERTIES
-RESID_PROPERTY_SUBSYSTEM_TYPE_VALUE=Subsystem
-
-RESID_PROPERTY_USERID_LABEL=User ID
-RESID_PROPERTY_USERID_TOOLTIP=User ID for connecting to this service
-
-RESID_PROPERTY_PORT_LABEL=Port
-RESID_PROPERTY_PORT_TOOLTIP=Port to use when connecting to this remote subsystem
-
-RESID_PROPERTY_CONNECTED_TOOLTIP=Currently connected to this service?
-RESID_PROPERTY_CONNECTED_LABEL=Connected
-
-RESID_PROPERTY_VRM_LABEL=Version
-RESID_PROPERTY_VRM_TOOLTIP=Version, release and modification of remote system, if available
-
-
-#FILTER POOL PROPERTIES
-RESID_PROPERTY_FILTERPOOL_TYPE_VALUE=Filter pool
-RESID_PROPERTY_FILTERPOOLREFERENCE_TYPE_VALUE=Filter pool reference
-
-RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_LABEL=Referenced filter pool
-RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_TOOLTIP=Filter pool this references
-RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_LABEL=Parent profile
-RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_TOOLTIP=Profile containing referenced filter pool
-RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL=Related connection
-RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP=If this is a connection-private filter pool, this is the name of that connection
-RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_LABEL=Connection-private
-RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_TOOLTIP=Is this is a connection-private filter pool, which only exists for this connection?
-
-
-#FILTER PROPERTIES
-RESID_PROPERTY_FILTERSTRING_LABEL=Filter string
-RESID_PROPERTY_FILTERSTRING_TOOLTIP=Filter string used to get this resource
-
-RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL=Number of filter strings
-RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP=How many filter strings contained in this filter
-
-RESID_PROPERTY_FILTERPARENTFILTER_LABEL=Parent filter
-RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP=Filter containing this nested filter
-
-RESID_PROPERTY_FILTERPARENTPOOL_LABEL=Parent filter pool
-RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP=Filter pool that directly or indirectly contains this filter
-
-# generic files - needed outside of files.ui
-RESID_PROPERTY_FILE_TYPE_FILE_VALUE=File
-RESID_PROPERTY_FILE_TYPE_FOLDER_VALUE=Folder
-RESID_PROPERTY_FILE_TYPE_ROOT_VALUE=Root
-RESID_PROPERTY_FILE_PATH_LABEL=Location
-RESID_PROPERTY_FILE_PATH_TOOLTIP=Path containing this file or folder
-
-#MESSAGE PROPERTIES
-RESID_PROPERTY_MESSAGE_TYPE_VALUE=Message
-
-#TEAM VIEW PROPERTIES
-RESID_PROPERTY_TEAM_CATEGORY_TYPE_VALUE=Category
-RESID_PROPERTY_TEAM_SSFACTORY_TYPE_VALUE=SubSystem factory
-RESID_PROPERTY_TEAM_PROPERTYSET_TYPE_VALUE=Property set
-
-
-RESID_SCRATCHPAD=Scratchpad
-RESID_REMOTE_SCRATCHPAD=Remote Scratchpad
-
-RESID_FETCHING = Fetching Remote Resources
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewRootInputAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewRootInputAdapter.java
deleted file mode 100644
index 96cafe7cb..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewRootInputAdapter.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David Dykstal (IBM) - moved SystemsPreferencesManager to a new package
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [190195] Cannot enable new connection prompt in system view
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * David McKnight (IBM) - [216252] [nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.SystemPreferencesManager;
-import org.eclipse.rse.ui.internal.model.SystemNewConnectionPromptObject;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.swt.widgets.Shell;
-
-
-
-/**
- * Adapter for the root-providing object of the SystemView tree viewer.
- */
-public class SystemViewRootInputAdapter extends AbstractSystemViewAdapter
-{
- private SystemNewConnectionPromptObject newConnPrompt;
- private Object[] newConnPromptArray;
-
- /**
- * Ctor
- */
- public SystemViewRootInputAdapter()
- {
-
- }
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given element.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
-
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- return null;
- }
-
- /**
- * Return the label for this object
- */
- public String getText(Object element)
- {
- return SystemResources.RESID_SYSTEMREGISTRY_CONNECTIONS;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- return getText(element);
- }
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- //return "System Root Provider"; // should never be called
- // DKM - MRI hack to get "root"
- return SystemViewResources.RESID_PROPERTY_FILE_TYPE_ROOT_VALUE;
- }
-
- /**
- * Return the parent of this object
- */
- public Object getParent(Object element)
- {
- return null;
- }
-
- /**
- * Return the children of this object
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- ISystemViewInputProvider provider = (ISystemViewInputProvider)element;
-
- if ((provider instanceof ISystemRegistry) && showNewConnectionPrompt())
- {
- Object[] children = provider.getSystemViewRoots();
- if ((children == null) || (children.length == 0))
- {
- return getNewConnectionPromptObjectAsArray();
- }
- else
- {
- Object[] allChildren = new Object[children.length+1];
- allChildren[0] = getNewConnectionPromptObject();
- for (int idx=0; idx<children.length; idx++)
- allChildren[idx+1] = children[idx];
- return allChildren;
- }
- }
- return provider.getSystemViewRoots();
- }
-
- /**
- * Return true if this object has children
- */
- public boolean hasChildren(IAdaptable element)
- {
- ISystemViewInputProvider provider = (ISystemViewInputProvider)element;
- if ((provider instanceof ISystemRegistry) && showNewConnectionPrompt())
- {
- return true;
- }
- return provider.hasSystemViewRoots();
- }
-
- // FOR COMMON DELETE ACTIONS
- /**
- * We don't support delete at all.
- */
- public boolean showDelete(Object element)
- {
- return false;
- }
-
- // FOR COMMON RENAME ACTIONS
- /**
- * We don't support rename at all.
- */
- public boolean showRename(Object element)
- {
- return false;
- }
- /**
- * Return a validator for verifying the new name is correct.
- */
- public ISystemValidator getNameValidator(Object element)
- {
- return null;
- }
-
- // PRIVATE METHODS...
-
- private boolean showNewConnectionPrompt()
- {
- return SystemPreferencesManager.getShowNewConnectionPrompt();
- }
-
- private SystemNewConnectionPromptObject getNewConnectionPromptObject()
- {
- if (newConnPrompt == null)
- newConnPrompt = new SystemNewConnectionPromptObject();
- return newConnPrompt;
- }
-
- private Object[] getNewConnectionPromptObjectAsArray()
- {
- if (newConnPromptArray == null)
- newConnPromptArray = new Object[1];
- newConnPromptArray[0] = getNewConnectionPromptObject();
- return newConnPromptArray;
- }
- /**
- * Return our unique property descriptors
- */
- protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- return null;
- }
- /**
- * Return our unique property values
- */
- public Object internalGetPropertyValue(Object key)
- {
- return null;
- }
-
-
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- * We return "Connections"
- */
- public String getMementoHandle(Object element)
- {
- return "Connections"; // this is what getName() returns, but if we xlate the name we want this to remain in english. //$NON-NLS-1$
- }
- /**
- * Return a short string to uniquely identify the type of resource. Eg "conn" for connection.
- * This just defaults to getType, but if that is not sufficient override it here, since that is
- * a translated string.
- */
- public String getMementoHandleKey(Object element)
- {
- // this really should not be translated... but changing it now might cause a problem restoring
- // from a previous release. Phil.
- return getType(element);
- //return "root";
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewScratchpadAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewScratchpadAdapter.java
deleted file mode 100644
index 5097b8b62..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewScratchpadAdapter.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Xuan Chen (IBM) - [223126] [api][breaking] Remove API related to User Actions in RSE Core/UI
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction;
-import org.eclipse.rse.ui.internal.model.SystemScratchpad;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.swt.widgets.Shell;
-
-
-
-/**
- * Adapter for the root-providing object of the SystemView tree viewer.
- */
-public class SystemViewScratchpadAdapter extends AbstractSystemViewAdapter implements ISystemRemoteElementAdapter,ISystemDragDropAdapter
-{
-
- private SystemPasteFromClipboardAction _pasteToScratchpadAction = null;
-
- public SystemViewScratchpadAdapter()
- {
- }
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given element.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- if (_pasteToScratchpadAction == null)
- {
- _pasteToScratchpadAction = new SystemPasteFromClipboardAction(shell, RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard());
- }
- menu.add(menuGroup, _pasteToScratchpadAction);
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- return null;
- }
-
- /**
- * Return the label for this object
- */
- public String getText(Object element)
- {
- return SystemViewResources.RESID_REMOTE_SCRATCHPAD;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- return getText(element);
- }
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- return SystemViewResources.RESID_SCRATCHPAD;
- }
-
- /**
- * Return the parent of this object
- */
- public Object getParent(Object element)
- {
- return null;
- }
-
- /**
- * Return the children of this object
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- SystemScratchpad pad = (SystemScratchpad)element;
- return pad.getChildren();
- }
-
- /**
- * Return true if this object has children
- */
- public boolean hasChildren(IAdaptable element)
- {
- SystemScratchpad pad = (SystemScratchpad)element;
- return pad.hasChildren();
- }
-
- // FOR COMMON DELETE ACTIONS
- /**
- * We don't support delete at all.
- */
- public boolean showDelete(Object element)
- {
- return false;
- }
-
- // FOR COMMON RENAME ACTIONS
- /**
- * We don't support rename at all.
- */
- public boolean showRename(Object element)
- {
- return false;
- }
- /**
- * Return a validator for verifying the new name is correct.
- */
- public ISystemValidator getNameValidator(Object element)
- {
- return null;
- }
-
-
- /**
- * Return our unique property descriptors
- */
- protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- return null;
- }
- /**
- * Return our unique property values
- */
- public Object internalGetPropertyValue(Object key)
- {
- return null;
- }
-
-
- public boolean canDrop(Object element)
- {
- return true;
- }
-
- public Object doDrop(Object from, Object to, boolean sameSystemType, boolean sameSystem, int srcType, IProgressMonitor monitor)
- {
- if (to instanceof SystemScratchpad)
- {
- if (from instanceof List)
- {
- List set = (List)from;
- for (int i = 0;i < set.size(); i++)
- {
- ((SystemScratchpad)to).addChild(set.get(i));
- }
- }
- else
- {
- ((SystemScratchpad)to).addChild(from);
- }
- return from;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getAbsoluteParentName(java.lang.Object)
- */
- public String getAbsoluteParentName(Object element)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getSubSystemConfigurationId(java.lang.Object)
- */
- public String getSubSystemConfigurationId(Object element)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteTypeCategory(java.lang.Object)
- */
- public String getRemoteTypeCategory(Object element)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteType(java.lang.Object)
- */
- public String getRemoteType(Object element)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteSubType(java.lang.Object)
- */
- public String getRemoteSubType(Object element)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#refreshRemoteObject(java.lang.Object, java.lang.Object)
- */
- public boolean refreshRemoteObject(Object oldElement, Object newElement)
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParent(org.eclipse.swt.widgets.Shell, java.lang.Object)
- */
- public Object getRemoteParent(Object element, IProgressMonitor monitor) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#getRemoteParentNamesInUse(org.eclipse.swt.widgets.Shell, java.lang.Object)
- */
- public String[] getRemoteParentNamesInUse(Object element, IProgressMonitor monitor) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean validateDrop(Object src, Object target, boolean sameSystem)
- {
- return true;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewSubSystemAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewSubSystemAdapter.java
deleted file mode 100644
index 5546b573a..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewSubSystemAdapter.java
+++ /dev/null
@@ -1,818 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David Dykstal (IBM) - 180562: remove implementation of IRSEUserIdConstants
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * David Dykstal (IBM) - [217556] remove service subsystem types
- * Martin Oberhuber (Wind River) - [195399] Improve String display for default port 0
- * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
- * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.IConnectorService;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapter;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.validators.ValidatorPortInput;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ISystemPropertyConstants;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-
-
-/**
- * Adapter for displaying SubSystem objects in tree views.
- * These are children of SystemConnection objects
- */
-public class SystemViewSubSystemAdapter extends AbstractSystemViewAdapter
-{
- protected String translatedType;
- // for reset property support
- private String original_portData;
- private SystemInheritablePropertyData original_userIdData = new SystemInheritablePropertyData();
- //private SystemInheritablePropertyData original_portData = new SystemInheritablePropertyData();
- private TextPropertyDescriptor propertyPortDescriptor;
- private boolean changed_userId, changed_port;
- private boolean port_editable = true;
- // -------------------
- // property descriptors
- // -------------------
- private PropertyDescriptor[] propertyDescriptorArray = null;
- //private SystemInheritablePropertyData portData = new SystemInheritablePropertyData();
- //private SystemInheritableTextPropertyDescriptor portDescriptor;
- private SystemInheritablePropertyData userIdData = new SystemInheritablePropertyData();
- private SystemInheritableTextPropertyDescriptor userIdDescriptor = null;
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given subsystem object.
- * Calls the method getActions on the subsystem's factory, and places
- * all action objects returned from the call, into the menu.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- // does not make sense adding unique actions per multi-selection
- if (selection.size() == 1) {
- Object element = selection.getFirstElement();
- ISubSystem ss = (ISubSystem)element;
- ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration();
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter == null) {
- // FIXME Fallback to default SubSystemConfigurationAdapter, such
- // that we get at least the "connect" and other common actions
- // for subsystems before their adapter is loaded. Note that this
- // means that the popular "launch Shell" action will not be
- // available before the rse.shells.ui plugin is loaded; but that
- // should be fixed by contributing that action via plugin.xml,
- // rather than forcing full bundle activation here from the
- // menu. See
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=226550
- // //adapter = new SubSystemConfigurationAdapter();
- Platform.getAdapterManager().loadAdapter(ssFactory, ISubSystemConfigurationAdapter.class.getName());
- adapter = (ISubSystemConfigurationAdapter) ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
- // if (adapter == null) {
- // //TODO is this right? It deprives clients from the ability
- // //to get rid of the standard actions contributed by the
- // //default adapter. We shouldn't do that.
- // adapter = new SubSystemConfigurationAdapter();
- // }
- }
- if (adapter != null) {
- // Lazy Loading: Dynamic contributed subsystem actions will be
- // provided only once the corresponding plugin is activated
- // (adapter factory loaded). This means, that by default,
- // dynamic actions are only shown after connecting a subsystem.
- // If a subsystem needs to show these earlier, it needs to
- // provision for eager bundle activation to ensure that its
- // ISubSystemConfigurationAdapter is loaded -- or, provide these
- // actions by static plugin.xml markup.
- IAction[] actions = adapter.getSubSystemActions(menu, selection, shell, menuGroup, ssFactory, ss);
- if (actions != null)
- {
- for (int idx = 0; idx < actions.length; idx++) {
- IAction action = actions[idx];
- menu.add(menuGroup, action);
- }
- }
- }
- }
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_NEW, new GroupMarker(ISystemContextMenuConstants.GROUP_NEW_NONCASCADING));// user or BP/ISV additions
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- //System.out.println("INSIDE GETIMAGEDESCRIPTOR FOR SUBSYSTEM VIEW ADAPTER: "+element);
- ISubSystem ss = (ISubSystem)element;
- ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration();
- if (ssFactory != null)
- {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- if (ss.isConnected())
- return adapter.getLiveImage(ssFactory);
- else
- return adapter.getImage(ssFactory);
- } else {
- // get image from proxy
- ISubSystemConfigurationProxy proxy = ssFactory.getSubSystemConfigurationProxy();
- SubSystemConfigurationProxyAdapter proxyAdapter = (SubSystemConfigurationProxyAdapter) Platform.getAdapterManager().getAdapter(proxy,
- SubSystemConfigurationProxyAdapter.class);
- if (proxyAdapter != null) {
- if (ss.isConnected())
- return proxyAdapter.getLiveImageDescriptor();
- else
- return proxyAdapter.getImageDescriptor();
- } else {
- SystemBasePlugin.logWarning("Unexpected error: SubSystemConfiguration has no adapter and no proxyAdapter: " + ss.getName()); //$NON-NLS-1$
- return null;
- }
- }
- }
- else
- {
- SystemBasePlugin.logWarning("Unexpected error: SubSystemConfiguration is null for ss " + ss.getName()); //$NON-NLS-1$
- return null;
- }
- }
-
- /**
- * Return the label for this object. Uses getName() on the subsystem object.
- */
- public String getText(Object element)
- {
- return ((ISubSystem)element).getName();
- }
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- return ((ISubSystem)element).getName();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- ISubSystem ss = (ISubSystem)element;
- String suffix = ss.getName();
- Class serviceType = ss.getServiceType();
- if (serviceType != null) {
- suffix = serviceType.toString();
- }
- return ss.getSystemProfileName() + "." + ss.getHostAliasName() + "." + suffix; //$NON-NLS-1$ //$NON-NLS-2$
- }
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- if (translatedType == null)
- translatedType = SystemViewResources.RESID_PROPERTY_SUBSYSTEM_TYPE_VALUE;
- return translatedType;
- }
-
-
- /**
- * Return the parent of this object. This is a connection object.
- */
- public Object getParent(Object element)
- {
- //System.out.println("INSIDE GETPARENT FOR SUBSYSTEM VIEW ADAPTER: "+element);
- ISubSystem ss = (ISubSystem)element;
- return RSECorePlugin.getTheSystemRegistry().getHost(ss.getSystemProfile(),ss.getHostAliasName());
- }
-
- /**
- * Return the children of this object
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- //System.out.println("INSIDE GETCHILDREN FOR SUBSYSTEM VIEW ADAPTER: "+element);
- ISubSystem ss = (ISubSystem)element;
- Object[] children = ss.getChildren();
- return children;
- }
-
- /**
- * Return true if this object has children
- */
- public boolean hasChildren(IAdaptable element)
- {
- //System.out.println("INSIDE HASCHILDREN FOR SUBSYSTEM VIEW ADAPTER: "+element);
- ISubSystem ss = (ISubSystem)element;
- return ss.hasChildren();
- }
-
- // ----------------------------------
- // Property sheet supplier methods...
- // ----------------------------------
-
- /**
- * Returns the current collection of property descriptors for connection objects.
- * @return an array containing all descriptors.
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- PropertyDescriptor[] defaultProperties = (PropertyDescriptor[])getDefaultDescriptors();
- propertyDescriptorArray = new PropertyDescriptor[defaultProperties.length + 4];
- int idx = 0;
- for (idx = 0; idx < defaultProperties.length; idx++)
- propertyDescriptorArray[idx] = defaultProperties[idx];
-
- // add our unique property descriptors...
- //idx = defaultProperties.length; assertion
-
- // user id
- //propertyDescriptorArray[idx] = new TextPropertyDescriptor(ISystemPropertyConstants.P_USERID,
- // SystemViewResources.RESID_PROPERTY_USERID_LABEL));
- userIdDescriptor =
- new SystemInheritableTextPropertyDescriptor(ISystemPropertyConstants.P_USERID,
- SystemViewResources.RESID_PROPERTY_USERID_LABEL);
-
- userIdDescriptor.setToggleButtonToolTipText(SystemResources.RESID_SUBSYSTEM_USERID_INHERITBUTTON_TIP);
- userIdDescriptor.setEntryFieldToolTipText(SystemResources.RESID_SUBSYSTEM_USERID_TIP);
- propertyDescriptorArray[idx] = userIdDescriptor;
- propertyDescriptorArray[idx].setDescription(SystemViewResources.RESID_PROPERTY_USERID_TOOLTIP);
-
- // port
- propertyPortDescriptor = new TextPropertyDescriptor(ISystemPropertyConstants.P_PORT,
- SystemViewResources.RESID_PROPERTY_PORT_LABEL);
- propertyPortDescriptor.setDescription(SystemViewResources.RESID_PROPERTY_PORT_TOOLTIP);
- propertyPortDescriptor.setValidator(new ValidatorPortInput());
- propertyDescriptorArray[++idx] = propertyPortDescriptor;
- //propertyDescriptorArray[++idx] = getPortDescriptor();
-
- // connected
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_CONNECTED, SystemViewResources.RESID_PROPERTY_CONNECTED_LABEL, SystemViewResources.RESID_PROPERTY_CONNECTED_TOOLTIP);
-
- // vrm
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_VRM, SystemViewResources.RESID_PROPERTY_VRM_LABEL, SystemViewResources.RESID_PROPERTY_VRM_TOOLTIP);
- }
- return propertyDescriptorArray;
- }
- /**
- * Return our unique property descriptors
- */
- protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- return null;
- }
-
- /**
- * Create (first time), configure and return the property descriptor for the port number
- *
- private SystemInheritableTextPropertyDescriptor getPortDescriptor()
- {
- if (portDescriptor == null)
- {
- SystemViewPlugin plugin = SystemViewPlugin.getDefault();
- RSEUIPlugin sp = RSEUIPlugin.getDefault();
- portDescriptor =
- new SystemInheritableTextPropertyDescriptor(ISystemPropertyConstants.P_PORT,
- SystemViewResources.RESID_PROPERTY_PORT_LABEL));
- portDescriptor.setToggleButtonToolTipText(SystemResources.RESID_SUBSYSTEM_PORT_INHERITBUTTON_TIP));
- portDescriptor.setEntryFieldToolTipText(SystemResources.RESID_SUBSYSTEM_PORT_TIP));
- portDescriptor.setDescription(SystemViewResources.RESID_PROPERTY_PORT_DESCRIPTION));
- }
- return portDescriptor;
- }*/
-
- /**
- * Set the values in the userIdPropertyData object that drives the userId property sheet widget
- */
- private SystemInheritablePropertyData setUserIdPropertyData(SystemInheritablePropertyData data, ISubSystem subsys)
- {
- String localUserId = subsys.getLocalUserId();
- data.setLocalValue(localUserId);
- String parentUserId = subsys.getHost().getDefaultUserId();
- data.setInheritedValue(parentUserId);
- data.setIsLocal((localUserId!=null)&&(localUserId.length()>0));
-
- // DY: Defect 42735, check if user has temporarilly overrode the userid
- // for this connection via the signon dialog
- if (subsys.isConnected())
- {
- String connectedId = subsys.getConnectorService().getUserId();
- //On Local subsystems, connectedId==null. Phil.
- if (data.getIsLocal() && connectedId!=null && !connectedId.equals(localUserId))
- {
- data.setLocalValue(connectedId);
- data.setIsLocal(true);
- }
- else if (connectedId!=null && !connectedId.equals(parentUserId))
- {
- data.setLocalValue(connectedId);
- data.setIsLocal(true);
- }
- }
-
- return data;
- }
-
- /**
- * Set the values in the portPropertyData object that drives the port property sheet widget
- *
- private SystemInheritablePropertyData setPortPropertyData(SystemInheritablePropertyData data, SubSystem subsys)
- {
- Integer localPort = subsys.getPort();
- int iPort = 0;
- if (localPort != null)
- iPort = localPort.intValue();
- if (iPort > 0)
- data.setLocalValue(localPort.toString());
- else
- data.setLocalValue(null); // clear history
- SubSystemConfiguration ssFactory = subsys.getParentSubSystemConfiguration();
- boolean notApplicable = (!ssFactory.isPortEditable() && (iPort <= 0));
- if (!notApplicable)
- {
- data.setInheritedValue("0");
- data.setInheritedDisplayString(NLS.bind(SystemPropertyResources.RESID_PORT_DYNAMICSELECT, "0")); //$NON-NLS-1$
- data.setIsLocal(iPort != 0);
- }
- data.setNotApplicable(notApplicable);
- getPortDescriptor().setEditable(!notApplicable);
- //data.printDetails();
- return data;
- }
- */
-
- private String getPortString(ISubSystem ss)
- {
- //return getPortPropertyData(portData, ss);
- int iPort = ss.getConnectorService().getPort();
- ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration();
- boolean notApplicable = (!ssFactory.isPortEditable() && (iPort <= 0));
- if (notApplicable)
- return getTranslatedNotApplicable();
- else
- {
- return Integer.toString(iPort);
- }
- }
-
- /**
- * Returns the current value for the named property.
- * The parent handles P_TEXT and P_TYPE only, and we augment that here.
- * @param property the name of the property as named by its property descriptor
- * @return the current value of the property
- */
- public Object getPropertyValue(Object property)
- {
- String name = (String)property;
- ISubSystem ss = (ISubSystem)propertySourceInput;
- if (name.equals(ISystemPropertyConstants.P_USERID))
- return setUserIdPropertyData(userIdData, ss);
- else if (name.equals(ISystemPropertyConstants.P_PORT))
- return getPortString(ss);
- else if (name.equals(ISystemPropertyConstants.P_VRM))
- {
- IConnectorService system = ss.getConnectorService();
- if (system != null)
- {
- String vrm = system.getVersionReleaseModification();
- if (vrm != null)
- return vrm;
- else
- return getTranslatedNotAvailable();
- }
- else
- return getTranslatedNotAvailable();
- }
- else if (name.equals(ISystemPropertyConstants.P_IS_CONNECTED))
- {
- // yantzi: artemis 6.0, offline support
- if (ss.getHost().isOffline())
- {
- // connection is offline
- return SystemResources.RESID_OFFLINE_LABEL;
- }
-
- IConnectorService system = ss.getConnectorService();
- boolean connected = false;
- if (system == null)
- {
- System.out.println("SystemViewSubSystemAdapter: Error! system is null for subsystem "+ss.getClass().getName()); //$NON-NLS-1$
- SystemBasePlugin.logError("SystemViewSubSystemAdapter: Error! system is null for subsystem "+ss.getClass().getName(), null); //$NON-NLS-1$
- }
- else
- connected = system.isConnected();
- return connected ? getTranslatedYes() : getTranslatedNo();
- }
- else
- return super.getPropertyValue(name);
- }
-
- /**
- * Returns itself
- */
- public ISubSystem getSubSystem(Object element)
- {
- if (element instanceof ISubSystem)
- return (ISubSystem)element;
- else
- return null;
- }
-
- /**
- * Return our unique property values
- */
- public Object internalGetPropertyValue(Object key)
- {
- return null;
- }
-
- // because this node has some editable properties, these overrides of our
- // parent class are needed as callbacks from the PropertySheet window.
- /**
- * Set input object for property source queries. This is called by the
- * SystemViewAdaptorFactory before returning this adapter object.
- */
- public void setPropertySourceInput(Object propertySourceInput)
- {
- if (this.propertySourceInput == propertySourceInput)
- return;
- super.setPropertySourceInput(propertySourceInput);
- ISubSystem ss = (ISubSystem)propertySourceInput;
- ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration();
- original_userIdData = setUserIdPropertyData(original_userIdData,ss);
- //original_portData = setPortPropertyData(original_portData,ss);
- original_portData = getPortString(ss);
- changed_userId = changed_port = false;
-
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- // Lazy Loading: Since this is called from opening a context
- // menu, Dynamic Validator will only be available once the
- // ISubSystemConfigurationAdapter is loaded, i.e. after
- // connecting.
- // If a subsystem wants to provision for having the validator
- // available earlier, it needs to eagerly load the bundle that
- // declares its ISubSystemConfigurationAdapter.
- if (userIdDescriptor != null) {
- userIdDescriptor.setValidator(adapter.getUserIdValidator(ssFactory));
- }
- // getPortDescriptor().setValidator((ICellEditorValidator)ssFactory.getPortValidator());
- if (propertyPortDescriptor != null) {
- propertyPortDescriptor.setValidator(adapter.getPortValidator(ssFactory));
- }
- }
-
- ss.getConnectorService().getPort();
- port_editable = ssFactory.isPortEditable();
- }
-
- /**
- * Returns whether the property value has changed from the default.
- * Only applicable for editable properties.
- * Called by PropertySheet viewer when user presses reset.
- * @return <code>true</code> if the value of the specified property has changed
- * from its original default value; <code>false</code> otherwise.
- */
- public boolean isPropertySet(Object propertyObject)
- {
- String property = (String)propertyObject;
- boolean changed = false;
- if (property.equals(ISystemPropertyConstants.P_USERID))
- changed = changed_userId;
- else if (property.equals(ISystemPropertyConstants.P_PORT))
- changed = changed_port && port_editable;
- return changed;
- }
-
- /**
- * Change the subsystem user Id value
- */
- private void updateUserId(ISubSystem subsys, SystemInheritablePropertyData data)
- {
- //int whereToUpdate = USERID_LOCATION_SUBSYSTEM;
- String userId = data.getLocalValue(); // will be "" if !data.getIsLocal(), which results in wiping out local override
- ISubSystemConfiguration ssFactory = subsys.getSubSystemConfiguration();
- // unlike with connection objects, we don't ever allow the user to change the parent's
- // userId value, even if it is empty, when working with subsystems. There is too much
- // ambiquity as the parent could be the connnection or the user preferences setting for this
- // system type. Because of this decision, we don't need to tell updateSubSystem(...) where
- // to update, as it always the local subsystem.
- ssFactory.updateSubSystem(subsys, true, userId, false, subsys.getConnectorService().getPort());
- }
- /**
- * Change the subsystem port value
- *
- private void updatePort(SubSystem subsys, SystemInheritablePropertyData data)
- {
- String port = data.getLocalValue(); // will be "" if !data.getIsLocal(), which results in wiping out local override
- Integer portInteger = null;
- if (data.getIsLocal() && (port.length()>0))
- portInteger = new Integer(port);
- else
- portInteger = new Integer(0);
- SubSystemConfiguration ssFactory = subsys.getParentSubSystemConfiguration();
- ssFactory.updateSubSystem((Shell)null, subsys, false, subsys.getLocalUserId(), true, portInteger);
- }
- */
- /**
- * Change the subsystem port value
- */
- private void updatePort(ISubSystem subsys, String data)
- {
- if (!port_editable)
- return;
- String port = data;
- Integer portInteger = null;
- if (port.length()>0)
- {
- try
- {
- portInteger = new Integer(port);
- }
- catch (Exception exc)
- {
- return;
- }
- }
- else
- {
- portInteger = new Integer(0);
- }
- int portInt = portInteger.intValue();
- ISubSystemConfiguration ssFactory = subsys.getSubSystemConfiguration();
- ssFactory.updateSubSystem(subsys, false, subsys.getLocalUserId(), true, portInt);
- subsys.commit();
- }
-
-
- /**
- * Called when user selects the reset button in property sheet.
- */
- public void resetPropertyValue(Object propertyObject)
- {
- String property = (String)propertyObject;
- ISubSystem ss = (ISubSystem)propertySourceInput;
- ss.getSubSystemConfiguration();
- if (property.equals(ISystemPropertyConstants.P_USERID))
- {
- updateUserId(ss, original_userIdData);
- changed_userId = false;
- }
- else if (property.equals(ISystemPropertyConstants.P_PORT))
- {
- //updatePort(ss, original_portData);
- updatePort(ss, original_portData);
- changed_port = false;
- }
- }
- /**
- * Called when user changes property via property sheet.
- */
- public void setPropertyValue(Object property, Object value)
- {
- String name = (String)property;
- ISubSystem ss = (ISubSystem)propertySourceInput;
- ss.getSubSystemConfiguration();
- //System.out.println("inside setPropVal: " + property + ", value: " + value);
- if (name.equals(ISystemPropertyConstants.P_USERID))
- {
- updateUserId(ss, (SystemInheritablePropertyData)value);
- changed_userId = true;
- }
- else if (name.equals(ISystemPropertyConstants.P_PORT))
- {
- //System.out.println("inside setPropVal: " + property + ", value: " + value);
- //updatePort(ss, (SystemInheritablePropertyData)value);
- updatePort(ss, (String)value);
- changed_port = true;
- }
- }
-
- /**
- * Override of {@link AbstractSystemViewAdapter#testAttribute(Object, String, String)}. We add
- * one more attribute for subsystems:
- * <ol>
- * <li>name="serverLaunchPP". Returns "true" if the given subsystem supports the Server Launch Settings
- * property page, which is determined by calling it's factory's {@link ISubSystemConfiguration#supportsServerLaunchProperties(org.eclipse.rse.core.model.IHost)} method.
- * </ol>
- *
- * This property is used to filter the existence of the Server Launch Settings property page.
- *
- * @see org.eclipse.ui.IActionFilter#testAttribute(Object, String, String)
- */
- public boolean testAttribute(Object target, String name, String value)
- {
- if (target instanceof ISubSystem)
- {
- if (name.equalsIgnoreCase("serverLaunchPP")) //$NON-NLS-1$
- {
- ISubSystem ss = (ISubSystem)target;
- boolean supports = ss.getSubSystemConfiguration().supportsServerLaunchProperties(ss.getHost());
- return supports ? value.equals("true") : value.equals("false"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else if (name.equalsIgnoreCase("envVarPP")) //$NON-NLS-1$
- {
- /** FIXME can't access specific subsystems from core anymore
- boolean supports = false;
- if (ss instanceof IRemoteFileSubSystem)
- supports = ((IRemoteFileSubSystemConfiguration)ss.getParentSubSystemConfiguration()).supportsEnvironmentVariablesPropertyPage();
- else
- supports = ((IRemoteCmdSubSystemConfiguration)ss.getParentSubSystemConfiguration()).supportsEnvironmentVariablesPropertyPage();
- */
- boolean supports = false;
- return supports ? value.equals("true") : value.equals("false"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else if (name.equalsIgnoreCase("isConnectionError")) //$NON-NLS-1$
- {
- ISubSystem ss = (ISubSystem) target;
- boolean error = ss.isConnectionError();
- return error ? value.equals("true") : value.equals("false"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return super.testAttribute(target, name, value);
- }
-
- // FOR COMMON DELETE ACTIONS
- /**
- * Return true if we should show the delete action in the popup for the given element.
- * If true, then canDelete will be called to decide whether to enable delete or not.
- */
- public boolean showDelete(Object element)
- {
- return canDelete(element);
- }
-
- /**
- * Return true if this object is deletable by the user. If so, when selected,
- * the Edit->Delete menu item will be enabled.
- */
- public boolean canDelete(Object element)
- {
- //System.out.println("INSIDE ISDELETABLE FOR SUBSYSTEM VIEW ADAPTER: "+element);
- ISubSystem ss = (ISubSystem)element;
- ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration();
- return ssFactory.isSubSystemsDeletable();
- }
-
- /**
- * Perform the delete action.
- */
- public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor)
- {
- //System.out.println("INSIDE DODELETE FOR SUBSYSTEM VIEW ADAPTER: "+element);
- ISubSystem ss = (ISubSystem)element;
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.deleteSubSystem(ss);
- return true;
- }
-
- // FOR COMMON RENAME ACTIONS
- /**
- * Return true if we should show the rename action in the popup for the given element.
- * If true, then canRename will be called to decide whether to enable delete or not.
- */
- public boolean showRename(Object element)
- {
- return canRename(element);
- }
- /**
- * Return true if this object is renamable by the user. If so, when selected,
- * the Rename menu item will be enabled.
- */
- public boolean canRename(Object element)
- {
- return canDelete(element); // same rules for both delete and rename
- }
-
- /**
- * Perform the rename action. Assumes uniqueness checking was done already.
- */
- public boolean doRename(Shell shell, Object element, String name, IProgressMonitor monitor)
- {
- ISubSystem ss = (ISubSystem)element;
- ISubSystemConfiguration parentSSFactory = ss.getSubSystemConfiguration();
- parentSSFactory.renameSubSystem(ss,name); // renames, and saves to disk
- return true;
- }
-
- /**
- * Return a validator for verifying the new name is correct on a rename action.
- * The default implementation is not to support rename hence this method returns
- * null. Override if appropriate.
- */
- public ISystemValidator getNameValidator(Object element)
- {
- return null;
- }
-
- // FOR COMMON DRAG AND DROP ACTIONS
- /**
- * Indicates whether the subsystem can be dragged.
- * Can't be used for physical copies but rather
- * for views (like the Scratchpad)
- */
- public boolean canDrag(Object element)
- {
- return true;
- }
-
- /**
- * Returns the subsystem (no phyiscal operation required to drag and subsystem (because it's local)
- */
- public Object doDrag(Object element, boolean sameSystemType, IProgressMonitor monitor)
- {
- return element;
- }
-
-
-
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
-
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- * This just defaults to getName, but if that is not sufficient override it here.
- */
- public String getMementoHandle(Object element)
- {
- ISubSystem ss = (ISubSystem)element;
- ISubSystemConfiguration ssf = ss.getSubSystemConfiguration();
- return ssf.getId()+"="+ss.getName(); //$NON-NLS-1$
- }
- /**
- * Return what to save to disk to identify this element when it is the input object to a secondary
- * Remote System Explorer perspective.
- */
- public String getInputMementoHandle(Object element)
- {
- Object parent = getParent(element);
- return SystemAdapterHelpers.getViewAdapter(parent, getViewer()).getInputMementoHandle(parent) + MEMENTO_DELIM + getMementoHandle(element);
- }
- /**
- * Return a short string to uniquely identify the type of resource. Eg "conn" for connection.
- * This just defaults to getType, but if that is not sufficient override it here, since that is
- * a translated string.
- */
- public String getMementoHandleKey(Object element)
- {
- return ISystemMementoConstants.MEMENTO_KEY_SUBSYSTEM;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/BrowseAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/BrowseAction.java
deleted file mode 100644
index 250581ae1..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/BrowseAction.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.monitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-class BrowseAction extends Action
-{
- protected final SystemMonitorViewPart part;
-
- public BrowseAction(SystemMonitorViewPart part)
- {
- super();
- this.part = part;
- }
-
- public BrowseAction(SystemMonitorViewPart part, String label, ImageDescriptor des)
- {
- super(label, des);
- this.part = part;
-
- setToolTipText(label);
- }
-
- public void checkEnabledState()
- {
- if (this.part._folder != null && this.part._folder.getInput() != null)
- {
- setEnabled(true);
- }
- else
- {
- setEnabled(false);
- }
- }
-
- public void run()
- {
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/ClearAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/ClearAction.java
deleted file mode 100644
index 87b800b27..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/ClearAction.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.monitor;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-
-
-
-public class ClearAction extends BrowseAction
-{
-
- public ClearAction(SystemMonitorViewPart view)
- {
- super(view, SystemResources.ACTION_CLEAR_ALL_LABEL,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CLEAR_ALL_ID));
-
- setToolTipText(SystemResources.ACTION_CLEAR_ALL_TOOLTIP);
- // TODO DKM - get help for this!
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CLEAR_CONSOLE_ACTION);
- }
-
- public void checkEnabledState()
- {
- setEnabled(part.getViewer() != null);
- }
-
- public void run()
- {
- clear();
- }
-
- // clear contents of the current command viewer
- private void clear()
- {
- part.removeAllItemsToMonitor();
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/ClearSelectedAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/ClearSelectedAction.java
deleted file mode 100644
index a30f9f804..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/ClearSelectedAction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.monitor;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-
-
-
-
-
-public class ClearSelectedAction extends BrowseAction
-{
- public ClearSelectedAction(SystemMonitorViewPart view)
- {
- super(view, SystemResources.ACTION_CLEAR_SELECTED_LABEL,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CLEAR_SELECTED_ID));
-
- setToolTipText(SystemResources.ACTION_CLEAR_SELECTED_TOOLTIP);
- // TODO DKM - get help for this!
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CLEAR_CONSOLE_ACTION);
- }
-
- public void checkEnabledState()
- {
- if (part.getViewer() != null)
- {
- setEnabled(true);
- return;
- }
-
- setEnabled(false);
- }
-
- public void run()
- {
- clear();
- }
-
- private void clear()
- {
- part.removeItemToMonitor((IAdaptable)part.getViewer().getInput());
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/MonitorViewPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/MonitorViewPage.java
deleted file mode 100644
index 775c5e63d..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/MonitorViewPage.java
+++ /dev/null
@@ -1,587 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [180562] dont implement ISystemThemeConstants
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Kevin Doyle (IBM) - [177587] changed wrapped selection provider in setFocus()
- * Kevin Doyle (IBM) - [212940] Duplicate Help Context Identifiers
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.monitor;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.core.model.ISystemContainer;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction;
-import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemTableView;
-import org.eclipse.rse.ui.view.SystemTableViewProvider;
-import org.eclipse.rse.ui.widgets.ISystemCollapsableSectionListener;
-import org.eclipse.rse.ui.widgets.SystemCollapsableSection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Scale;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-
-
-
-/**
- * Class for a remote shell session on a connection
- */
-public class MonitorViewPage implements SelectionListener, IPropertyChangeListener, ISelectionChangedListener, Listener,
-FocusListener
-{
- private static SystemMessage _queryMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_QUERY_PROGRESS);
-
- class PollingThread extends Thread
- {
- private boolean _querying = false;
- private ISystemViewElementAdapter _adapter;
- private Object _inputObject;
-
-
- public PollingThread()
- {
- _inputObject = _viewer.getInput();
- _adapter = (ISystemViewElementAdapter)((IAdaptable)_inputObject).getAdapter(ISystemViewElementAdapter.class);
- }
-
- public void run()
- {
- while (isPollingEnabled())
- {
- int interval = getPollingInterval() * 1000;
- try
- {
- Thread.sleep(interval);
- doQuery();
- // while (_querying)
- // {
- // Thread.sleep(100);
- // }
- doRedraw();
- }
- catch (InterruptedException e)
- {
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
-
- protected void doQuery()
- {
-
- Display display = Display.getDefault();
- if (display != null && !_querying)
- {
- _querying= true;
- if (_inputObject instanceof ISystemContainer)
- {
- ((ISystemContainer)_inputObject).markStale(true);
- }
- ISubSystem ss = _adapter.getSubSystem(_inputObject);
- if (!ss.isConnected())
- return;
-
- String name = _adapter.getName(_inputObject);
- _queryMessage.makeSubstitution(name);
- String txt = _queryMessage.getLevelOneText();
- Job job = new Job(txt)
- {
- public IStatus run(IProgressMonitor monitor)
- {
- Object[] children = _adapter.getChildren((IAdaptable)_inputObject, monitor);
- if (children != null)
- {
- SystemTableViewProvider provider = (SystemTableViewProvider)_viewer.getContentProvider();
- if (provider!=null) {
- //bug 150924: provider can be lost when disconnecting while this job runs
- provider.setCache(children);
- }
-
- }
-
- _querying = false;
- return Status.OK_STATUS;
- }
- };
-
- job.schedule();
-
- try
- {
- job.wait();
- }
- catch (Exception e)
- {
-
- }
- }
-
- }
-
- protected void doRedraw()
- {
- Display display = Display.getDefault();
- if (display != null)
- {
- display.asyncExec(
- new Runnable()
- {
- public void run()
- {
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- registry.fireEvent(new SystemResourceChangeEvent(_inputObject, ISystemResourceChangeEvents.EVENT_CHANGE_CHILDREN, _inputObject));
- //getViewer().refresh();
- }
- });
- }
- }
- }
-
- class SelectAllAction extends Action
- {
- public SelectAllAction()
- {
- super(SystemResources.ACTION_SELECT_ALL_LABEL, null);
- setToolTipText(SystemResources.ACTION_SELECT_ALL_TOOLTIP);
- }
-
- public void checkEnabledState()
- {
- setEnabled(true);
- }
-
- public void run()
- {
- SystemTableView view = _viewer;
- view.getTable().selectAll();
- view.setSelection(view.getSelection());
- }
- }
-
-
- private SystemTableView _viewer;
-
- private boolean _isPolling = false;
- private int _pollingInterval;
-
- private Group _tabFolderPage;
- private Button _pollCheckbox;
- private Scale _scale;
- private Text _scaleValue;
-
- private PollingThread _pollingThread;
-
- private SystemMonitorViewPart _viewPart;
-
- private String _title;
-
- private SystemCopyToClipboardAction _copyAction;
- private SystemPasteFromClipboardAction _pasteAction;
- private SelectAllAction _selectAllAction;
- private IActionBars _actionBars;
-
- public MonitorViewPage(SystemMonitorViewPart viewPart)
- {
- _viewPart = viewPart;
- _actionBars = _viewPart.getViewSite().getActionBars();
- }
-
-
-
- public Composite createTabFolderPage(CTabFolder tabFolder, CellEditorActionHandler editorActionHandler)
- {
- _tabFolderPage = new Group(tabFolder, SWT.NULL);
- GridLayout gridLayout = new GridLayout();
- _tabFolderPage.setLayout(gridLayout);
-
- createControl(_tabFolderPage);
-
- // global actions
- Clipboard clipboard = RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard();
- _copyAction = new SystemCopyToClipboardAction(_viewer.getShell(), clipboard);
- _copyAction.setEnabled(false);
-
- _pasteAction = new SystemPasteFromClipboardAction(_viewer.getShell(), clipboard);
- _pasteAction.setEnabled(false);
-
- editorActionHandler.setCopyAction(_copyAction);
- editorActionHandler.setPasteAction(_pasteAction);
-
- _selectAllAction = new SelectAllAction();
- _selectAllAction.setEnabled(false);
- editorActionHandler.setSelectAllAction(_selectAllAction);
-
-
- _viewer.addSelectionChangedListener(this);
- _viewer.getControl().addFocusListener(this);
-
- return _tabFolderPage;
- }
-
- public void setFocus()
- {
- if (_viewPart != null)
- _viewPart.setActiveViewerSelectionProvider(_viewer);
- }
-
- public IActionBars getActionBars()
- {
- return _actionBars;
- }
-
- public void selectionChanged(SelectionChangedEvent e)
- {
- IStructuredSelection sel = (IStructuredSelection) e.getSelection();
- _copyAction.setEnabled(_copyAction.updateSelection(sel));
- _pasteAction.setEnabled(_pasteAction.updateSelection(sel));
- _selectAllAction.setEnabled(true);
-
- //setActionHandlers();
- }
-
- public int getPollingInterval()
- {
- return _pollingInterval;
- }
-
- public boolean isPollingEnabled()
- {
- if (_isPolling && !getViewer().getControl().isDisposed())
- {
- return true;
- }
- return false;
- }
-
- public void setPollingEnabled(boolean flag)
- {
- _isPolling = flag;
- }
-
- public void setEnabled(boolean flag)
- {
- if (!flag)
- {
- Table table = _viewer.getTable();
-
- Color bgcolour = _tabFolderPage.getBackground();
-
- table.setBackground(bgcolour);
- }
- }
-
- protected void createPollControls(Composite parent)
- {
-
- SystemCollapsableSection collapsable = new SystemCollapsableSection(parent);
- collapsable.setText(SystemResources.RESID_MONITOR_POLL_CONFIGURE_POLLING_LABEL);
- collapsable.setToolTips(SystemResources.RESID_MONITOR_POLL_CONFIGURE_POLLING_COLLAPSE_TOOLTIP,
- SystemResources.RESID_MONITOR_POLL_CONFIGURE_POLLING_EXPAND_TOOLTIP
- );
-
- Composite inputContainer = collapsable.getPageComposite();
-
-
- _pollCheckbox = SystemWidgetHelpers.createCheckBox(inputContainer, this, SystemResources.RESID_MONITOR_POLL_LABEL, SystemResources.RESID_MONITOR_POLL_TOOLTIP);
- GridData pg = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- _pollCheckbox.setLayoutData(pg);
-
- _pollingInterval = 100;
- SystemWidgetHelpers.createLabel(inputContainer, SystemResources.RESID_MONITOR_POLL_INTERVAL_LABEL);
-
- _scale = new Scale(inputContainer, SWT.NULL);
- _scale.setMaximum(200);
- _scale.setMinimum(5);
- _scale.setSelection(_pollingInterval);
-
- _scale.addSelectionListener(
- new SelectionListener()
- {
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- _pollingInterval = _scale.getSelection();
- _scaleValue.setText(_pollingInterval + "s"); //$NON-NLS-1$
-
- if (_pollingThread != null)
- _pollingThread.interrupt();
- }
-
- });
-
- _scale.setToolTipText(SystemResources.RESID_MONITOR_POLL_INTERVAL_TOOLTIP);
- GridData sd = new GridData(GridData.FILL_HORIZONTAL);
- _scale.setLayoutData(sd);
-
- _scaleValue = SystemWidgetHelpers.createReadonlyTextField(inputContainer);
- _scaleValue.setTextLimit(5);
- GridData scgd = new GridData(GridData.HORIZONTAL_ALIGN_END);
- _scaleValue.setLayoutData(scgd);
- _scaleValue.setText(_pollingInterval + "s"); //$NON-NLS-1$
-
-
-
- GridLayout ilayout = new GridLayout();
- ilayout.numColumns = 4;GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL);
- inputContainer.setLayout(ilayout);
- inputContainer.setLayoutData(gridData1);
-
-
- // defaults
- _scale.setEnabled(_isPolling);
- _scaleValue.setEnabled(_isPolling);
-
- collapsable.addCollapseListener(new CollapsableListener(inputContainer));
- collapsable.setCollapsed(true);
- }
-
- class CollapsableListener implements ISystemCollapsableSectionListener
- {
- Composite _child;
- public CollapsableListener(Composite child)
- {
- _child = child;
- }
-
- public void sectionCollapsed(boolean collapsed)
- {
- //System.out.println("collapsed");
- }
- }
-
- public void createControl(Composite parent)
- {
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 1;
- parent.setLayout(gridLayout);
-
- // create table portion
- Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
- _viewer = new SystemTableView(table, _viewPart);
-
- //Tree tree = new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
- //_viewer = new SystemTableTreeView(tree, _viewPart);
-
- _viewer.addDoubleClickListener(new IDoubleClickListener()
- {
- public void doubleClick(DoubleClickEvent event)
- {
- handleDoubleClick(event);
- }
- });
-
- //TableLayout layout = new TableLayout();
- //tree.setLayout(layout);
- //tree.setLayout(new GridLayout())
- table.setHeaderVisible(false);
- table.setLinesVisible(false);
-
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
- table.setLayoutData(gridData);
-
- createPollControls(_tabFolderPage);
- }
-
- public void propertyChange(PropertyChangeEvent e)
- {
- }
-
-
- private void handleDoubleClick(DoubleClickEvent event)
- {
- IStructuredSelection s = (IStructuredSelection) event.getSelection();
- Object element = s.getFirstElement();
- if (element == null)
- return;
-
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) element).getAdapter(ISystemViewElementAdapter.class);
-
- if (adapter != null)
- {
- adapter.handleDoubleClick(element);
- }
- }
-
- public void dispose()
- {
- _viewer.dispose();
- _tabFolderPage.dispose();
- _isPolling = false;
- }
-
-
-
-
- public Object getInput()
- {
- return _viewer.getInput();
- }
-
- public void setInput(IAdaptable object)
- {
- setInput(object, true);
- updateTitle(object);
- }
-
- public void updateTitle(IAdaptable object)
- {
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)object.getAdapter(ISystemViewElementAdapter.class);
-
- String title = adapter.getText(object);
- _tabFolderPage.setText(title);
- }
-
- public String getTitle()
- {
- return _title;
- }
-
- public void setInput(IAdaptable object, boolean updateHistory)
- {
- if (_viewer != null && object != null)
- {
- _viewer.setInput(object);
- }
- }
-
- public void clearInput()
- {
- if (_viewer != null)
- {
- _viewer.setInput(null);
- }
- }
-
- public SystemTableView getViewer()
- {
- return _viewer;
- }
-
-
-
- public void updateActionStates()
- {
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- }
-
-
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
- */
- public void focusGained(FocusEvent arg0)
- {
- IActionBars actionBars = getActionBars();
- if (actionBars != null)
- {
- if (arg0.widget == _viewer.getControl())
- {
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, _copyAction);
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.PASTE, _pasteAction);
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, _selectAllAction);
- actionBars.updateActionBars();
-
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(FocusEvent arg0)
- {
-
- }
-
- public void handleEvent(Event event)
- {
- Widget w = event.widget;
- if (w == _pollCheckbox)
- {
- boolean wasPolling = _isPolling;
- _isPolling = _pollCheckbox.getSelection();
- _scale.setEnabled(_isPolling);
- _scaleValue.setEnabled(_isPolling);
- if (wasPolling != _isPolling && _isPolling)
- {
- _pollingThread = new PollingThread();
- _pollingThread.start();
- }
- }
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/MonitorViewWorkbook.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/MonitorViewWorkbook.java
deleted file mode 100644
index 19b39969e..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/MonitorViewWorkbook.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- * Kevin Doyle (IBM) - [177587] createTabItem sets the wrapped selection provider
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.monitor;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemTableView;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-
-
-
-/**
- * This is the desktop view wrapper of the System View viewer.
- */
-public class MonitorViewWorkbook extends Composite
-{
-
-
- private CTabFolder _folder;
- private SystemMonitorViewPart _viewPart;
-
- public MonitorViewWorkbook(Composite parent, SystemMonitorViewPart viewPart)
- {
- super(parent, SWT.NONE);
-
- _folder = new CTabFolder(this, SWT.NONE);
- _folder.setLayout(new TabFolderLayout());
- _folder.setLayoutData(new GridData(GridData.FILL_BOTH));
- setLayout(new FillLayout());
- _viewPart = viewPart;
- }
-
- public void dispose()
- {
-
- //if (!_folder.isDisposed())
- {
- for (int i = 0; i < _folder.getItemCount(); i++)
- {
- CTabItem item = _folder.getItem(i);
- if (!item.isDisposed())
- {
- MonitorViewPage page = (MonitorViewPage) item.getData();
- page.dispose();
- }
- }
- _folder.dispose();
- }
- super.dispose();
- }
-
- public CTabFolder getFolder()
- {
- return _folder;
- }
-
- public void remove(Object root)
- {
- for (int i = 0; i < _folder.getItemCount(); i++)
- {
- CTabItem item = _folder.getItem(i);
- if (!item.isDisposed())
- {
- MonitorViewPage page = (MonitorViewPage) item.getData();
-
- if (page != null && root == page.getInput())
- {
- item.dispose();
- page.dispose();
-
- page = null;
- item = null;
-
- _folder.redraw();
-
- return;
- }
- }
- }
- }
-
- public void removeDisconnected()
- {
- for (int i = 0; i < _folder.getItemCount(); i++)
- {
- CTabItem item = _folder.getItem(i);
- if (!item.isDisposed())
- {
- MonitorViewPage page = (MonitorViewPage) item.getData();
- if (page != null)
- {
- IAdaptable input = (IAdaptable)page.getInput();
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)input.getAdapter(ISystemViewElementAdapter.class);
- if (adapter != null)
- {
- ISubSystem subSystem = adapter.getSubSystem(input);
- if (subSystem != null)
- {
- if (!subSystem.isConnected())
- {
- item.dispose();
- page.dispose();
-
- page = null;
- item = null;
-
- _folder.redraw();
- }
- }
- }
- }
- }
- }
- }
-
-
-
- public CTabItem getSelectedTab()
- {
- if (_folder.getItemCount() > 0)
- {
- int index = _folder.getSelectionIndex();
- CTabItem item = _folder.getItem(index);
- return item;
- }
-
- return null;
- }
-
- public MonitorViewPage getCurrentTabItem()
- {
- if (_folder.getItemCount() > 0)
- {
- int index = _folder.getSelectionIndex();
- CTabItem item = _folder.getItem(index);
- return (MonitorViewPage) item.getData();
- }
- return null;
- }
-
- public void showCurrentPage()
- {
- _folder.setFocus();
- }
-
- public Object getInput()
- {
- MonitorViewPage page = getCurrentTabItem();
- if (page != null)
- {
- page.setFocus();
- return page.getInput();
- }
-
- return null;
- }
-
- public SystemTableView getViewer()
- {
- if (getCurrentTabItem() != null)
- {
- return getCurrentTabItem().getViewer();
- }
- return null;
- }
-
- public void addItemToMonitor(IAdaptable root, boolean createTab)
- {
- if (!_folder.isDisposed())
- {
- for (int i = 0; i < _folder.getItemCount(); i++)
- {
- CTabItem item = _folder.getItem(i);
- MonitorViewPage page = (MonitorViewPage) item.getData();
- if (page != null && root == page.getInput())
- {
- page.getViewer().refresh();
-
- if (_folder.getSelectionIndex() != i)
- {
- _folder.setSelection(item);
- }
- updateActionStates();
- //page.setFocus();
- return;
- }
- }
-
- if (createTab)
- {
- // never shown this, so add it
- createTabItem(root);
- }
- }
- }
-
- private void createTabItem(IAdaptable root)
- {
- MonitorViewPage monitorViewPage = new MonitorViewPage(_viewPart);
-
- CTabItem titem = new CTabItem(_folder, SWT.NULL);
- setTabTitle(root, titem);
-
- titem.setData(monitorViewPage);
- titem.setControl(monitorViewPage.createTabFolderPage(_folder, _viewPart.getEditorActionHandler()));
- _folder.setSelection(titem );
-
- monitorViewPage.setInput(root);
-
- SystemTableView viewer = monitorViewPage.getViewer();
- if (_viewPart != null)
- {
- _viewPart.setActiveViewerSelectionProvider(viewer);
- _viewPart.getSite().registerContextMenu(viewer.getContextMenuManager(), viewer);
- }
- monitorViewPage.setFocus();
- }
-
- private void setTabTitle(IAdaptable root, CTabItem titem)
- {
- ISystemViewElementAdapter va = (ISystemViewElementAdapter) root.getAdapter(ISystemViewElementAdapter.class);
- if (va != null)
- {
- titem.setText(va.getName(root));
- titem.setImage(va.getImageDescriptor(root).createImage());
- }
- }
-
- public void setInput(IAdaptable root)
- {
- for (int i = 0; i < _folder.getItemCount(); i++)
- {
- CTabItem item = _folder.getItem(i);
- MonitorViewPage page = (MonitorViewPage) item.getData();
- if (root == page.getInput())
- {
- _folder.setSelection(i);
- page.getViewer().refresh();
- return;
- }
- }
- }
-
- public void updateActionStates()
- {
- for (int i = 0; i < _folder.getItemCount(); i++)
- {
- CTabItem item = _folder.getItem(i);
- if (!item.isDisposed())
- {
- MonitorViewPage page = (MonitorViewPage) item.getData();
- if (page != null)
- {
- page.updateActionStates();
- }
- }
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/SystemMonitorUI.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/SystemMonitorUI.java
deleted file mode 100644
index 1c349f000..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/SystemMonitorUI.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.monitor;
-
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-
-
-/**
- * A singleton class for dealing with remote commands
- */
-public class SystemMonitorUI
-{
-
-
- // singleton instance
- private static SystemMonitorUI instance;
- private static SystemMonitorViewPart _viewPart;
-
- public static final String MONITOR_VIEW_ID = "org.eclipse.rse.ui.view.monitorView"; //$NON-NLS-1$
-
- private SystemMonitorUI()
- {
- super();
- }
-
- /**
- * Get the singleton instance.
- * @return the singleton object of this type
- */
- public static SystemMonitorUI getInstance()
- {
- if (instance == null)
- {
- instance = new SystemMonitorUI();
- }
-
- return instance;
- }
-
-
- public SystemMonitorViewPart activateCommandsView()
- {
- try
- {
- IWorkbenchPage page = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage();
- _viewPart = (SystemMonitorViewPart) page.showView(SystemMonitorUI.MONITOR_VIEW_ID);
- page.bringToTop(_viewPart);
- }
- catch (PartInitException e)
- {
- SystemBasePlugin.logError("Can not open remote shell view", e); //$NON-NLS-1$
- }
-
- return _viewPart;
- }
-
-
- public static SystemMonitorViewPart getMonitorView()
- {
- return _viewPart;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/SystemMonitorViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/SystemMonitorViewPart.java
deleted file mode 100644
index ff70aa090..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/SystemMonitorViewPart.java
+++ /dev/null
@@ -1,1133 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Michael Berger (IBM) - 146339 Added refresh action graphic.
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Kevin Doyle (IBM) - [177587] Made MonitorViewPart a SelectionProvider
- * Kevin Doyle (IBM) - [160378] Subset action should be disabled when there are no tabs in Monitor
- * Kevin Doyle (IBM) - [196582] ClassCastException when doing copy/paste
- * Kevin Doyle (IBM) - [212940] Duplicate Help Context Identifiers
- * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.monitor;
-
-import java.util.ArrayList;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvent;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
-import org.eclipse.rse.core.events.ISystemRemoteChangeListener;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.model.ISystemContainer;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.internal.ui.SystemPropertyResources;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.view.SystemTableTreeViewProvider;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.IRSEViewPart;
-import org.eclipse.rse.ui.view.ISystemTableViewColumnManager;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemTableView;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-
-/**
- * This is the desktop view wrapper of the System View viewer.
- */
-public class SystemMonitorViewPart
- extends ViewPart
- implements
- ISelectionListener,
- SelectionListener,
- ISelectionChangedListener,
- ISystemResourceChangeListener,
- ISystemShellProvider,
- ISystemRemoteChangeListener,
- ISystemMessageLine,
- IRSEViewPart,
- ISelectionProvider
-{
-
-
- class RestoreStateRunnable implements Runnable
- {
- public void run()
- {
- }
- }
- class PositionToAction extends BrowseAction
- {
- class PositionToDialog extends SystemPromptDialog
- {
- private String _name;
- private Combo _cbName;
-
-
- public PositionToDialog(Shell shell, String title)
- {
- super(shell, title);
- }
-
- public String getPositionName()
- {
- return _name;
- }
-
- protected void buttonPressed(int buttonId)
- {
- setReturnCode(buttonId);
- _name = _cbName.getText();
- close();
- }
-
- protected Control getInitialFocusControl()
- {
- return _cbName;
- }
-
- public Control createInner(Composite parent)
- {
- Composite c = SystemWidgetHelpers.createComposite(parent, 2);
-
- Label aLabel = new Label(c, SWT.NONE);
- aLabel.setText(SystemPropertyResources.RESID_PROPERTY_NAME_LABEL);
-
- _cbName = SystemWidgetHelpers.createCombo(c, null);
- GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- _cbName.setLayoutData(textData);
- _cbName.setText("*"); //$NON-NLS-1$
- _cbName.setToolTipText(SystemResources.RESID_TABLE_POSITIONTO_ENTRY_TOOLTIP);
-
- this.getShell().setText(SystemResources.RESID_TABLE_POSITIONTO_LABEL);
- setHelp();
- return c;
- }
-
- private void setHelp()
- {
- setHelp(RSEUIPlugin.HELPPREFIX + "gnpt0000"); //$NON-NLS-1$
- }
- }
-
- public PositionToAction()
- {
- super(SystemMonitorViewPart.this, SystemResources.ACTION_POSITIONTO_LABEL, null);
- setToolTipText(SystemResources.ACTION_POSITIONTO_TOOLTIP);
- }
-
- public void run()
- {
-
- PositionToDialog posDialog = new PositionToDialog(getViewer().getShell(), getTitle());
- if (posDialog.open() == Window.OK)
- {
- String name = posDialog.getPositionName();
-
- getViewer().positionTo(name);
- }
- }
- }
-
-class SubSetAction extends BrowseAction
- {
- class SubSetDialog extends SystemPromptDialog
- {
- private String[] _filters;
- private Text[] _controls;
- private IPropertyDescriptor[] _uniqueDescriptors;
-
-
- public SubSetDialog(Shell shell, IPropertyDescriptor[] uniqueDescriptors)
- {
- super(shell, SystemResources.RESID_TABLE_SUBSET_LABEL);
- _uniqueDescriptors = uniqueDescriptors;
- }
-
- public String[] getFilters()
- {
- return _filters;
- }
-
- protected void buttonPressed(int buttonId)
- {
- setReturnCode(buttonId);
-
- for (int i = 0; i < _controls.length; i++)
- {
- _filters[i] = _controls[i].getText();
- }
-
- close();
- }
-
- protected Control getInitialFocusControl()
- {
- return _controls[0];
- }
-
- public Control createInner(Composite parent)
- {
- Composite c = SystemWidgetHelpers.createComposite(parent, 2);
-
- int numberOfFields = _uniqueDescriptors.length;
- _controls = new Text[numberOfFields + 1];
- _filters = new String[numberOfFields + 1];
-
- Label nLabel = new Label(c, SWT.NONE);
- nLabel.setText(SystemPropertyResources.RESID_PROPERTY_NAME_LABEL);
-
-
- _controls[0] = SystemWidgetHelpers.createTextField(c, null);
- GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- _controls[0].setLayoutData(textData);
- _controls[0].setText("*"); //$NON-NLS-1$
- _controls[0].setToolTipText(SystemResources.RESID_TABLE_SUBSET_ENTRY_TOOLTIP);
-
-
-
- for (int i = 0; i < numberOfFields; i++)
- {
- IPropertyDescriptor des = _uniqueDescriptors[i];
-
- Label aLabel = new Label(c, SWT.NONE);
- aLabel.setText(des.getDisplayName());
-
- _controls[i + 1] = SystemWidgetHelpers.createTextField(c, null);
- GridData textData3 = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
- _controls[i + 1].setLayoutData(textData3);
- _controls[i + 1].setText("*"); //$NON-NLS-1$
- }
-
- setHelp();
- return c;
- }
-
- private void setHelp()
- {
- setHelp(RSEUIPlugin.HELPPREFIX + "gnss0000"); //$NON-NLS-1$
- }
- }
-
- public SubSetAction()
- {
- super(SystemMonitorViewPart.this, SystemResources.ACTION_SUBSET_LABEL, null);
- setToolTipText(SystemResources.ACTION_SUBSET_TOOLTIP);
- }
-
- public void run()
- {
- SubSetDialog subsetDialog = new SubSetDialog(getViewer().getShell(), getViewer().getVisibleDescriptors(getViewer().getInput()));
- if (subsetDialog.open() == Window.OK)
- {
- String[] filters = subsetDialog.getFilters();
- getViewer().setViewFilters(filters);
-
- }
- }
- }
-
-
-
- class RefreshAction extends BrowseAction
- {
- public RefreshAction()
- {
- super(SystemMonitorViewPart.this, SystemResources.ACTION_REFRESH_LABEL,
- //RSEUIPlugin.getDefault().getImageDescriptor(ICON_SYSTEM_REFRESH_ID));
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_REFRESH_ID));
- setTitleToolTip(SystemResources.ACTION_REFRESH_TOOLTIP);
- }
-
- public void run()
- {
- Object inputObject = getViewer().getInput();
- if (inputObject instanceof ISystemContainer)
- {
- ((ISystemContainer)inputObject).markStale(true);
- }
- ((SystemTableTreeViewProvider) getViewer().getContentProvider()).flushCache();
- getViewer().refresh();
-
- // refresh layout too
- //_viewer.computeLayout(true);
-
- }
- }
- private class SelectColumnsAction extends BrowseAction
- {
-
- class SelectColumnsDialog extends SystemPromptDialog
- {
- private ISystemViewElementAdapter _adapter;
- private ISystemTableViewColumnManager _columnManager;
- private IPropertyDescriptor[] _uniqueDescriptors;
- private ArrayList _currentDisplayedDescriptors;
- private ArrayList _availableDescriptors;
-
- private List _availableList;
- private List _displayedList;
-
- private Button _addButton;
- private Button _removeButton;
- private Button _upButton;
- private Button _downButton;
-
-
- public SelectColumnsDialog(Shell shell, ISystemViewElementAdapter viewAdapter, ISystemTableViewColumnManager columnManager)
- {
- super(shell, SystemResources.RESID_TABLE_SELECT_COLUMNS_LABEL);
- setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_TOOLTIP);
- _adapter = viewAdapter;
- _columnManager = columnManager;
- _uniqueDescriptors = viewAdapter.getUniquePropertyDescriptors();
- IPropertyDescriptor[] initialDisplayedDescriptors = _columnManager.getVisibleDescriptors(_adapter);
- _currentDisplayedDescriptors = new ArrayList(initialDisplayedDescriptors.length);
- for (int i = 0; i < initialDisplayedDescriptors.length;i++)
- {
- if (!_currentDisplayedDescriptors.contains(initialDisplayedDescriptors[i]))
- _currentDisplayedDescriptors.add(initialDisplayedDescriptors[i]);
- }
- _availableDescriptors = new ArrayList(_uniqueDescriptors.length);
- for (int i = 0; i < _uniqueDescriptors.length;i++)
- {
- if (!_currentDisplayedDescriptors.contains(_uniqueDescriptors[i]))
- {
- _availableDescriptors.add(_uniqueDescriptors[i]);
- }
- }
- }
-
-
- public void handleEvent(Event e)
- {
- Widget source = e.widget;
- if (source == _addButton)
- {
- int[] toAdd = _availableList.getSelectionIndices();
- addToDisplay(toAdd);
- }
- else if (source == _removeButton)
- {
- int[] toAdd = _displayedList.getSelectionIndices();
- removeFromDisplay(toAdd);
- }
- else if (source == _upButton)
- {
- int index = _displayedList.getSelectionIndex();
- moveUp(index);
- _displayedList.select(index - 1);
- }
- else if (source == _downButton)
- {
- int index = _displayedList.getSelectionIndex();
- moveDown(index);
- _displayedList.select(index + 1);
- }
-
- // update button enable states
- updateEnableStates();
- }
-
- public IPropertyDescriptor[] getDisplayedColumns()
- {
- IPropertyDescriptor[] displayedColumns = new IPropertyDescriptor[_currentDisplayedDescriptors.size()];
- for (int i = 0; i< _currentDisplayedDescriptors.size();i++)
- {
- displayedColumns[i]= (IPropertyDescriptor)_currentDisplayedDescriptors.get(i);
- }
- return displayedColumns;
- }
-
- private void updateEnableStates()
- {
- boolean enableAdd = false;
- boolean enableRemove = false;
- boolean enableUp = false;
- boolean enableDown = false;
-
- int[] availableSelected = _availableList.getSelectionIndices();
- for (int i = 0; i < availableSelected.length; i++)
- {
- int index = availableSelected[i];
- IPropertyDescriptor descriptor = (IPropertyDescriptor)_availableDescriptors.get(index);
- if (!_currentDisplayedDescriptors.contains(descriptor))
- {
- enableAdd = true;
- }
- }
-
- if (_displayedList.getSelectionCount()>0)
- {
- enableRemove = true;
-
- int index = _displayedList.getSelectionIndex();
- if (index > 0)
- {
- enableUp = true;
- }
- if (index < _displayedList.getItemCount()-1)
- {
- enableDown = true;
- }
- }
-
- _addButton.setEnabled(enableAdd);
- _removeButton.setEnabled(enableRemove);
- _upButton.setEnabled(enableUp);
- _downButton.setEnabled(enableDown);
-
- }
-
- private void moveUp(int index)
- {
- Object obj = _currentDisplayedDescriptors.remove(index);
- _currentDisplayedDescriptors.add(index - 1, obj);
- refreshDisplayedList();
- }
-
- private void moveDown(int index)
- {
- Object obj = _currentDisplayedDescriptors.remove(index);
- _currentDisplayedDescriptors.add(index + 1, obj);
-
- refreshDisplayedList();
- }
-
- private void addToDisplay(int[] toAdd)
- {
- ArrayList added = new ArrayList();
- for (int i = 0; i < toAdd.length; i++)
- {
- int index = toAdd[i];
-
- IPropertyDescriptor descriptor = (IPropertyDescriptor)_availableDescriptors.get(index);
-
- if (!_currentDisplayedDescriptors.contains(descriptor))
- {
- _currentDisplayedDescriptors.add(descriptor);
- added.add(descriptor);
- }
- }
-
- for (int i = 0; i < added.size(); i++)
- {
- _availableDescriptors.remove(added.get(i));
- }
-
-
- refreshAvailableList();
- refreshDisplayedList();
-
- }
-
- private void removeFromDisplay(int[] toRemove)
- {
- for (int i = 0; i < toRemove.length; i++)
- {
- int index = toRemove[i];
- IPropertyDescriptor descriptor = (IPropertyDescriptor)_currentDisplayedDescriptors.get(index);
- _currentDisplayedDescriptors.remove(index);
- _availableDescriptors.add(descriptor);
- }
- refreshDisplayedList();
- refreshAvailableList();
- }
-
- protected void buttonPressed(int buttonId)
- {
- setReturnCode(buttonId);
-
- close();
- }
-
- protected Control getInitialFocusControl()
- {
- return _availableList;
- }
-
- public Control createInner(Composite parent)
- {
- Composite main = SystemWidgetHelpers.createComposite(parent, 1);
-
- SystemWidgetHelpers.createLabel(main, SystemResources.RESID_TABLE_SELECT_COLUMNS_DESCRIPTION_LABEL);
-
- Composite c = SystemWidgetHelpers.createComposite(main, 4);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
- _availableList = SystemWidgetHelpers.createListBox(c, SystemResources.RESID_TABLE_SELECT_COLUMNS_AVAILABLE_LABEL, this, true);
-
- Composite addRemoveComposite = SystemWidgetHelpers.createComposite(c, 1);
- addRemoveComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
- _addButton = SystemWidgetHelpers.createPushButton(addRemoveComposite,
- SystemResources.RESID_TABLE_SELECT_COLUMNS_ADD_LABEL,
- this);
- _addButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_ADD_TOOLTIP);
-
- _removeButton = SystemWidgetHelpers.createPushButton(addRemoveComposite,
- SystemResources.RESID_TABLE_SELECT_COLUMNS_REMOVE_LABEL,
- this);
- _removeButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_REMOVE_TOOLTIP);
-
- _displayedList = SystemWidgetHelpers.createListBox(c, SystemResources.RESID_TABLE_SELECT_COLUMNS_DISPLAYED_LABEL, this, false);
-
- Composite upDownComposite = SystemWidgetHelpers.createComposite(c, 1);
- upDownComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
- _upButton = SystemWidgetHelpers.createPushButton(upDownComposite,
- SystemResources.RESID_TABLE_SELECT_COLUMNS_UP_LABEL,
- this);
- _upButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_UP_TOOLTIP);
-
- _downButton = SystemWidgetHelpers.createPushButton(upDownComposite,
- SystemResources.RESID_TABLE_SELECT_COLUMNS_DOWN_LABEL,
- this);
- _downButton.setToolTipText(SystemResources.RESID_TABLE_SELECT_COLUMNS_DOWN_TOOLTIP);
-
- initLists();
-
- setHelp();
- return c;
- }
-
- private void initLists()
- {
- refreshAvailableList();
- refreshDisplayedList();
- updateEnableStates();
- }
-
- private void refreshAvailableList()
- {
- _availableList.removeAll();
- // initialize available list
- for (int i = 0; i < _availableDescriptors.size(); i++)
- {
- IPropertyDescriptor descriptor = (IPropertyDescriptor)_availableDescriptors.get(i);
- _availableList.add(descriptor.getDisplayName());
- }
- }
-
- private void refreshDisplayedList()
- {
- _displayedList.removeAll();
- // initialize display list
- for (int i = 0; i < _currentDisplayedDescriptors.size(); i++)
- {
-
- Object obj = _currentDisplayedDescriptors.get(i);
- if (obj != null && obj instanceof IPropertyDescriptor)
- {
- _displayedList.add(((IPropertyDescriptor)obj).getDisplayName());
- }
- }
- }
-
- private void setHelp()
- {
- setHelp(RSEUIPlugin.HELPPREFIX + "gntc0000"); //$NON-NLS-1$
- }
- }
-
- public SelectColumnsAction()
- {
- super(SystemMonitorViewPart.this, SystemResources.ACTION_SELECTCOLUMNS_LABEL, null);
- setToolTipText(SystemResources.ACTION_SELECTCOLUMNS_TOOLTIP);
- setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTER_ID));
- }
-
- public void checkEnabledState()
- {
-
- if (getViewer() != null && getViewer().getInput() != null)
- {
- setEnabled(true);
- }
- else
- {
- setEnabled(false);
- }
- }
- public void run()
- {
- SystemTableView viewer = getViewer();
- ISystemTableViewColumnManager mgr = viewer.getColumnManager();
- ISystemViewElementAdapter adapter = viewer.getAdapterForContents();
- SelectColumnsDialog dlg = new SelectColumnsDialog(getShell(), adapter, mgr);
- if (dlg.open() == Window.OK)
- {
- mgr.setCustomDescriptors(adapter, dlg.getDisplayedColumns());
- viewer.computeLayout(true);
- viewer.refresh();
- }
- }
- }
-
- MonitorViewWorkbook _folder = null;
- private CellEditorActionHandler _editorActionHandler = null;
-
- // for ISystemMessageLine
- private String _message, _errorMessage;
- private SystemMessage sysErrorMessage;
- private IStatusLineManager _statusLine = null;
-
- private SelectColumnsAction _selectColumnsAction = null;
- private RefreshAction _refreshAction = null;
-
- private ClearAction _clearAllAction = null;
- private ClearSelectedAction _clearSelectedAction = null;
-
- private SubSetAction _subsetAction = null;
- private PositionToAction _positionToAction = null;
-
- private ISelectionProvider viewerProvider = null;
- private ArrayList selectionListeners = new ArrayList();
-
- private ISelectionChangedListener selectionListener = null;
-
- // constants
- public static final String ID = "org.eclipse.rse.ui.view.monitorView"; //$NON-NLS-1$
- // matches id in plugin.xml, view tag
-
- public void setFocus()
- {
- _folder.showCurrentPage();
- }
-
- public Shell getShell()
- {
- return _folder.getShell();
- }
-
- public SystemTableView getViewer()
- {
- return _folder.getViewer();
- }
-
- public Viewer getRSEViewer()
- {
- return _folder.getViewer();
- }
-
- public CellEditorActionHandler getEditorActionHandler()
- {
- if (_editorActionHandler == null)
- {
- _editorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
- }
- return _editorActionHandler;
- }
-
- public void createPartControl(Composite parent)
- {
- _folder = new MonitorViewWorkbook(parent, this);
- _folder.getFolder().addSelectionListener(this);
-
- ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService();
- selectionService.addSelectionListener(this);
-
-
- SystemWidgetHelpers.setHelp(_folder, RSEUIPlugin.HELPPREFIX + "mntr0000"); //$NON-NLS-1$
-
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- registry.addSystemResourceChangeListener(this);
- registry.addSystemRemoteChangeListener(this);
-
-
- RestoreStateRunnable restore = new RestoreStateRunnable();
- Display.getCurrent().asyncExec(restore);
-
- getSite().setSelectionProvider(this);
- selectionListener = new ISelectionChangedListener() {
- public void selectionChanged (SelectionChangedEvent event)
- {
- for (int i = 0; i < selectionListeners.size(); i++)
- {
- if (selectionListeners.get(i) instanceof ISelectionChangedListener)
- {
- ((ISelectionChangedListener) selectionListeners.get(i)).selectionChanged(event);
- }
- }
- }
- };
-
-
- fillLocalToolBar();
-
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection sel)
- {
- }
-
- public void dispose()
- {
- ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService();
- selectionService.removeSelectionListener(this);
- _folder.dispose();
-
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- registry.removeSystemResourceChangeListener(this);
- registry.removeSystemRemoteChangeListener(this);
-
-
- super.dispose();
- }
-
- public void updateActionStates()
- {
-
- if (_folder != null && _folder.getInput() != null)
- {
- }
- if (_clearAllAction != null)
- {
- _clearAllAction.checkEnabledState();
- _clearSelectedAction.checkEnabledState();
- _selectColumnsAction.checkEnabledState();
- _refreshAction.checkEnabledState();
- _positionToAction.checkEnabledState();
- _subsetAction.checkEnabledState();
- }
- }
-
- public void fillLocalToolBar()
- {
- if (_folder != null )
- {
-
-
- //updateActionStates();
-
- IActionBars actionBars = getViewSite().getActionBars();
-
- _refreshAction= new RefreshAction();
-
- _clearSelectedAction = new ClearSelectedAction(this);
- _clearAllAction = new ClearAction(this);
-
- _selectColumnsAction = new SelectColumnsAction();
-
- _subsetAction = new SubSetAction();
- _positionToAction = new PositionToAction();
-
- IToolBarManager toolBarManager = actionBars.getToolBarManager();
- addToolBarItems(toolBarManager);
- addToolBarMenuItems(actionBars.getMenuManager());
- }
- updateActionStates();
- }
-
- private void addToolBarItems(IToolBarManager toolBarManager)
- {
- toolBarManager.removeAll();
-
- toolBarManager.add(_refreshAction);
-
- toolBarManager.add(new Separator());
- toolBarManager.add(_clearSelectedAction);
- toolBarManager.add(_clearAllAction);
-
- toolBarManager.add(new Separator());
- toolBarManager.add(_selectColumnsAction);
-
- toolBarManager.update(true);
- }
-
-
-
- public void selectionChanged(SelectionChangedEvent e)
- {
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener)
- {
- if (selectionListeners != null)
- selectionListeners.add(listener);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener)
- {
- if (selectionListeners != null)
- selectionListeners.remove(listener);
- }
-
- public ISelection getSelection()
- {
- if (viewerProvider == null)
- return null;
- else
- return viewerProvider.getSelection();
- }
-
- /**
- * Sets the wrapped selection provider.
- * This method should only be called when the viewer changes.
- * @param newProvider The new wrapped selection provider.
- */
- public void setActiveViewerSelectionProvider(ISelectionProvider newProvider)
- {
- if (viewerProvider != null)
- viewerProvider.removeSelectionChangedListener(selectionListener);
-
- viewerProvider = newProvider;
-
- if (newProvider != null)
- {
- newProvider.addSelectionChangedListener(selectionListener);
-
- // Create a new event and tell all listeners about it, so that the properties
- // view is updated to show the new viewers selected object
- SelectionChangedEvent event = new SelectionChangedEvent(newProvider, newProvider.getSelection());
- for (int i = 0; i < selectionListeners.size(); i++)
- {
- if (selectionListeners.get(i) instanceof ISelectionChangedListener)
- {
- ((ISelectionChangedListener) selectionListeners.get(i)).selectionChanged(event);
- }
- }
- }
- }
-
- public void setSelection(ISelection selection)
- {
- if (viewerProvider != null)
- viewerProvider.setSelection(selection);
- }
-
- public void addItemToMonitor(IAdaptable root)
- {
- if (root != null)
- {
- _folder.addItemToMonitor(root, true);
- if (true)
- updateActionStates();
- }
- }
-
- public void removeItemToMonitor(IAdaptable root)
- {
- if (root != null)
- {
- _folder.remove(root);
- if (true)
- updateActionStates();
- }
- }
-
- public void removeAllItemsToMonitor()
- {
- while (_folder.getInput() != null)
- {
- removeItemToMonitor((IAdaptable)_folder.getInput());
- }
- }
-
- public void setInput(IAdaptable object)
- {
- _folder.setInput(object);
- }
-
-
- /**
- * Used to asynchronously update the view whenever properties change.
- */
- public void systemResourceChanged(ISystemResourceChangeEvent event)
- {
-
- Object child = event.getSource();
- SystemTableView viewer = getViewer();
- if (viewer != null)
- {
- Object input = viewer.getInput();
- switch (event.getType())
- {
- case ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE:
- {
- _folder.removeDisconnected();
- updateActionStates();
- }
- break;
- case ISystemResourceChangeEvents.EVENT_RENAME:
- {
- if (child == input)
- {
- _folder.getCurrentTabItem().updateTitle((IAdaptable)child);
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_DELETE:
- case ISystemResourceChangeEvents.EVENT_DELETE_MANY:
- {
- if (child == input)
- {
- removeItemToMonitor((IAdaptable)child);
- }
- }
- break;
- default:
- break;
- }
- }
- }
-
- /**
- * 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.
- * @see org.eclipse.rse.core.events.ISystemRemoteChangeEvent
- */
- public void systemRemoteResourceChanged(ISystemRemoteChangeEvent event)
- {
- int eventType = event.getEventType();
- Object remoteResource = event.getResource();
-
- java.util.List remoteResourceNames = null;
- if (remoteResource instanceof java.util.List)
- {
- remoteResourceNames = (java.util.List) remoteResource;
- remoteResource = remoteResourceNames.get(0);
- }
-
- Object child = event.getResource();
-
- SystemTableView viewer = getViewer();
- if (viewer != null)
- {
- Object input = viewer.getInput();
- if (input == child || child instanceof Vector)
- {
- switch (eventType)
- {
- // --------------------------
- // REMOTE RESOURCE CHANGED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CHANGED :
- break;
-
- // --------------------------
- // REMOTE RESOURCE CREATED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED :
- break;
-
- // --------------------------
- // REMOTE RESOURCE DELETED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED :
- {
- if (child instanceof Vector)
- {
- /*Vector vec = (Vector)child;
- for (int v = 0; v < vec.size(); v++)
- {
- Object c = vec.get(v);
-
- }*/
- }
- else
- {
-
- return;
- }
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE RENAMED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED :
- {
- addItemToMonitor((IAdaptable)child);
- }
-
- break;
- }
- }
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- Widget source = e.widget;
- Widget item = e.item;
- Object data = item.getData();
- MonitorViewPage page = null;
-
- if (data instanceof MonitorViewPage)
- page = (MonitorViewPage) data;
-
- // Set the wrapped viewer to be the viewer of the new selected tab
- if (page != null)
- {
- SystemTableView viewer = page.getViewer();
- setActiveViewerSelectionProvider(viewer);
- }
-
- if (source == _folder.getFolder())
- {
- updateActionStates();
- }
- }
-
-
-// -------------------------------
- // ISystemMessageLine interface...
- // -------------------------------
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage()
- {
- _errorMessage = null;
- sysErrorMessage = null;
- if (_statusLine != null)
- _statusLine.setErrorMessage(_errorMessage);
- }
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage()
- {
- _message = null;
- if (_statusLine != null)
- _statusLine.setMessage(_message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage()
- {
- return _errorMessage;
- }
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null<code> is returned.
- */
- public String getMessage()
- {
- return _message;
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message)
- {
- this._errorMessage = message;
- if (_statusLine != null)
- _statusLine.setErrorMessage(message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public SystemMessage getSystemErrorMessage()
- {
- return sysErrorMessage;
- }
-
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(SystemMessage message)
- {
- sysErrorMessage = message;
- setErrorMessage(message.getLevelOneText());
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(Throwable exc)
- {
- setErrorMessage(exc.getMessage());
- }
-
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message)
- {
- this._message = message;
- if (_statusLine != null)
- _statusLine.setMessage(message);
- }
- /**
- *If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(SystemMessage message)
- {
- setMessage(message.getLevelOneText());
- }
-
- private void addToolBarMenuItems(IMenuManager menuManager)
- {
- menuManager.removeAll();
- menuManager.add(_selectColumnsAction);
- menuManager.add(new Separator("Filter")); //$NON-NLS-1$
- menuManager.add(_positionToAction);
- menuManager.add(_subsetAction);
- }
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/TabFolderLayout.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/TabFolderLayout.java
deleted file mode 100644
index 3328c9879..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/monitor/TabFolderLayout.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.monitor;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-public class TabFolderLayout extends Layout {
-
-
-
- protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
- return new Point(wHint, hHint);
-
- Control [] children = composite.getChildren ();
- int count = children.length;
- int maxWidth = 0, maxHeight = 0;
- for (int i=0; i<count; i++) {
- Control child = children [i];
- Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
- maxWidth = Math.max (maxWidth, pt.x);
- maxHeight = Math.max (maxHeight, pt.y);
- }
-
- if (wHint != SWT.DEFAULT)
- maxWidth= wHint;
- if (hHint != SWT.DEFAULT)
- maxHeight= hHint;
-
- return new Point(maxWidth, maxHeight);
-
- }
-
- protected void layout (Composite composite, boolean flushCache) {
- Rectangle rect= composite.getClientArea();
-
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- children[i].setBounds(rect);
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/BrowseAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/BrowseAction.java
deleted file mode 100644
index 2b390b576..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/BrowseAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split SystemRegistryUI from SystemRegistry implementation
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.scratchpad;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.rse.ui.internal.model.SystemRegistryUI;
-import org.eclipse.rse.ui.internal.model.SystemScratchpad;
-
-
-
-class BrowseAction extends Action
-{
- protected SystemScratchpadView _view;
- protected SystemScratchpad _scratchPad;
- public BrowseAction(SystemScratchpadView view, String label, ImageDescriptor des)
- {
- super(label, des);
- _view = view;
- setImageDescriptor(des);
- setToolTipText(label);
- _scratchPad = SystemRegistryUI.getInstance().getSystemScratchPad();
- }
-
- public void checkEnabledState()
- {
- if (_view.getInput() != null)
- {
- setEnabled(true);
- }
- else
- {
- setEnabled(false);
- }
- }
-
- public void run()
- {
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/ClearAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/ClearAction.java
deleted file mode 100644
index aefbac41f..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/ClearAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Kevin Doyle (IBM) - [189150] setSelection(null) added to clear()
- * Kevin Doyle (IBM) - [194899] Remove All should do a full reset of the scratchpad
- *******************************************************************************/
-
-
-package org.eclipse.rse.internal.ui.view.scratchpad;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-
-
-
-public class ClearAction extends BrowseAction
-{
-
- public ClearAction(SystemScratchpadView view)
- {
- super(view, SystemResources.ACTION_CLEAR_ALL_LABEL,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CLEAR_ALL_ID));
-
- setToolTipText(SystemResources.ACTION_CLEAR_ALL_TOOLTIP);
- // TODO DKM - get help for this!
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CLEAR_CONSOLE_ACTION);
- }
-
- public void checkEnabledState()
- {
- setEnabled(_scratchPad.hasChildren());
- }
-
- public void run()
- {
- clear();
- }
-
- // clear contents of the current command viewer
- private void clear()
- {
- // Reset the SystemScratchpad
- _scratchPad.clearChildren();
- // Set the input of the view to SystemScratchpad if it has changed
- if (_view.getInput() != _scratchPad) {
- _view.setInput(_scratchPad);
- }
- // Refresh the Scratchpad and update action states
- RSECorePlugin.getTheSystemRegistry().fireEvent(new SystemResourceChangeEvent(_scratchPad, ISystemResourceChangeEvents.EVENT_REFRESH, _scratchPad));
- _view.setSelection(null);
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/ClearSelectedAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/ClearSelectedAction.java
deleted file mode 100644
index f4f717c8d..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/ClearSelectedAction.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Kevin Doyle (IBM) - [189150] setSelection(null) added to clear()
- * Kevin Doyle (IBM) - [193148] Clear Selected Action enabled when not on a root element
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.scratchpad;
-import java.util.Iterator;
-
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.SystemResourceChangeEvent;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-
-public class ClearSelectedAction extends BrowseAction
-{
- public ClearSelectedAction(SystemScratchpadView view)
- {
- super(view, SystemResources.ACTION_CLEAR_SELECTED_LABEL,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CLEAR_SELECTED_ID));
-
- setToolTipText(SystemResources.ACTION_CLEAR_SELECTED_TOOLTIP);
- // TODO DKM - get help for this!
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CLEAR_CONSOLE_ACTION);
- }
-
- public void checkEnabledState()
- {
- if (_scratchPad.hasChildren())
- {
- StructuredSelection selection = (StructuredSelection)_view.getSelection();
- if (selection != null)
- {
- Iterator iterator = selection.iterator();
- while (iterator.hasNext())
- {
- Object obj = iterator.next();
- if (!_scratchPad.contains(obj))
- {
- setEnabled(false);
- return;
- }
- else
- {
- if (selection instanceof TreeSelection)
- {
- TreeSelection treeSelection = (TreeSelection) selection;
- TreePath[] paths = treeSelection.getPathsFor(obj);
- // if paths[0].getSegmentCount is not 1 then it's not a root
- if (paths.length > 0 && paths[0].getSegmentCount() != 1)
- {
- setEnabled(false);
- return;
- }
- }
- }
- }
- setEnabled(true);
- return;
- }
- }
-
- setEnabled(false);
- }
-
- public void run()
- {
- clear();
- }
-
- private void clear()
- {
- StructuredSelection selection = (StructuredSelection)_view.getSelection();
- if (selection != null)
- {
- Iterator iterator = selection.iterator();
- while (iterator.hasNext())
- {
- _scratchPad.removeChild(iterator.next());
- }
- RSECorePlugin.getTheSystemRegistry().fireEvent(new SystemResourceChangeEvent(_scratchPad, ISystemResourceChangeEvents.EVENT_REFRESH, _scratchPad));
- _view.setSelection(null);
- //_view.updateActionStates();
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadView.java
deleted file mode 100644
index 7eaa5aeae..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadView.java
+++ /dev/null
@@ -1,1976 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Kevin Doyle (IBM) - [192278] Removed handleKeyPressed
- * Kevin Doyle (IBM) - [189150] _selectionFlagsUpdated reset after clear action performed
- * Kevin Doyle (IBM) - [195537] Use Hashlookup and ElementComparer
- * Kevin Doyle (IBM) - [189423] Scratchpad not completely updated after Delete.
- * Kevin Doyle (IBM) - [193151] Scratchpad not updated on Move
- * Kevin Doyle (IBM) - [189421] Scratchpad not updated after Rename
- * David McKnight (IBM) - [197860] drag and drop consistency - no text transfer
- * Kevin Doyle (IBM) - [197841] "Terminate and Remove" should remove the shell from Scratchpad
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.scratchpad;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.window.SameShellProvider;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvent;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
-import org.eclipse.rse.core.events.ISystemRemoteChangeListener;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterReference;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemContainer;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
-import org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonSelectAllAction;
-import org.eclipse.rse.internal.ui.actions.SystemOpenExplorerPerspectiveAction;
-import org.eclipse.rse.internal.ui.actions.SystemShowInTableAction;
-import org.eclipse.rse.internal.ui.actions.SystemSubMenuManager;
-import org.eclipse.rse.internal.ui.view.ElementComparer;
-import org.eclipse.rse.internal.ui.view.SafeTreeViewer;
-import org.eclipse.rse.internal.ui.view.SystemView;
-import org.eclipse.rse.internal.ui.view.SystemViewDataDragAdapter;
-import org.eclipse.rse.internal.ui.view.SystemViewDataDropAdapter;
-import org.eclipse.rse.internal.ui.view.SystemViewMenuListener;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemDeleteTarget;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.ISystemRenameTarget;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.actions.ISystemAction;
-import org.eclipse.rse.ui.actions.SystemRefreshAction;
-import org.eclipse.rse.ui.internal.model.SystemRegistryUI;
-import org.eclipse.rse.ui.internal.model.SystemScratchpad;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ContextObject;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
-import org.eclipse.rse.ui.view.ISystemSelectAllTarget;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.part.EditorInputTransfer;
-import org.eclipse.ui.part.PluginTransfer;
-
-
-/**
- * This subclass of the standard JFace tabletree viewer is used to
- * show a generic tabletree view of the selected object
- * <p>
- */
-public class SystemScratchpadView
- // TODO change TreeViewer to ScratchpadViewer when Eclipse fixes SWT viewer
-// extends ScratchpadViewer
- extends SafeTreeViewer
- implements IMenuListener, ISystemDeleteTarget,
- ISystemRenameTarget, ISystemSelectAllTarget, ISystemShellProvider,
- ISystemResourceChangeListener, ISystemRemoteChangeListener,
- ISelectionChangedListener, ISelectionProvider
-{
- private Object _objectInput;
- //private ArrayList _attributeColumns;
- private TableLayout _layout;
- private SystemScratchpadViewProvider _provider;
- private MenuManager _menuManager;
-
- // these variables were copied from SystemView to allow for limited support
- // of actions. I say limited because somethings don't yet work properly.
- protected SystemRefreshAction _refreshAction;
- protected PropertyDialogAction _propertyDialogAction;
- protected SystemOpenExplorerPerspectiveAction _openToPerspectiveAction;
- protected SystemShowInTableAction _showInTableAction;
-
- // global actions
- // Note the Edit menu actions are set in SystemViewPart. Here we use these
- // actions from our own popup menu actions.
- protected SystemCommonDeleteAction _deleteAction;
- // for global delete menu item
- protected SystemCommonRenameAction _renameAction;
- // for common rename menu item
- protected SystemCommonSelectAllAction _selectAllAction;
- // for common Ctrl+A select-all
- protected ClearSelectedAction _clearSelectedAction;
- protected ClearAction _clearAllAction;
-
- protected boolean _selectionShowRefreshAction;
- protected boolean _selectionShowOpenViewActions;
- protected boolean _selectionShowDeleteAction;
- protected boolean _selectionShowRenameAction;
- protected boolean _selectionEnableDeleteAction;
- protected boolean _selectionEnableRenameAction;
-
- protected boolean _selectionIsRemoteObject = true;
- protected boolean _selectionFlagsUpdated = false;
-
-
- private ISystemMessageLine _messageLine;
- protected boolean menuListenerAdded = false;
-
- private static final int LEFT_BUTTON = 1;
- private int mouseButtonPressed = LEFT_BUTTON;
-
- public boolean debugRemote = false;
-
- /**
- * Constructor for the table view
- *
- */
- public SystemScratchpadView(Tree tableTree, ISystemMessageLine msgLine)
- {
- super(tableTree);
- _messageLine = msgLine;
- //_attributeColumns = new ArrayList();
- _layout = new TableLayout();
-
- _provider = new SystemScratchpadViewProvider(this);
-
- setUseHashlookup(true);
- setComparer(new ElementComparer());
-
- setContentProvider(_provider);
-
- IWorkbench wb = PlatformUI.getWorkbench();
- setLabelProvider(new DecoratingLabelProvider(_provider, wb.getDecoratorManager().getLabelDecorator()));
-
- //setLabelProvider(_provider);
-
- _menuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- _menuManager.setRemoveAllWhenShown(true);
- _menuManager.addMenuListener(this);
- Menu menu = _menuManager.createContextMenu(tableTree);
- tableTree.setMenu(menu);
-
- addSelectionChangedListener(this);
-
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.addSystemResourceChangeListener(this);
- sr.addSystemRemoteChangeListener(this);
-
- initDragAndDrop();
-
- tableTree.setVisible(false);
- getControl().addMouseListener(new MouseAdapter()
- {
- public void mouseDown(MouseEvent e)
- {
- mouseButtonPressed = e.button; //d40615
- }
- });
- }
-
- public Layout getLayout()
- {
- return _layout;
- }
-
-
- /**
- * Return the popup menu for the table
- */
- public Menu getContextMenu()
- {
- return getTree().getMenu();
- }
- /**
- * Return the popup menu for the table
- */
- public MenuManager getContextMenuManager()
- {
- return _menuManager;
- }
-
- /**
- * Called whenever the input for the view changes
- */
- public void inputChanged(Object newObject, Object oldObject)
- {
- if (newObject instanceof IAdaptable)
- {
- getTree().setVisible(true);
- _objectInput = newObject;
-
-
- super.inputChanged(newObject, oldObject);
- }
- else if (newObject == null)
- {
- getTree().setVisible(false);
- _objectInput = null;
- }
- }
-
- public Object getInput()
- {
- return _objectInput;
- }
-
- /**
- * Convenience method for retrieving the view adapter for an object
- */
- protected ISystemViewElementAdapter getViewAdapter(Object obj)
- {
- return SystemAdapterHelpers.getViewAdapter(obj);
- }
-
-
-
- /**
- * Initialize drag and drop support for this view.
- *
- */
- protected void initDragAndDrop()
- {
- int ops = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] dragtransfers = new Transfer[]
- { PluginTransfer.getInstance(),
- EditorInputTransfer.getInstance()
- };
-
- Transfer[] droptransfers = new Transfer[]
- { PluginTransfer.getInstance(),
- FileTransfer.getInstance(),
- EditorInputTransfer.getInstance()
- };
-
- addDragSupport(ops | DND.DROP_DEFAULT, dragtransfers, new SystemViewDataDragAdapter(this));
- addDropSupport(ops | DND.DROP_DEFAULT, droptransfers, new SystemViewDataDropAdapter(this));
- }
-
-
- /**
- * Used to asynchronously update the view whenever properties change.
- */
- public void systemResourceChanged(ISystemResourceChangeEvent event)
- {
- Object parent = event.getParent();
- Object child = event.getSource();
- int eventType = event.getType();
- switch (eventType)
- {
- case ISystemResourceChangeEvents.EVENT_RENAME_FILTER_REFERENCE:
- case ISystemResourceChangeEvents.EVENT_CHANGE_FILTER_REFERENCE:
- case ISystemResourceChangeEvents.EVENT_CHANGE_FILTERSTRING_REFERENCE:
- {
- if (child instanceof ISystemFilter)
- {
- IRSEBaseReferencingObject[] references = ((ISystemFilter)child).getReferencingObjects();
- for (int i = 0; i < references.length; i++)
- {
- IRSEBaseReferencingObject ref = references[i];
- Widget w = findItem(ref);
- if (w != null)
- {
- internalRefresh(ref);
- }
- }
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE :
- case ISystemResourceChangeEvents.EVENT_PROPERTYSHEET_UPDATE :
- case ISystemResourceChangeEvents.EVENT_ICON_CHANGE:
- {
- Widget w = findItem(child);
-
- if (w != null)
- {
- updateItem(w, child);
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_ADD :
- case ISystemResourceChangeEvents.EVENT_ADD_RELATIVE :
- {
- boolean addingConnection = (child instanceof IHost);
- if (_objectInput instanceof ISystemRegistry && addingConnection)
- {
- SystemScratchpadViewProvider provider = (SystemScratchpadViewProvider) getContentProvider();
-
- if (provider != null)
- {
-
- internalRefresh(_objectInput);
- }
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_REFRESH:
- case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE:
- {
- internalRefresh(child);
- }
- break;
- case ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED:
- {
- IStructuredSelection sel = (IStructuredSelection)getSelection();
- Iterator iter = sel.iterator();
- while (iter.hasNext())
- {
- Object obj = iter.next();
- internalRefresh(obj);
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_RENAME:
- {
- Widget w = findItem(child);
- if (w != null)
- {
- updateItem(w, child);
- }
- }
- break;
- case ISystemResourceChangeEvents.EVENT_DELETE:
- case ISystemResourceChangeEvents.EVENT_COMMAND_SHELL_REMOVED:
- {
- deleteObject(child);
- }
- break;
- case ISystemResourceChangeEvents.EVENT_DELETE_MANY:
- {
- Object[] multiSrc = event.getMultiSource();
- if (multiSrc != null) {
- for (int i = 0; i < multiSrc.length; i++) {
- deleteObject(multiSrc[i]);
- }
- }
- }
- break;
- default :
- break;
-
- }
-
- if (child == _objectInput || parent == _objectInput)
- {
- SystemScratchpadViewProvider provider = (SystemScratchpadViewProvider) getContentProvider();
-
- if (provider != null)
- {
-
-
- try
- {
- internalRefresh(_objectInput);
- }
- catch (Exception e)
- {
- SystemBasePlugin.logError(e.getMessage());
- }
- }
- }
- }
-
- /**
- * 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.
- * @see org.eclipse.rse.core.events.ISystemRemoteChangeEvent
- */
- public void systemRemoteResourceChanged(ISystemRemoteChangeEvent event)
- {
- int eventType = event.getEventType();
- Object remoteResourceParent = event.getResourceParent();
- Object remoteResource = event.getResource();
- //boolean originatedHere = (event.getOriginatingViewer() == this);
- List remoteResourceNames = null;
- if (remoteResource instanceof List)
- {
- remoteResourceNames = (List) remoteResource;
- remoteResource = remoteResourceNames.get(0);
- }
- String remoteResourceName = getRemoteResourceAbsoluteName(remoteResource);
- if (remoteResourceName == null)
- return;
-
- switch (eventType)
- {
- // --------------------------
- // REMOTE RESOURCE CHANGED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CHANGED :
- {
- if (remoteResourceParent == getInput())
- {
- Widget w = findItem(remoteResource);
- if (w != null)
- {
- updateItem(w, remoteResource);
- }
-
- }
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE CREATED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED :
- {
- // Since all creation operations can only be done on the same parent
- // we only need to handle refreshing of the parent
- // Must handle String's as Move operation create event passes us Strings
- if (remoteResourceParent instanceof String)
- {
- Item item = findFirstRemoteItemReference((String) remoteResourceParent, null, null);
- if (item != null)
- internalRefresh(item.getData());
- }
- else
- {
- internalRefresh(remoteResourceParent);
- }
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE DELETED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED :
- {
- if (remoteResourceNames != null)
- {
- for (int i = 0; i < remoteResourceNames.size(); i++)
- {
- deleteObject(remoteResourceNames.get(i));
- }
- }
- else
- {
- deleteObject(remoteResource);
- }
-
- /*
- {
- Object dchild = remoteResource;
-
-
- ISystemViewElementAdapter dadapt = getAdapter(dchild);
- if (dadapt != null)
- {
- SubSystem dSubSystem = dadapt.getSubSystem(dchild);
- String dkey = dadapt.getAbsoluteName(dchild);
-
- if (provider != null)
- {
- Object[] children = provider.getChildren(_objectInput);
- for (int i = 0; i < children.length; i++)
- {
- Object existingChild = children[i];
- if (existingChild != null)
- {
- ISystemViewElementAdapter eadapt = getAdapter(existingChild);
- SubSystem eSubSystem = eadapt.getSubSystem(existingChild);
-
- if (dSubSystem == eSubSystem)
- {
- String ekey = eadapt.getAbsoluteName(existingChild);
- if (ekey.equals(dkey))
- {
- // do a full refresh
- refresh();
- }
- }
-
- }
- }
- }
- }
- }
- */
-
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE RENAMED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED :
- {
- renameRemoteObject(remoteResource, event.getOldNames()[0]);
- }
-
- break;
- }
- }
-
- /**
- * Turn a given remote object reference into a fully qualified absolute name
- */
- private String getRemoteResourceAbsoluteName(Object remoteResource)
- {
- if (remoteResource == null)
- return null;
- String remoteResourceName = null;
- if (remoteResource instanceof String)
- remoteResourceName = (String) remoteResource;
- else
- {
- ISystemViewElementAdapter ra = getViewAdapter(remoteResource);
- if (ra == null)
- return null;
- remoteResourceName = ra.getAbsoluteName(remoteResource);
- }
- return remoteResourceName;
- }
-
- /**
- * Display a message/status on the message/status line
- */
- public void displayMessage(String msg)
- {
- if (_messageLine != null)
- _messageLine.setMessage(msg);
- }
- /**
- * Clear message/status shown on the message/status line
- */
- public void clearMessage()
- {
- if (_messageLine != null)
- _messageLine.clearMessage();
- }
-
- public void selectionChanged(SelectionChangedEvent event)
- {
-
- // Set _selectionFlagsUpdate to false, so the next time the context menu
- // is requested we rescan the selections to determine which actions
- // to show and enable/disable.
- // Setting this to false will force a rescan because in fillContextMenu()
- // if this is false it will call scanSelections();
- _selectionFlagsUpdated = false;
- IStructuredSelection sel = (IStructuredSelection)event.getSelection();
- Object firstSelection = sel.getFirstElement();
- if (firstSelection == null)
- return;
-
- ISystemViewElementAdapter adapter = getViewAdapter(firstSelection);
- if (adapter != null)
- {
- displayMessage(adapter.getStatusLineText(firstSelection));
- if ((mouseButtonPressed == LEFT_BUTTON))
- adapter.selectionChanged(firstSelection);
- }
- else
- clearMessage();
- }
-
- public void dispose()
- {
- removeAsListener();
-
- Composite tree = getTree();
-
- boolean isDisposed = tree.isDisposed();
-
- // dispose control if not disposed
- if (!isDisposed) {
- tree.dispose();
- }
- }
-
- /**
- * Remove as listener.
- */
- public void removeAsListener() {
-
- // remove listeners
- removeSelectionChangedListener(this);
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- sr.removeSystemResourceChangeListener(this);
- sr.removeSystemRemoteChangeListener(this);
-
- //Composite tree = getTree();
- //boolean isDisposed = tree.isDisposed();
- }
-
- /*
- * Everything below is basically stuff copied and pasted from SystemsView
- * -There needs to be cleaning up of the below code as some of this stuff
- * is broken for the table view
- *
- *
- public void createStandardGroups(IMenuManager menu)
- {
- if (!menu.isEmpty())
- return;
- // simply sets partitions in the menu, into which actions can be directed.
- // Each partition can be delimited by a separator (new Separator) or not (new GroupMarker).
- // Deleted groups are not used yet.
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_NEW));
- // new->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_GOTO));
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_EXPANDTO));
- // expand to->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_EXPAND));
- // expand, collapse
- // goto into, go->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_OPENWITH));
- // open with->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_BROWSEWITH));
- // browse with ->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_OPEN));
- // open xxx
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_WORKWITH));
- // work with->
- //menu.add(new Separator(ISystemContextMenuConstants.GROUP_SHOW)); // show->type hierarchy, in-navigator
- 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 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
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_IMPORTEXPORT));
- // get or put actions
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_ADAPTERS));
- // actions queried from adapters
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_ADDITIONS));
- // user or BP/ISV additions
- //menu.add(new Separator(ISystemContextMenuConstants.GROUP_VIEWER_SETUP)); // ? Probably View->by xxx, yyy
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_TEAM));
- // Team
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_COMPAREWITH));
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_REPLACEWITH));
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_PROPERTIES));
- // Properties
- }*/
-
- /**
- * Rather than pre-defining this common action we wait until it is first needed,
- * for performance reasons.
- */
- protected PropertyDialogAction getPropertyDialogAction()
- {
- if (_propertyDialogAction == null)
- {
- _propertyDialogAction = new PropertyDialogAction(new SameShellProvider(getShell()), this);
- //propertyDialogAction.setToolTipText(" ");
- }
- _propertyDialogAction.selectionChanged(getSelection());
- return _propertyDialogAction;
- }
-
-
- /**
- * Return the select All action
- */
- protected IAction getSelectAllAction()
- {
- if (_selectAllAction == null)
- _selectAllAction = new SystemCommonSelectAllAction(getShell(), this, this);
- return _selectAllAction;
- }
-
- /**
- * Rather than pre-defined this common action we wait until it is first needed,
- * for performance reasons.
- */
- protected IAction getRenameAction()
- {
- if (_renameAction == null)
- _renameAction = new SystemCommonRenameAction(getShell(), this);
- return _renameAction;
- }
- /**
- * Rather than pre-defined this common action we wait until it is first needed,
- * for performance reasons.
- */
- protected IAction getDeleteAction()
- {
- if (_deleteAction == null)
- _deleteAction = new SystemCommonDeleteAction(getShell(), this);
- return _deleteAction;
- }
-
- protected IAction getClearSelectedAction()
- {
- if (_clearSelectedAction == null)
- _clearSelectedAction = new ClearSelectedAction(this);
- _clearSelectedAction.checkEnabledState();
- return _clearSelectedAction;
- }
-
- protected IAction getClearAllAction()
- {
- if (_clearAllAction == null)
- _clearAllAction = new ClearAction(this);
- _clearAllAction.checkEnabledState();
- return _clearAllAction;
- }
-
- /**
- * Return the refresh action
- */
- protected IAction getRefreshAction()
- {
- if (_refreshAction == null)
- _refreshAction = new SystemRefreshAction(getShell());
- return _refreshAction;
- }
- /*
- * Get the common "Open to->" action for opening a new Remote System Explorer view,
- * scoped to the currently selected object.
- *
- protected SystemCascadingOpenToAction getOpenToAction()
- {
- if (openToAction == null)
- openToAction = new SystemCascadingOpenToAction(getShell(),getWorkbenchWindow());
- return openToAction;
- } NOT USED YET */
- /**
- * Get the common "Open to->" action for opening a new Remote System Explorer view,
- * scoped to the currently selected object.
- */
- protected SystemOpenExplorerPerspectiveAction getOpenToPerspectiveAction()
- {
- if (_openToPerspectiveAction == null)
- {
- IWorkbench desktop = PlatformUI.getWorkbench();
- IWorkbenchWindow win = desktop.getActiveWorkbenchWindow();
-
- _openToPerspectiveAction = new SystemOpenExplorerPerspectiveAction(getShell(), win);
- }
- //getWorkbenchWindow());
- return _openToPerspectiveAction;
- }
-
- protected SystemShowInTableAction getShowInTableAction()
- {
- if (_showInTableAction == null)
- {
- _showInTableAction = new SystemShowInTableAction(getShell());
- }
- //getWorkbenchWindow());
- return _showInTableAction;
- }
-
- public Shell getShell()
- {
- return getTree().getShell();
- }
-
- /**
- * Required method from ISystemDeleteTarget.
- * Decides whether to even show the delete menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean showDelete()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionShowDeleteAction;
- }
- /**
- * Required method from ISystemDeleteTarget
- * Decides whether to enable the delete menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean canDelete()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionEnableDeleteAction;
- }
-
- /*
- * Required method from ISystemDeleteTarget
- */
- public boolean doDelete(IProgressMonitor monitor)
- {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
- //int selectedCount = selection.size();
- //Object multiSource[] = new Object[selectedCount];
- //int idx = 0;
- Object element = null;
- //Object parentElement = getSelectedParent();
- ISystemViewElementAdapter adapter = null;
- boolean ok = true;
- boolean anyOk = false;
- Vector deletedVector = new Vector();
- try
- {
- while (ok && elements.hasNext())
- {
- element = elements.next();
- //multiSource[idx++] = element;
- adapter = getViewAdapter(element);
- ok = adapter.doDelete(getShell(), element, monitor);
- if (ok)
- {
- anyOk = true;
- deletedVector.addElement(element);
- }
- }
- }
- catch (SystemMessageException exc)
- {
- SystemMessageDialog.displayErrorMessage(getShell(), exc.getSystemMessage());
- ok = false;
- }
- catch (Exception exc)
- {
- 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));
- ok = false;
- }
- if (anyOk)
- {
- Object[] deleted = new Object[deletedVector.size()];
- for (int idx = 0; idx < deleted.length; idx++)
- deleted[idx] = deletedVector.elementAt(idx);
- if (_selectionIsRemoteObject)
- sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED, deletedVector, null, null, null, this);
- else
- sr.fireEvent(new org.eclipse.rse.core.events.SystemResourceChangeEvent(deleted, ISystemResourceChangeEvents.EVENT_DELETE_MANY, getInput()));
- }
- return ok;
- }
-
- // ---------------------------
- // ISYSTEMRENAMETARGET METHODS
- // ---------------------------
-
- /**
- * Required method from ISystemRenameTarget.
- * Decides whether to even show the rename menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean showRename()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionShowRenameAction;
- }
- /**
- * Required method from ISystemRenameTarget
- * Decides whether to enable the rename menu item.
- * Assumes scanSelections() has already been called
- */
- public boolean canRename()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionEnableRenameAction;
- }
-
- // default implementation
- // in default table, parent is input
- protected Object getParentForContent(Object element)
- {
- return _objectInput;
- }
-
- /**
- * Required method from ISystemRenameTarget
- */
- public boolean doRename(String[] newNames)
- {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
- //int selectedCount = selection.size();
- Object element = null;
-
- ISystemViewElementAdapter adapter = null;
- ISystemRemoteElementAdapter remoteAdapter = null;
- String oldFullName = null;
- boolean ok = true;
- try
- {
- int nameIdx = 0;
- while (ok && elements.hasNext())
- {
- element = elements.next();
- adapter = getViewAdapter(element);
- Object parentElement = getParentForContent(element);
-
- remoteAdapter = getRemoteAdapter(element);
- if (remoteAdapter != null)
- oldFullName = remoteAdapter.getAbsoluteName(element);
- // pre-rename
- ok = adapter.doRename(getShell(), element, newNames[nameIdx++], null);
- if (ok)
- {
- if (remoteAdapter != null) {
- sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED, element, parentElement, remoteAdapter.getSubSystem(element), new String[]{oldFullName}, this);
- }
- else {
- sr.fireEvent(new org.eclipse.rse.core.events.SystemResourceChangeEvent(element, ISystemResourceChangeEvents.EVENT_RENAME, parentElement));
- }
- }
- }
- }
- catch (SystemMessageException exc)
- {
- SystemMessageDialog.displayErrorMessage(getShell(), exc.getSystemMessage());
- ok = false;
- }
- catch (Exception exc)
- {
- //String msg = exc.getMessage();
- //if ((msg == null) || (exc instanceof ClassCastException))
- // msg = exc.getClass().getName();
- SystemMessageDialog.displayErrorMessage(getShell(), RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_RENAMING).makeSubstitution(element, exc),
- //msg),
- exc);
- ok = false;
- }
- return ok;
- }
-
- /**
- * Returns the implementation of ISystemRemoteElement for the given
- * object. Returns null if this object does not adaptable to this.
- */
- protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
- {
- ISystemRemoteElementAdapter adapter = null;
- if (!(o instanceof IAdaptable))
- adapter = (ISystemRemoteElementAdapter) Platform.getAdapterManager().getAdapter(o, ISystemRemoteElementAdapter.class);
- else
- adapter = (ISystemRemoteElementAdapter) ((IAdaptable) o).getAdapter(ISystemRemoteElementAdapter.class);
- if ((adapter != null) && (adapter instanceof ISystemViewElementAdapter))
- ((ISystemViewElementAdapter) adapter).setViewer(this);
- return adapter;
- }
-
- /**
- * Return true if select all should be enabled for the given object.
- * For a tree view, you should return true if and only if the selected object has children.
- * You can use the passed in selection or ignore it and query your own selection.
- */
- public boolean enableSelectAll(IStructuredSelection selection)
- {
- return true;
- }
- /**
- * 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
- * of the given selected object. You can use the passed in selected object
- * or ignore it and query the selected object yourself.
- */
- public void doSelectAll(IStructuredSelection selection)
- {
-
- Tree tree = getTree();
-
- Tree theTree = tree;
- theTree.setSelection(theTree.getItems());
- TreeItem[] items = theTree.getItems();
- Object[] objects = new Object[items.length];
- for (int idx = 0; idx < items.length; idx++)
- objects[idx] = items[idx].getData();
- fireSelectionChanged(new SelectionChangedEvent(this, new StructuredSelection(objects)));
-
-
- }
-
- public void menuAboutToShow(IMenuManager manager)
- {
- SystemView.createStandardGroups(manager);
- if (!menuListenerAdded)
- {
- if (manager instanceof MenuManager)
- {
- Menu m = ((MenuManager)manager).getMenu();
- if (m != null)
- {
- menuListenerAdded = true;
- SystemViewMenuListener ml = new SystemViewMenuListener();
- if (_messageLine != null)
- ml.setShowToolTipText(true, _messageLine);
- m.addMenuListener(ml);
- }
- }
- }
- fillContextMenu(manager);
- }
-
- public ISelection getSelection()
- {
- ISelection selection = super.getSelection();
- if (selection == null || selection.isEmpty())
- {
- // make the selection the parent
- ArrayList list = new ArrayList();
- if (_objectInput != null)
- {
- list.add(_objectInput);
- selection = new StructuredSelection(list);
- }
- }
-
- return selection;
- }
-
- public void fillContextMenu(IMenuManager menu) {
-
- IStructuredSelection selection = (IStructuredSelection) getSelection();
-
- boolean allSelectionsFromSameParent = true;
- int selectionCount = selection.size();
-
-
-
- if (selectionCount == 0) // nothing selected
- {
- return;
- }
- else
- {
-
- if (selectionCount == 1) {
-
- if (selection.getFirstElement() == getInput()) {
- //return;
- }
- }
-
- if (selectionCount > 1)
- {
- allSelectionsFromSameParent = sameParent();
-
- if (!allSelectionsFromSameParent)
- {
- if (selectionHasAncestryRelationship())
- {
- // don't show the menu because actions with
- // multiple select on objects that are ancestors
- // of each other is problematic
- // still create the standard groups
- SystemView.createStandardGroups(menu);
- return;
- }
- }
- }
-
- // Partition into groups...
- SystemView.createStandardGroups(menu);
-
- // ADD COMMON ACTIONS...
- // COMMON REFRESH ACTION...
- if (showRefresh())
- {
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_BUILD, getRefreshAction());
- }
-
- // COMMON RENAME ACTION...
- if (canRename())
- {
- if (showRename())
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_REORGANIZE, getRenameAction());
- }
-
- // ADAPTER SPECIFIC ACTIONS
- SystemMenuManager ourMenu = new SystemMenuManager(menu);
-
- Iterator elements = selection.iterator();
- Hashtable adapters = new Hashtable();
- while (elements.hasNext())
- {
- Object element = elements.next();
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (adapter != null)
- {
- adapters.put(adapter, element); // want only unique adapters
- }
- }
- Enumeration uniqueAdapters = adapters.keys();
- Shell shell = getShell();
- while (uniqueAdapters.hasMoreElements())
- {
- ISystemViewElementAdapter nextAdapter = (ISystemViewElementAdapter) uniqueAdapters.nextElement();
- nextAdapter.addActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADAPTERS);
-
- if (nextAdapter instanceof AbstractSystemViewAdapter)
- {
- AbstractSystemViewAdapter aVA = (AbstractSystemViewAdapter)nextAdapter;
- // add remote actions
- aVA.addCommonRemoteActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADAPTERS);
-
- // add dynamic menu popups
- aVA.addDynamicPopupMenuActions(ourMenu, selection, shell, ISystemContextMenuConstants.GROUP_ADDITIONS);
- }
- }
-
-
-
-
- // wail through all actions, updating shell and selection
- IContributionItem[] items = menu.getItems();
- for (int idx = 0; idx < items.length; idx++)
- {
- if ((items[idx] instanceof ActionContributionItem) && (((ActionContributionItem) items[idx]).getAction() instanceof ISystemAction))
- {
- ISystemAction item = (ISystemAction) (((ActionContributionItem) items[idx]).getAction());
- item.setInputs(getShell(), this, selection);
- }
- else if (items[idx] instanceof SystemSubMenuManager)
- {
- SystemSubMenuManager item = (SystemSubMenuManager) items[idx];
- item.setInputs(getShell(), this, selection);
- }
- }
-
- // COMMON DELETE ACTION...
- if (canDelete() && showDelete())
- {
- //menu.add(getDeleteAction());
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_REORGANIZE, getDeleteAction());
- ((ISystemAction) getDeleteAction()).setInputs(getShell(), this, selection);
- menu.add(new Separator());
- }
-
- // REMOVE FROM VIEW ACTION...
-
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_ADDITIONS, getClearSelectedAction());
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_ADDITIONS, getClearAllAction());
-
- // 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 pdAction = getPropertyDialogAction();
- if (pdAction.isApplicableForSelection())
- {
-
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_PROPERTIES, pdAction);
- }
- // OPEN IN NEW PERSPECTIVE ACTION... if (fromSystemViewPart && showOpenViewActions())
- if (!_selectionIsRemoteObject)
- {
- //SystemCascadingOpenToAction openToAction = getOpenToAction();
- SystemOpenExplorerPerspectiveAction openToPerspectiveAction = getOpenToPerspectiveAction();
- SystemShowInTableAction showInTableAction = getShowInTableAction();
- openToPerspectiveAction.setSelection(selection);
- showInTableAction.setSelection(selection);
- //menu.appendToGroup(ISystemContextMenuConstants.GROUP_OPEN, openToAction.getSubMenu());
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_OPEN, openToPerspectiveAction);
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_OPEN, showInTableAction);
-
- }
-
-
-
- }
- }
-
-
- /**
- * Decides whether to even show the refresh menu item.
- * Assumes scanSelections() has already been called
- */
- protected boolean showRefresh()
- {
- if (!_selectionFlagsUpdated)
- scanSelections();
- return _selectionShowRefreshAction;
- }
-
- /**
- * 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.
- * <p>
- * Designed to be as fast as possible by going directly to the SWT widgets
- */
- public boolean sameParent()
- {
- boolean same = true;
-
- Tree tree = getTree();
-
- TreeItem[] items = tree.getSelection();
-
- if ((items == null) || (items.length ==0)) {
- return true;
- }
-
- TreeItem prevParent = null;
- TreeItem currParent = null;
-
- for (int idx = 0; idx < items.length; idx++)
- {
- currParent = items[idx].getParentItem();
-
- if ((idx>0) && (currParent != prevParent)) {
- same = false;
- break;
- }
- else
- {
- prevParent = currParent;
- }
- }
- return same;
- }
-
- private boolean selectionHasAncestryRelationship() {
- Tree tree = getTree();
-
- TreeItem[] items = tree.getSelection();
-
- for (int idx=0; idx<items.length; idx++)
- {
- TreeItem item = items[idx];
-
- for (int c=0; c < items.length; c++)
- {
- if (item != items[c])
- {
- if (isAncestorOf(item, items[c], false))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Returns whether an item is an ancestor of another item. The ancestor can be direct or indirect.
- * @param container the item which might be an ancestor.
- * @param item the child.
- * @param direct <code>true</code> if the container must be a direct ancestor of the child item,
- * <code>false</code> otherwise.
- * @return <code>true</code> if there is an ancestry relationship, <code>false</code> otherwise.
- */
- private boolean isAncestorOf(TreeItem container, TreeItem item, boolean direct)
- {
- TreeItem[] children = null;
-
- // does not have to be a direct ancestor
- if (!direct) {
- // get the children of the container's parent, i.e. the container's siblings
- // as well as itself
- TreeItem parent = container.getParentItem();
-
- // check if parent is null
- // parent is null if the container is a root item
- if (parent != null) {
- children = parent.getItems();
- }
- else {
- children = getTree().getItems();
- }
- }
- // must be a direct ancestor
- else {
- // get the children of the container
- children = container.getItems();
- }
-
- // go through all the children
- for (int i = 0; i < children.length; i++) {
-
- TreeItem child = children[i];
-
- // if one of the children matches the child item, return true
- if (child == item && direct) {
- return true;
- }
- // otherwise, go through children, and see if any of those are ancestors of
- // the child item
- else if (child.getItemCount() > 0) {
-
- // we check for direct ancestry
- if (isAncestorOf(child, item, true)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * --------------------------------------------------------------------------------
- * For many actions we have to walk the selection list and examine each selected
- * object to decide if a given common action is supported or not.
- * <p>
- * Walking this list multiple times while building the popup menu is a performance
- * hit, so we have this common method that does it only once, setting instance
- * variables for all of the decisions we are in interested in.
- * --------------------------------------------------------------------------------
- */
- protected void scanSelections()
- {
- // initial these variables to true. Then if set to false even once, leave as false always...
- _selectionShowRefreshAction = true;
- _selectionShowOpenViewActions = true;
- _selectionShowDeleteAction = true;
- _selectionShowRenameAction = true;
- _selectionEnableDeleteAction = true;
- _selectionEnableRenameAction = true;
- _selectionIsRemoteObject = true;
- _selectionFlagsUpdated = true;
-
- IStructuredSelection selection = (IStructuredSelection) getSelection();
- Iterator elements = selection.iterator();
- while (elements.hasNext())
- {
- Object element = elements.next();
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- if (adapter != null)
- {
- if (_selectionShowRefreshAction)
- _selectionShowRefreshAction = adapter.showRefresh(element);
-
- if (_selectionShowOpenViewActions)
- _selectionShowOpenViewActions = adapter.showOpenViewActions(element);
-
- if (_selectionShowDeleteAction)
- _selectionShowDeleteAction = adapter.showDelete(element);
-
- if (_selectionShowRenameAction)
- _selectionShowRenameAction = adapter.showRename(element);
-
- if (_selectionEnableDeleteAction)
- _selectionEnableDeleteAction = _selectionShowDeleteAction && adapter.canDelete(element);
- //System.out.println("ENABLE DELETE SET TO " + selectionEnableDeleteAction);
-
- if (_selectionEnableRenameAction)
- _selectionEnableRenameAction = _selectionShowRenameAction && adapter.canRename(element);
-
- if (_selectionIsRemoteObject)
- _selectionIsRemoteObject = (getRemoteAdapter(element) != null);
- }
- }
-
- }
-
- /**
- * Overridden so that we can pass a wrapper IContextObject into the provider to get children instead
- * of the model object, itself
- */
- protected void createChildren(final Widget widget)
- {
- if (widget instanceof TreeItem)
- {
- final Item[] tis = getChildren(widget);
- if (tis != null && tis.length > 0) {
- Object data = tis[0].getData();
- if (data != null) {
- return; // children already there!
- }
- }
-
- BusyIndicator.showWhile(widget.getDisplay(), new Runnable() {
- public void run() {
- // fix for PR 1FW89L7:
- // don't complain and remove all "dummies" ...
- if (tis != null) {
- for (int i = 0; i < tis.length; i++) {
- if (tis[i].getData() != null) {
- disassociate(tis[i]);
- Assert.isTrue(tis[i].getData() == null,
- "Second or later child is non -null");//$NON-NLS-1$
-
- }
- tis[i].dispose();
- }
- }
- Object d = widget.getData();
- if (d != null)
- {
- Object parentElement = getContextObject((TreeItem)widget);
- Object[] children = getSortedChildren(parentElement);
- if (children != null)
- {
- for (int i = 0; i < children.length; i++)
- {
- createTreeItem(widget, children[i], -1);
- }
- }
- }
- }
-
- });
- }
- else
- {
- super.createChildren(widget);
- }
- }
-
-
- /**
- * Get the containing filter reference for an item
- * @param item the item to get the filter reference for
- * @return the filter reference
- */
- public ISystemFilterReference getContainingFilterReference(TreeItem item)
- {
- Object data = item.getData();
- if (data instanceof ISystemFilterReference)
- {
- return (ISystemFilterReference)data;
- }
- else
- {
- TreeItem parent = item.getParentItem();
- if (parent != null)
- {
- return getContainingFilterReference(parent);
- }
- else
- {
- Object input = getInput();
- if (input instanceof ISystemFilterReference)
- {
- return (ISystemFilterReference)input;
- }
- else
- {
- return null;
- }
- }
- }
- }
-
- /**
- * Get the containing subsystem from an item
- * @param item the item to get the subsystem for
- * @return the subsystem
- */
- public ISubSystem getContainingSubSystem(TreeItem item)
- {
- Object data = item.getData();
- if (data instanceof ISubSystem)
- {
- return (ISubSystem)data;
- }
- else
- {
- TreeItem parent = item.getParentItem();
- if (parent != null)
- {
- return getContainingSubSystem(parent);
- }
- else
- {
- Object input = getInput();
- if (input instanceof ISubSystem)
- {
- return (ISubSystem)input;
- }
- else
- {
- return null;
- }
- }
- }
- }
-
- /**
- * Get the context object from a tree item
- * @param item the item to get the context for
- * @return the context object
- */
- public IContextObject getContextObject(TreeItem item)
- {
- Object data = item.getData();
- ISystemFilterReference filterReference = getContainingFilterReference(item);
- if (filterReference != null)
- {
- return new ContextObject(data, filterReference.getSubSystem(), filterReference);
- }
- else
- {
- ISubSystem subSystem = getContainingSubSystem(item);
- if (subSystem != null)
- {
- return new ContextObject(data, subSystem);
- }
- else
- {
- return new ContextObject(data);
- }
- }
- }
-
- /**
- * Overrides the standard viewer method to get the model object from the context object
- */
- public void add(Object parentElementOrTreePath, Object[] childElements) {
- Assert.isNotNull(parentElementOrTreePath);
- assertElementsNotNull(childElements);
-
- if (parentElementOrTreePath instanceof IContextObject)
- {
- parentElementOrTreePath = ((IContextObject)parentElementOrTreePath).getModelObject();
- }
- super.add(parentElementOrTreePath, childElements);
- }
-
- /**
- * Delete all occurrences of a given remote object
- */
- protected void deleteObject(Object deleteObject)
- {
- // If deleteObject is a string find it's tree item and get it's data as thats what's
- // stored inside the SystemScratchpad
- if (deleteObject instanceof String)
- {
- Item item = findFirstRemoteItemReference((String) deleteObject,null,null);
- if (item == null)
- return;
- else
- deleteObject = item.getData();
- }
-
- // check if remoteResource is a root in Scratchpad and if so remove it
- SystemScratchpad scratchpad = SystemRegistryUI.getInstance().getSystemScratchPad();
- if (scratchpad.contains(deleteObject))
- scratchpad.removeChild(deleteObject);
-
- // find all references to the remote resource and remove them
- Widget[] widgets = findItems(deleteObject);
- for (int i = 0; i < widgets.length; i++)
- {
- if (widgets[i] instanceof TreeItem)
- {
- remove(getTreePathFromItem((TreeItem) widgets[i]));
- }
- }
-
- }
-
- /**
- * Rename a remote object.
- */
- protected void renameRemoteObject(Object renameObject, String oldElementName) {
- String[] properties = new String[1];
- properties[0] = IBasicPropertyConstants.P_TEXT;
- List matches = new Vector();
- ISubSystem subsystem = null;
- String newElementName = ""; //$NON-NLS-1$
- Object refreshObject = null;
-
- // Try to determine the new element name/subsystem to help improve performance when searching for objects
- if (renameObject instanceof String) {
- newElementName = (String) renameObject;
- } else {
- ISystemViewElementAdapter rmtAdapter = getViewAdapter(renameObject);
- if (rmtAdapter != null) {
- subsystem = rmtAdapter.getSubSystem(renameObject);
- newElementName = rmtAdapter.getName(renameObject);
- }
- }
-
- findAllRemoteItemReferences(oldElementName, renameObject, subsystem, matches);
-
- // Go through all the matches and update the properties
- for (int i = 0; i < matches.size(); i++) {
- Item item = (Item) matches.get(i);
- if (item != null && !item.isDisposed()) {
- Object data = item.getData();
-
- if (data != null) {
- ISystemRemoteElementAdapter remoteAdapter = (ISystemRemoteElementAdapter)((IAdaptable)data).getAdapter(ISystemRemoteElementAdapter.class);
-
- if (remoteAdapter != null && data != renameObject)
- {
- remoteAdapter.refreshRemoteObject(data, renameObject);
- }
- item.setText(newElementName);
- internalUpdate(item, data, properties);
-
- if (refreshObject == null) {
- refreshObject = data;
- }
-
- }
- }
- }
-
- if (refreshObject != null) {
- // Update the Scratchpad Model
- SystemRegistryUI.getInstance().getSystemScratchPad().replace(oldElementName, refreshObject);
-
- // FTP/SSH require a new listing of files otherwise they will
- // display the old file names.
- // We can't depend on SystemView to do the refresh as it does it in a
- // deferred job and we don't know when that is done or what
- // order the listeners are in.
- if (refreshObject instanceof ISystemContainer) {
- ((ISystemContainer) refreshObject).markStale(true);
- }
- internalRefresh(refreshObject);
- }
- }
-
- //TODO:
- // ----------------------------------------------------------------
- // Functions Below are pure copies of the ones from SystemView
- // and as such should be moved to a common location
- // or with 3.0 remove all need for Recursive methods - Preferred
- // ----------------------------------------------------------------
-
- /**
- * Find the first binary-match or name-match of remote object, given its absolute name.
- * @param remoteObjectName The absolute name of the remote object to find.
- * @param subsystem The subsystem of the remote object to find. Optional.
- * @param parentItem The parent item at which to start the search. Optional.
- * @return TreeItem hit if found
- */
- public Item findFirstRemoteItemReference(String remoteObjectName, ISubSystem subsystem, Item parentItem) {
- //List matches = new Vector();
- Item match = null;
- if (parentItem == null)
- //findAllRemoteItemReferences(remoteObjectName, null, subsystem, matches);
- match = internalFindFirstRemoteItemReference(remoteObjectName, null, subsystem);
- else {
-
- //recursiveFindAllRemoteItemReferences(parentItem, remoteObjectName, null, subsystem, matches);
- match = recursiveFindFirstRemoteItemReference(parentItem, remoteObjectName, null, subsystem);
- }
- //if (matches.size() > 0)
- // return (Item)matches.elementAt(0);
- //else
- // return null;
- return match;
- }
-
- /**
- * 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.
- * <p>
- * 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
- * @return TreeItem hit if found
- */
- 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);
- }
-
- return match;
- }
-
- protected Item mappedFindFirstRemoteItemReference(Object elementObject)
- {
- return (Item)findItem(elementObject);
- }
-
- /**
- * Recursively tries to find the first references to a remote object.
- * This search is restricted to the given subsystem, if given.
- * @param parent the parent item at which to start the search.
- * @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.
- */
- protected Item recursiveFindFirstRemoteItemReference(Item parent, String elementName, Object elementObject, ISubSystem subsystem) {
- Object rawData = parent.getData();
- ISystemViewElementAdapter remoteAdapter = null;
- // ----------------------------
- // what are we looking at here?
- // ----------------------------
- if (rawData != null) remoteAdapter = getViewAdapter(rawData);
- // -----------------------------------------------------------------------
- // if this is a remote object, test if it is the one we are looking for...
- // -----------------------------------------------------------------------
- if (remoteAdapter != null) {
- // first test for binary match
- if (elementObject == rawData) {
- if (debugRemote) System.out.println("Remote item binary match found"); //$NON-NLS-1$
- return parent; // return the match
- }
- // now test for absolute name match
- String fqn = remoteAdapter.getAbsoluteName(rawData);
- if (debugRemote) System.out.println("TESTING FINDFIRST: '" + fqn + "' vs '" + elementName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if ((fqn != null) && fqn.equals(elementName)) {
- if ((subsystem != null) && (subsystem == remoteAdapter.getSubSystem(rawData))) {
- if (debugRemote) System.out.println("Remote item name match found and subsystems matched"); //$NON-NLS-1$
- return parent; // return the match
- } else if (subsystem == null) {
- if (debugRemote) System.out.println("Remote item name match found and subsystem null"); //$NON-NLS-1$
- return parent;
- } else if (debugRemote) System.out.println("Remote item name match found but subsystem mismatch"); //$NON-NLS-1$
- }
- }
- // -------------------------------------------------------------------------
- // if we have been given a subsystem to restrict to, that is a hint to us...
- // -------------------------------------------------------------------------
- else if ((rawData != null) && (subsystem != null)) // test for hints we are in the wrong place
- {
- // if we are currently visiting a subsystem, and that subsystem is not from the same
- // factory, then we can assume the remote object occurrences we are looking for are
- // not to be found within this branch...
- if ((rawData instanceof ISubSystem) && (rawData != subsystem)) {
- 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
- // 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
- Item[] items = getChildren(parent);
- Item match = null;
- for (int i = 0; (match == null) && (i < items.length); i++) {
- if (!items[i].isDisposed()) match = recursiveFindFirstRemoteItemReference(items[i], elementName, elementObject, subsystem);
- }
- return match;
- }
-
- /**
- * Recursively tries to find all occurrences of a given remote object, starting at the tree root.
- * Since the object memory object for a remote object is not dependable we call getAbsoluteName()
- * on the adapter to do the comparisons.
- * <p>
- * TODO: This method should not return any invalid matches, i.e. remote objects
- * that do match the String identifier but have been deleted already. Because the
- * 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.
- * <p>
- * 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),
- * or <code>null</code> to get a new List created and returned
- * @return the List populated with hits, or <code>null</code> if
- * <code>null</code> was passed as matches to populate and no matches
- * were found.
- */
- protected List findAllRemoteItemReferences(String searchString, Object elementObject, ISubSystem subsystem, List matches) {
- Tree tree = getTree();
- Item[] roots = tree.getItems();
- if (roots == null) return matches;
- if (matches == null)
- matches = new Vector();
-
- boolean foundExact = false;
- for (int idx = 0; idx < roots.length; idx++){
- if (recursiveFindExactMatches((TreeItem)roots[idx], elementObject, subsystem, matches)){
- foundExact = true;
- }
- }
-
- if (!foundExact)
- {
- for (int idx = 0; idx < roots.length; idx++){
- matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches);
- }
- }
-
- return matches;
- }
-
- private boolean recursiveFindExactMatches(TreeItem root, Object elementObject, ISubSystem subsystem, List matches)
- {
- boolean foundSomething = false;
- Object data = root.getData();
- if (data == elementObject)
- {
- matches.add(root);
- foundSomething = true;
- }
- if (subsystem != null){
- if (data instanceof ISubSystem){
- if (data != subsystem)
- return false;
- }
- else if (data instanceof IHost){
- if (subsystem.getHost() != data)
- return false;
- }
- }
-
- TreeItem[] children = root.getItems();
- for (int i = 0; i < children.length; i++)
- {
- if (recursiveFindExactMatches(children[i], elementObject, subsystem, matches))
- {
- foundSomething = true;
- }
- }
- return foundSomething;
- }
-
- protected boolean mappedFindAllRemoteItemReferences(Object elementObject, List occurrences)
- {
- Widget[] items = findItems(elementObject);
- if (items.length > 0)
- {
- for (int i = 0; i < items.length; i++)
- {
- occurrences.add(items[i]);
- }
- 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.
- * @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
- * @param occurrences the List to populate with hits. Must not be <code>null</code>
- * @return the given List populated with hits
- */
- protected List recursiveFindAllRemoteItemReferences(Item parent, String elementName, Object elementObject, ISubSystem subsystem, List occurrences) {
- Object rawData = parent.getData();
- ISystemViewElementAdapter remoteAdapter = null;
- // ----------------------------
- // what are we looking at here?
- // ----------------------------
- if (rawData != null) remoteAdapter = getViewAdapter(rawData);
- // -----------------------------------------------------------------------
- // if this is a remote object, test if it is the one we are looking for...
- // -----------------------------------------------------------------------
- if (remoteAdapter != null) {
- // first test for binary match
- if (elementObject == rawData) {
- occurrences.add(parent); // found a match!
- if (debugRemote) System.out.println("Find All: Remote item binary match found"); //$NON-NLS-1$
- return occurrences; // no point in checking the kids
- }
- // now test for absolute name match
- String fqn = remoteAdapter.getAbsoluteName(rawData);
- if (debugRemote) System.out.println("TESTING FINDALL: '" + fqn + "' vs '" + elementName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if ((fqn != null) && fqn.equals(elementName)) {
- occurrences.add(parent); // found a match!
- if (debugRemote) System.out.println("...and remote item name match found"); //$NON-NLS-1$
- return occurrences; // no point in checking the kids
- }
- }
- // -------------------------------------------------------------------------
- // if we have been given a subsystem to restrict to, that is a hint to us...
- // -------------------------------------------------------------------------
- else if ((rawData != null) && (subsystem != null)) // test for hints we are in the wrong place
- {
- // if we are currently visiting a subsystem, and that subsystem is not from the same
- // factory, then we can assume the remote object occurrences we are looking for are
- // not to be found within this branch...
- if ((rawData instanceof ISubSystem) && (((ISubSystem) rawData).getSubSystemConfiguration() != subsystem.getSubSystemConfiguration())) {
- 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
- // 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
- 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;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadViewPart.java
deleted file mode 100644
index 452050836..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadViewPart.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Kevin Doyle (IBM) - [182403] Double Click on an object that can be expanded
- * Kevin Doyle (IBM) - [195543] Double Clicking expands wrong folder when duplicate elements shown
- * Kevin Doyle (IBM) - [193155] Double Clicking on a String in Scratchpad Errors
- * Kevin Doyle (IBM) - [194867] Remote Scratchpad should have Refresh Action on toolbar
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.scratchpad;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction;
-import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction;
-import org.eclipse.rse.ui.actions.SystemRefreshAction;
-import org.eclipse.rse.ui.internal.model.SystemRegistryUI;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.IRSEViewPart;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.ui.part.ViewPart;
-
-
-/**
- * This class is the Remote Scratchpad view.
- */
-public class SystemScratchpadViewPart extends ViewPart
- implements ISelectionListener, ISelectionChangedListener,
- ISystemResourceChangeListener, ISystemShellProvider,
- ISystemMessageLine, IRSEViewPart
-{
-
-
- private SystemScratchpadView _viewer;
-
- // common actions
- private SystemCopyToClipboardAction _copyAction;
- private SystemPasteFromClipboardAction _pasteAction;
- private SystemCommonDeleteAction _deleteAction;
- private SystemCommonRenameAction _renameAction;
- private ClearAction _clearAction;
- private ClearSelectedAction _clearSelectionAction;
- private SystemRefreshAction _refreshAction;
-
- // for ISystemMessageLine
- private String _message, _errorMessage;
- private SystemMessage sysErrorMessage;
- private IStatusLineManager _statusLine = null;
-
- // constants
- public static final String ID = "org.eclipse.rse.ui.view.scratchpad.SystemScratchpadViewPart"; // matches id in plugin.xml, view tag //$NON-NLS-1$
-
- public void setFocus()
- {
- _viewer.getControl().setFocus();
- }
-
- public SystemScratchpadView getViewer()
- {
- return _viewer;
- }
-
- public Viewer getRSEViewer()
- {
- return _viewer;
- }
-
- public void createPartControl(Composite parent)
- {
- Tree tree = new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
-
- _viewer = new SystemScratchpadView(tree, this);
-
- ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService();
- selectionService.addSelectionListener(this);
- _viewer.addSelectionChangedListener(this);
- getSite().setSelectionProvider(_viewer);
-
- _viewer.addDoubleClickListener(new IDoubleClickListener()
- {
- public void doubleClick(DoubleClickEvent event)
- {
- handleDoubleClick(event);
- }
- });
-
- fillLocalToolBar();
-
- // register global edit actions
- ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
- Clipboard clipboard = RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard();
-
- CellEditorActionHandler editorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
-
- _copyAction = new SystemCopyToClipboardAction(_viewer.getShell(), clipboard);
- _pasteAction = new SystemPasteFromClipboardAction(_viewer.getShell(), clipboard);
- _deleteAction = new SystemCommonDeleteAction(_viewer.getShell(), _viewer);
- _renameAction = new SystemCommonRenameAction(_viewer.getShell(), _viewer);
-
- // register rename action as a global handler
- getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.RENAME.getId(), _renameAction);
-
- editorActionHandler.setCopyAction(_copyAction);
- editorActionHandler.setPasteAction(_pasteAction);
- editorActionHandler.setDeleteAction(_deleteAction);
- //editorActionHandler.setSelectAllAction(new SelectAllAction());
-
- registry.addSystemResourceChangeListener(this);
-
- SystemWidgetHelpers.setHelp(_viewer.getControl(), RSEUIPlugin.HELPPREFIX + "scrp0000"); //$NON-NLS-1$
-
- setInput(SystemRegistryUI.getInstance().getSystemScratchPad());
-
- getSite().registerContextMenu(_viewer.getContextMenuManager(), _viewer);
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection sel)
- {
- }
-
- public void dispose()
- {
- ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService();
- selectionService.removeSelectionListener(this);
- _viewer.removeSelectionChangedListener(this);
-
- RSECorePlugin.getTheSystemRegistry().removeSystemResourceChangeListener(this);
-
- if (_viewer != null)
- {
- _viewer.dispose();
- }
-
- super.dispose();
- }
-
- private void handleDoubleClick(DoubleClickEvent event)
- {
- ITreeSelection s = (ITreeSelection) event.getSelection();
- Object element = s.getFirstElement();
-
- if (element == null || !(element instanceof IAdaptable))
- return;
-
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) element).getAdapter(ISystemViewElementAdapter.class);
-
- if (adapter != null)
- {
- if (adapter.hasChildren((IAdaptable)element))
- {
- // Get the path for the element and use it for setting expanded state,
- // so the proper TreeItem is expanded/collapsed
- TreePath[] paths = s.getPathsFor(element);
- if (paths == null || paths.length == 0 || paths[0] == null) return;
- TreePath elementPath = paths[0];
- if (_viewer.getExpandedState(elementPath))
- {
- _viewer.collapseToLevel(elementPath, 1);
- }
- else
- {
- _viewer.expandToLevel(elementPath, 1);
- }
- }
- else
- {
- adapter.handleDoubleClick(element);
- }
- }
- }
-
- public void updateActionStates()
- {
- if (_clearAction == null)
- fillLocalToolBar();
-
- _clearAction.checkEnabledState();
- _clearSelectionAction.checkEnabledState();
- }
-
- public void fillLocalToolBar()
- {
- IActionBars actionBars = getViewSite().getActionBars();
- IToolBarManager toolBarManager = actionBars.getToolBarManager();
- IMenuManager menuMgr = actionBars.getMenuManager();
-
- if (_clearAction == null) {
- _clearAction = new ClearAction(_viewer);
- _clearSelectionAction = new ClearSelectedAction(_viewer);
- }
-
- if (_refreshAction == null) {
- _refreshAction = new SystemRefreshAction(getShell());
- _refreshAction.setId(ActionFactory.REFRESH.getId());
- _refreshAction.setActionDefinitionId("org.eclipse.ui.file.refresh"); //$NON-NLS-1$
- _refreshAction.setSelectionProvider(_viewer);
- }
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), _refreshAction);
-
- updateActionStates();
-
- _statusLine = actionBars.getStatusLineManager();
-
- addToolBarItems(toolBarManager);
- addToolBarMenuItems(menuMgr);
- }
-
- private void addToolBarMenuItems(IMenuManager menuManager)
- {
- menuManager.removeAll();
- menuManager.add(_refreshAction);
- menuManager.add(new Separator());
- menuManager.add(_clearSelectionAction);
- menuManager.add(_clearAction);
- }
-
- private void addToolBarItems(IToolBarManager toolBarManager)
- {
- toolBarManager.removeAll();
- toolBarManager.add(_refreshAction);
- toolBarManager.add(new Separator());
- toolBarManager.add(_clearSelectionAction);
- toolBarManager.add(_clearAction);
- }
-
- public void selectionChanged(SelectionChangedEvent e)
- {
- // listener for this view
- updateActionStates();
-
- IStructuredSelection sel = (IStructuredSelection) e.getSelection();
- _copyAction.setEnabled(_copyAction.updateSelection(sel));
- _pasteAction.setEnabled(_pasteAction.updateSelection(sel));
- _deleteAction.setEnabled(_deleteAction.updateSelection(sel));
- }
-
- public void setInput(IAdaptable object)
- {
- setInput(object, null);
-
- }
-
- public void setInput(IAdaptable object, String[] filters)
- {
- if (_viewer != null && object != null)
- {
- _viewer.setInput(object);
-
- updateActionStates();
-
- }
- }
-
- /**
- * Used to asynchronously update the view whenever properties change.
- */
- public void systemResourceChanged(ISystemResourceChangeEvent event)
- {
- Object parent = event.getParent();
-
- if (event.getType() == ISystemResourceChangeEvents.EVENT_RENAME)
- {
- }
-
- if (parent == _viewer.getInput())
- {
- updateActionStates();
- }
- }
-
- public Shell getShell()
- {
- return _viewer.getShell();
- }
-
-
-// -------------------------------
- // ISystemMessageLine interface...
- // -------------------------------
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage()
- {
- _errorMessage = null;
- sysErrorMessage = null;
- if (_statusLine != null)
- _statusLine.setErrorMessage(_errorMessage);
- }
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage()
- {
- _message = null;
- if (_statusLine != null)
- _statusLine.setMessage(_message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage()
- {
- return _errorMessage;
- }
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null<code> is returned.
- */
- public String getMessage()
- {
- return _message;
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message)
- {
- this._errorMessage = message;
- if (_statusLine != null)
- _statusLine.setErrorMessage(message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public SystemMessage getSystemErrorMessage()
- {
- return sysErrorMessage;
- }
-
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(SystemMessage message)
- {
- sysErrorMessage = message;
- setErrorMessage(message.getLevelOneText());
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(Throwable exc)
- {
- setErrorMessage(exc.getMessage());
- }
-
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message)
- {
- this._message = message;
- if (_statusLine != null)
- _statusLine.setMessage(message);
- }
- /**
- *If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(SystemMessage message)
- {
- setMessage(message.getLevelOneText());
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadViewProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadViewProvider.java
deleted file mode 100644
index c1fc1bcf1..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/scratchpad/SystemScratchpadViewProvider.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.scratchpad;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-
-/**
- * This is the content and label provider for the SystemScratchpadView.
- * This class is used both to populate the SystemScratchpadView but also
- * to resolve the icon and labels for the cells in the table/tree.
- *
- */
-public class SystemScratchpadViewProvider implements ILabelProvider, ITreeContentProvider
-{
-
-
- private ListenerList listeners = new ListenerList(1);
-
-
- /**
- * The cache of images that have been dispensed by this provider.
- * Maps ImageDescriptor->Image.
- */
- private Map imageTable = new Hashtable(40);
- private SystemScratchpadView _view;
-
- public SystemScratchpadViewProvider(SystemScratchpadView view)
- {
- super();
- _view = view;
- }
-
- public void inputChanged(Viewer visualPart, Object oldInput, Object newInput)
- {
- }
-
-
-
- public boolean isDeleted(Object element)
- {
- return false;
- }
-
- public Object[] getChildren(Object object)
- {
- return getElements(object);
- }
-
- public Object getParent(Object object)
- {
- return getAdapterFor(object).getParent(object);
- }
-
- public boolean hasChildren(Object object)
- {
-
- ISystemViewElementAdapter adapter = getAdapterFor(object);
- if (adapter != null)
- {
- if (object instanceof IContextObject)
- {
- return adapter.hasChildren((IContextObject)object);
- }
- else
- {
- return adapter.hasChildren((IAdaptable)object);
- }
- }
- else if (object instanceof IAdaptable)
- {
- IWorkbenchAdapter wa = (IWorkbenchAdapter)((IAdaptable)object).getAdapter(IWorkbenchAdapter.class);
- if (wa != null)
- return wa.getChildren(object).length > 0;
- }
- return false;
- }
-
- public Object getElementAt(Object object, int i)
- {
-
- return null;
- }
-
- protected ISystemViewElementAdapter getAdapterFor(Object object)
- {
- if (object instanceof IContextObject)
- {
- object = ((IContextObject)object).getModelObject();
- }
- if (object instanceof IAdaptable)
- {
- IAdaptable adapt = (IAdaptable) object;
- ISystemViewElementAdapter result = (ISystemViewElementAdapter) adapt.getAdapter(ISystemViewElementAdapter.class);
- if (result != null)
- {
- result.setPropertySourceInput(object);
- result.setViewer(_view);
- return result;
- }
- }
- return null;
- }
-
- public Object[] getElements(Object object)
- {
- Object[] results = null;
-
- Object element = object;
- if (object instanceof IContextObject)
- {
- element = ((IContextObject)object).getModelObject();
- }
- if (element instanceof IAdaptable)
- {
- ISystemViewElementAdapter adapter = getAdapterFor(element);
- if (adapter != null && adapter.hasChildren((IAdaptable)element))
- {
- if (object instanceof IContextObject)
- {
- results = adapter.getChildren((IContextObject)object, new NullProgressMonitor());
- }
- else
- {
- results = adapter.getChildren((IAdaptable)object, new NullProgressMonitor());
- }
- }
- else
- {
- IWorkbenchAdapter wa = (IWorkbenchAdapter)((IAdaptable)object).getAdapter(IWorkbenchAdapter.class);
- if (wa != null)
- return wa.getChildren(object);
- }
- }
- if (results == null)
- {
- return new Object[0];
- }
-
- return results;
- }
-
- public String getText(Object object)
- {
- if (object instanceof String)
- {
- return (String)object;
- }
- ISystemViewElementAdapter adapter = getAdapterFor(object);
- if (adapter != null)
- {
- return adapter.getText(object);
- }
- else if (object instanceof IAdaptable)
- {
- IWorkbenchAdapter wa = (IWorkbenchAdapter)((IAdaptable)object).getAdapter(IWorkbenchAdapter.class);
- if (wa != null)
- {
- return wa.getLabel(object);
- }
- }
- return object.toString();
- }
-
- public Image getImage(Object object)
- {
- Image image = null;
- if (object instanceof String)
- {
- return null;
- }
- ISystemViewElementAdapter adapter = getAdapterFor(object);
- if (adapter != null)
- {
- ImageDescriptor descriptor = adapter.getImageDescriptor(object);
-
-
- if (descriptor != null)
- {
- Object iobj = imageTable.get(descriptor);
- if (iobj == null)
- {
- image = descriptor.createImage();
- imageTable.put(descriptor, image);
- }
- else
- {
- image = (Image) iobj;
- }
- }
- return image;
- }
- else if (object instanceof IAdaptable)
- {
- IWorkbenchAdapter wa = (IWorkbenchAdapter)((IAdaptable)object).getAdapter(IWorkbenchAdapter.class);
- if (wa != null)
- {
- ImageDescriptor descriptor = wa.getImageDescriptor(object);
- if (descriptor != null)
- {
- Object iobj = imageTable.get(descriptor);
- if (iobj == null)
- {
- image = descriptor.createImage();
- imageTable.put(descriptor, image);
- }
- else
- {
- image = (Image) iobj;
- }
- }
- return image;
- }
- }
- return null;
- }
-
-
- public void addListener(ILabelProviderListener listener)
- {
- listeners.add(listener);
- }
-
- public boolean isLabelProperty(Object element, String property)
- {
- return true;
- }
-
- public void removeListener(ILabelProviderListener listener)
- {
- listeners.remove(listener);
- }
-
- public void dispose()
- {
- // TODO Auto-generated method stub
-
- }
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchClearHistoryAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchClearHistoryAction.java
deleted file mode 100644
index 2377e924c..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchClearHistoryAction.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.actions.SystemBaseAction;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * This action clears the history in the Remote Search view.
- */
-public class SystemSearchClearHistoryAction extends SystemBaseAction {
-
- private SystemSearchViewPart searchView;
-
- /**
- * Constructor for action.
- * @param searchView the remote search view.
- * @param shell the shell.
- */
- public SystemSearchClearHistoryAction(SystemSearchViewPart searchView, Shell shell) {
- super(SystemResources.RESID_SEARCH_CLEAR_HISTORY_LABEL,SystemResources.RESID_SEARCH_CLEAR_HISTORY_TOOLTIP,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SEARCH_CLEAR_HISTORY_ID), shell);
-
- this.searchView = searchView;
- RSEUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, RSEUIPlugin.HELPPREFIX + "search_clear_history"); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- searchView.deleteAllPages();
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchCopyToClipboardAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchCopyToClipboardAction.java
deleted file mode 100644
index d1af839ff..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchCopyToClipboardAction.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * Action that copies objects selected in Remote Search view to clipboard.
- */
-public class SystemSearchCopyToClipboardAction extends SystemCopyToClipboardAction {
-
- /**
- * Constructor.
- * @param shell the shell.
- * @param clipboard the system clipboard.
- */
- public SystemSearchCopyToClipboardAction(Shell shell, Clipboard clipboard) {
- super(shell, clipboard);
- }
-
- /**
- * Returns the string "\t" if the object is a remote search result, otherwise returns the super class
- * implementation.
- * @see org.eclipse.rse.ui.actions.SystemCopyToClipboardAction#getTextTransferPrepend(java.lang.Object, org.eclipse.rse.ui.view.ISystemViewElementAdapter)
- */
- protected String getTextTransferPrepend(Object obj, ISystemViewElementAdapter adapter) {
- /** shouldn't be coupled with search (files ui)
- if (adapter instanceof SystemViewRemoteSearchResultAdapter)
- {
- return "\t";
- }
- else
- **/
- {
- return super.getTextTransferPrepend(obj, adapter);
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchHistoryAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchHistoryAction.java
deleted file mode 100644
index 9f22ce89e..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchHistoryAction.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.rse.ui.RSEUIPlugin;
-
-/**
- * This is the history action for the remote system search view.
- */
-public class SystemSearchHistoryAction extends Action {
-
-
-
- private SystemSearchViewPart searchView;
- private int index;
-
- /**
- * Constructor for SystemSearchHistoryAction.
- * @param text the text for the action.
- * @param image the image.
- * @param searchView the search view.
- * @param index the index in the history.
- */
- public SystemSearchHistoryAction(String text, ImageDescriptor image, SystemSearchViewPart searchView, int index) {
- super(text, image);
- setToolTipText(text);
- this.searchView = searchView;
- this.index = index;
- RSEUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, RSEUIPlugin.HELPPREFIX + "search_history"); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- searchView.showSearchResult(index);
- }
-
- /**
- * Sets the text and the tooltip.
- * @see org.eclipse.jface.action.IAction#setText(java.lang.String)
- */
- public void setText(String text) {
- super.setText(text);
- setToolTipText(text);
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchRemoveAllMatchesAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchRemoveAllMatchesAction.java
deleted file mode 100644
index d103744c7..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchRemoveAllMatchesAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.actions.SystemBaseAction;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * This action removes all matches from the Remote Search view.
- */
-public class SystemSearchRemoveAllMatchesAction extends SystemBaseAction {
-
- private SystemSearchViewPart searchView;
-
- /**
- * Constructor for action.
- * @param searchView the remote search view.
- * @param shell the shell.
- */
- public SystemSearchRemoveAllMatchesAction(SystemSearchViewPart searchView, Shell shell) {
- super(SystemResources.RESID_SEARCH_REMOVE_ALL_MATCHES_LABEL,SystemResources.RESID_SEARCH_REMOVE_ALL_MATCHES_TOOLTIP,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SEARCH_REMOVE_ALL_MATCHES_ID),
- shell);
-
- this.searchView = searchView;
- RSEUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, RSEUIPlugin.HELPPREFIX + "search_remove_all"); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- searchView.deleteCurrentPage();
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchRemoveSelectedMatchesAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchRemoveSelectedMatchesAction.java
deleted file mode 100644
index 6edb8c691..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchRemoveSelectedMatchesAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.actions.SystemBaseAction;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * This action removes selected matches from the Remote Search view.
- */
-public class SystemSearchRemoveSelectedMatchesAction extends SystemBaseAction {
-
- private SystemSearchViewPart searchView;
-
- /**
- * Constructor for action.
- * @param searchView the remote search view.
- * @param shell the shell.
- */
- public SystemSearchRemoveSelectedMatchesAction(SystemSearchViewPart searchView, Shell shell) {
- super(SystemResources.RESID_SEARCH_REMOVE_SELECTED_MATCHES_LABEL,SystemResources.RESID_SEARCH_REMOVE_SELECTED_MATCHES_TOOLTIP,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SEARCH_REMOVE_SELECTED_MATCHES_ID),
- shell);
-
- this.searchView = searchView;
- RSEUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, RSEUIPlugin.HELPPREFIX + "search_remove_selected"); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- searchView.deleteSelected();
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchTableView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchTableView.java
deleted file mode 100644
index 5c319d7d3..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchTableView.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Kevin Doyle (IBM) - [192725] Deleting Files doesn't remove them from Search view
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvent;
-import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-import org.eclipse.rse.internal.ui.view.SystemDecoratingLabelProvider;
-import org.eclipse.rse.internal.ui.view.SystemTableTreeView;
-import org.eclipse.rse.internal.ui.view.SystemTableTreeViewProvider;
-import org.eclipse.rse.services.search.IHostSearchResultConfiguration;
-import org.eclipse.rse.services.search.IHostSearchResultSet;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.Widget;
-
-
-public class SystemSearchTableView extends SystemTableTreeView
-{
-
-
- private boolean _firstRefresh = true;
- private IHostSearchResultSet resultSet;
-
- public SystemSearchTableView(Tree tabletree, IHostSearchResultSet resultSet, ISystemMessageLine msgLine)
- {
- super(tabletree, msgLine);
- this.resultSet = resultSet;
-
- _provider.disableDeferredQueries(true);
- setLabelProvider(new SystemDecoratingLabelProvider(_provider, RSEUIPlugin.getDefault().getWorkbench().getDecoratorManager().getLabelDecorator()));
- }
-
- public IHostSearchResultSet getResultSet() {
- return resultSet;
- }
-
-
- public void systemRemoteResourceChanged(ISystemRemoteChangeEvent event)
- {
- int eventType = event.getEventType();
-
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider)getContentProvider();
-
- IHostSearchResultSet resultSet = null;
-
- if (getInput() instanceof IHostSearchResultSet) {
- resultSet = (IHostSearchResultSet)getInput();
- }
-
- if (resultSet == null) {
- return;
- }
-
- switch (eventType)
- {
- // --------------------------
- // REMOTE RESOURCE DELETED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED :
- {
- {
- Object remoteResource = event.getResource();
- List remoteResourceNames = null;
-
- if (remoteResource instanceof List)
- {
- remoteResourceNames = (List) remoteResource;
- remoteResource = remoteResourceNames.get(0);
- }
- else
- {
- remoteResourceNames = new Vector();
- remoteResourceNames.add(remoteResource);
- }
-
- for (int d = 0; d < remoteResourceNames.size(); d++)
- {
- Object dchild = remoteResourceNames.get(d);
-
- ISystemViewElementAdapter dadapt = getViewAdapter(dchild);
- ISubSystem dSubSystem = dadapt.getSubSystem(dchild);
- String dkey = dadapt.getAbsoluteName(dchild);
-
- // this will use cache if there is one already
- // note: do not call provider.getCache() since the
- // cache is changed if getChildren() is called with
- // an object other than the input (so if we expand
- // a tree node then the cache will be the children
- // of that node, and not the root nodes of the tree)
- Object[] children = provider.getChildren(resultSet);
-
- for (int i = 0; i < children.length; i++)
- {
- Object existingChild = children[i];
-
- if (existingChild != null)
- {
- ISystemViewElementAdapter eadapt = getViewAdapter(existingChild);
- ISubSystem eSubSystem = eadapt.getSubSystem(existingChild);
-
- if (dSubSystem == eSubSystem)
- {
- String ekey = eadapt.getAbsoluteName(existingChild);
-
- boolean matches = false;
-
- // to compare absolute paths, check whether the system
- // is case sensitive or not
- if (dSubSystem.getSubSystemConfiguration().isCaseSensitive()) {
- matches = ekey.equals(dkey);
- }
- else {
- matches = ekey.equalsIgnoreCase(dkey);
- }
-
- if (matches)
- {
- resultSet.removeResult(existingChild);
- provider.setCache(resultSet.getAllResults());
- remove(existingChild);
- }
- }
- }
- }
-
- // If the deleted object is part of an archive it might be
- // visible in the search view, but not part of the result set
- Widget widget = findItem(dchild);
- if (widget != null)
- {
- Object data = widget.getData();
- remove(data);
- }
- }
- }
-
- }
- break;
-
- // --------------------------
- // REMOTE RESOURCE RENAMED...
- // --------------------------
- case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED :
- {
- Object resource = event.getResource();
- // String resourceOldPath = event.getOldName();
-
- /** FIXME - IREmoteFile is systems.core independent now
- // we only care about remote file renames
- if (resource instanceof IRemoteFile) {
-
- ISystemRemoteElementAdapter adapter = getRemoteAdapter(resource);
- resourceSubSystem = adapter.getSubSystem(resource);
-
- if (resourceSubSystem == null) {
- return;
- }
- }
- else
- {
- return;
- }
- */
- if (true) // DKM - hack to avoid this
- return;
- if (provider != null)
- {
- // this will use cache if there is one already
- // note: do not call provider.getCache() since the
- // cache is changed if getChildren() is called with
- // an object other than the input (so if we expand
- // a tree node then the cache will be the children
- // of that node, and not the root nodes of the tree)
- Object[] children = provider.getChildren(resultSet);
-
- for (int i = 0; i < children.length; i++)
- {
- Object child = children[i];
-
- // found same object. This means:
- // a) rename happened in this view, or
- // b) we are using the same object to populate this view
- // and another view, and the rename happened in the
- // other view
- if (child == resource)
- {
- Widget widget = findItem(child);
-
- if (widget != null)
- {
- update(child, null);
- return;
- }
- }
-
- /** FIXME - IREmoteFile is systems.core independent now
- // did not find object
- // rename happened in another view and we are not populating
- // this view and the other view with the same object
- else if (child instanceof IRemoteFile)
- {
- ISystemRemoteElementAdapter adapt = getRemoteAdapter(child);
- ISubSystem childSubSystem = adapt.getSubSystem(child);
-
- // check if both are from the same subsystem
- if (childSubSystem == resourceSubSystem) {
-
- String childPath = adapt.getAbsoluteName(child);
-
- // find out if system is case sensitive
- boolean isCaseSensitive = resourceSubSystem.getParentSubSystemConfiguration().isCaseSensitive();
-
- boolean matches = false;
-
- // look for the child whose path matches the old path of the resource
- if (isCaseSensitive) {
- matches = childPath.equals(resourceOldPath);
- }
- else {
- matches = childPath.equalsIgnoreCase(resourceOldPath);
- }
-
- // if paths match, update the object and then update the view
- if (matches) {
-
-
-
- // now update label for child
- Widget widget = findItem(child);
-
- if (widget != null) {
- update(child, null);
- return;
- }
- }
- }
- }*/
-
- }
- }
- break;
- }
- default :
- super.systemRemoteResourceChanged(event);
- break;
- }
- }
-
- protected void doUpdateItem(Widget widget, Object element, boolean flag)
- {
- if (_firstRefresh)
- {
- computeLayout(true);
- _firstRefresh = false;
- }
-
- super.doUpdateItem(widget, element, flag);
- }
-
- public void systemResourceChanged(ISystemResourceChangeEvent event) {
- Object actualSource = event.getSource();
-
- switch (event.getType()) {
-
- case ISystemResourceChangeEvents.EVENT_REFRESH :
-
- if (actualSource == null) {
- return;
- }
-
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider)getContentProvider();
-
- if (provider == null) {
- return;
- }
-
- if (actualSource instanceof IHostSearchResultConfiguration) {
-
- IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)actualSource;
- IHostSearchResultSet resultSet = config.getParentResultSet();
-
- if (resultSet == getInput()) {
- // this will use cache if there is one already
- // note: do not call provider.getCache() since the
- // cache is changed if getChildren() is called with
- // an object other than the input (so if we expand
- // a tree node then the cache will be the children
- // of that node, and not the root nodes of the tree)
- Object[] previousResults = provider.getCachedObjects(resultSet);
- Object[] newResults = resultSet.getAllResults();
-
- int newSize = newResults.length;
-
- // merge items so only one creation
- if ((previousResults == null || previousResults.length == 0) && newResults.length != 0) {
- provider.flushCache();
- refresh(getInput());
-
- }
- else if (previousResults != null) {
-
- int deltaSize = newSize - previousResults.length;
-
- if (deltaSize > 0) {
-
- Object[] delta = new Object[deltaSize];
- int d = 0;
-
- for (int i = 0; i < newSize; i++) {
- Object nobj = newResults[i];
-
- if (previousResults.length > i) {
- Object pobj = previousResults[i];
-
- if (pobj == null) {
- delta[d] = nobj;
- d++;
- }
- }
- else {
- delta[d] = nobj;
- d++;
- }
- }
-
- // must set the cache before calling add()
- provider.setCache(newResults);
-
- // set the cached objects
- provider.setCachedObjects(resultSet, newResults);
-
- if (delta.length > 2000) {
- internalRefresh(getInput());
- }
- else {
- add(getInput(), delta);
- }
- }
- }
- }
- }
-
- break;
-
- default :
- super.systemResourceChanged(event);
- break;
- }
- }
-
- protected Object getParentForContent(Object element)
- {
- return getViewAdapter(element).getParent(element);
- }
-
-
- /**
- * Does nothing.
- * @see org.eclipse.rse.internal.ui.view.SystemTableTreeView#handleKeyPressed(org.eclipse.swt.events.KeyEvent)
- */
- protected void handleKeyPressed(KeyEvent event) {
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchTableViewProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchTableViewProvider.java
deleted file mode 100644
index 6b70eda66..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchTableViewProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.rse.internal.ui.view.SystemTableTreeViewProvider;
-import org.eclipse.rse.internal.ui.view.SystemTableViewColumnManager;
-
-public class SystemSearchTableViewProvider extends SystemTableTreeViewProvider
-{
-
- public SystemSearchTableViewProvider(SystemTableViewColumnManager columnManager)
- {
- super(columnManager);
- }
-
- public String getText(Object object)
- {
- String text = getAdapterFor(object).getName(object);
- /** FIXME - IREmoteFile is systems.core independent now
- if (object instanceof IRemoteFile) {
- IRemoteFile parent = ((IRemoteFile)object).getParentRemoteFile();
- String absolutePath = getAdapterFor(parent).getAbsoluteName(parent);
- return text + " - " + absolutePath;
- }
- else {
- return text;
- }
- */
- return text;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchUI.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchUI.java
deleted file mode 100644
index 31f9bd1e6..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchUI.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.ui.PartInitException;
-
-
-/**
- * A singleton class for dealing with Remote Search view
- */
-public class SystemSearchUI {
-
-
-
- // singleton instance
- private static SystemSearchUI instance;
-
- // search view id
- public static final String SEARCH_RESULT_VIEW_ID = "org.eclipse.rse.ui.view.SystemSearchView"; //$NON-NLS-1$
-
- /**
- * Constructor for SystemSearchUI.
- */
- private SystemSearchUI() {
- super();
- }
-
- /**
- * Get the singleton instance.
- * @return the singleton object of this type
- */
- public static SystemSearchUI getInstance() {
-
- if (instance == null) {
- instance = new SystemSearchUI();
- }
-
- return instance;
- }
-
- /**
- * Activate search result view.
- * @return <code>true</code> if successful, <code>false</false> otherwise
- */
- public SystemSearchViewPart activateSearchResultView() {
-
- SystemSearchViewPart searchView = null;
-
- try {
- searchView = (SystemSearchViewPart)(SystemBasePlugin.getActiveWorkbenchWindow().getActivePage().showView(SystemSearchUI.SEARCH_RESULT_VIEW_ID));
- }
- catch (PartInitException e) {
- SystemBasePlugin.logError("Can not open search result view", e); //$NON-NLS-1$
- }
-
- return searchView;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewContentProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewContentProvider.java
deleted file mode 100644
index eb3485087..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewContentProvider.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.ui.part.ViewPart;
-
-
-/**
- * This class is the content provider for the remote systems search viewer.
- */
-public class SystemSearchViewContentProvider implements ITreeContentProvider {
-
-
- private ViewPart viewPart;
-
- /**
- * Constructor for SystemSearchViewContentProvider.
- */
- public SystemSearchViewContentProvider() {
- super();
- }
-
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parentElement) {
-
- if (parentElement == null) {
- return null;
- }
-
- if (parentElement instanceof IAdaptable) {
- ISystemViewElementAdapter adapter = getViewAdapter(parentElement);
-
- if (adapter == null) {
- return null;
- }
- else {
- return adapter.getChildren((IAdaptable)parentElement, new NullProgressMonitor());
- }
- }
-
- return null;
- }
-
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element) {
-
- if (element == null) {
- return null;
- }
-
- if (element instanceof IAdaptable) {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
-
- if (adapter == null) {
- return null;
- }
- else {
- return adapter.getParent(element);
- }
- }
-
- return null;
- }
-
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element) {
-
- if (element == null) {
- return false;
- }
-
- if (element instanceof IAdaptable) {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
-
- if (adapter == null) {
- return false;
- }
- else {
- return adapter.hasChildren((IAdaptable)element);
- }
- }
-
- return false;
- }
-
- /**
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement) {
-
- if (inputElement == null) {
- return null;
- }
-
- if (inputElement instanceof IAdaptable) {
- ISystemViewElementAdapter adapter = getViewAdapter(inputElement);
-
- if (adapter == null) {
- return null;
- }
- else {
- return adapter.getChildren((IAdaptable)inputElement, new NullProgressMonitor());
- }
- }
-
- return null;
- }
-
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- if (newInput == null) {
- return;
- }
-
- if (newInput instanceof IAdaptable) {
- ISystemViewElementAdapter adapter = getViewAdapter(newInput);
-
- if (adapter != null) {
- viewer.refresh();
- }
- }
- }
-
- /**
- * Get the adapter for the given object.
- * @param the object
- * @return the adapter
- */
- public ISystemViewElementAdapter getViewAdapter(Object element)
- {
- return SystemAdapterHelpers.getViewAdapter(element);
- }
- /**
- * Set the ViewPart of this provider
- * @param ViewPart of this provider
- */
- public void setViewPart(ViewPart viewPart)
- {
- this.viewPart = viewPart;
- }
- /**
- * Get the ViewPart of this provider
- * @return ViewPart of this provider
- */
- public ViewPart getViewPart()
- {
- return viewPart;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewLabelProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewLabelProvider.java
deleted file mode 100644
index 470ce1792..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewLabelProvider.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.graphics.Image;
-
-
-/**
- * This is the label provider for the remote systems search view.
- */
-public class SystemSearchViewLabelProvider extends LabelProvider {
-
-
-
- /**
- * Constructor for SystemSearchViewLabelProvider.
- */
- public SystemSearchViewLabelProvider() {
- super();
- }
-
- /**
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(Object)
- */
- public Image getImage(Object element) {
-
- if (element == null) {
- return null;
- }
-
- if (element instanceof IAdaptable) {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
-
- if (adapter != null) {
- ImageDescriptor descriptor = adapter.getImageDescriptor(element);
-
- if (descriptor != null) {
- return descriptor.createImage();
- }
- }
- }
-
- return null;
- }
-
- /**
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
- */
- public String getText(Object element) {
-
- if (element == null) {
- return null;
- }
-
- if (element instanceof IAdaptable) {
- ISystemViewElementAdapter adapter = getViewAdapter(element);
-
- if (adapter != null) {
- return adapter.getText(element);
- }
- }
-
- return null;
- }
-
- /**
- * Get the adapter for the given object.
- * @param the object
- * @return the adapter
- */
- public ISystemViewElementAdapter getViewAdapter(Object element)
- {
- return SystemAdapterHelpers.getViewAdapter(element);
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewPart.java
deleted file mode 100644
index 3d4d57dca..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/search/SystemSearchViewPart.java
+++ /dev/null
@@ -1,1278 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.search;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.view.SystemTableTreeViewProvider;
-import org.eclipse.rse.internal.ui.view.SystemView;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.services.search.IHostSearchResultConfiguration;
-import org.eclipse.rse.services.search.IHostSearchResultSet;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.IRSEViewPart;
-import org.eclipse.rse.ui.view.ISystemRemoveElementAdapter;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.CellEditorActionHandler;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * This class defines the Remote Search view.
- */
-public class SystemSearchViewPart extends ViewPart
- implements ISystemResourceChangeListener, ISystemShellProvider,
- IMenuListener, ISelectionChangedListener,
- ISystemMessageLine, IRSEViewPart
-{
- private PageBook pageBook;
- private StructuredViewer currentViewer;
-
- private IActionBars actionBars;
- private IMenuManager mMgr;
- private IToolBarManager tbMgr;
- //private IStatusLineManager slMgr;
-
- private static final String MENU_HISTORY_GROUP_NAME = "historyGroup"; //$NON-NLS-1$
- private static final String MENU_CLEAR_HISTORY_GROUP_NAME = "clearHistoryGroup"; //$NON-NLS-1$
-
- private ArrayList viewers = new ArrayList();
- private ArrayList historyActions = new ArrayList();
-
- private CancelAction cancelAction;
- private SystemSearchClearHistoryAction clearHistoryAction;
- private SystemSearchRemoveSelectedMatchesAction removeSelectedAction;
- private SystemSearchRemoveAllMatchesAction removeAllAction;
-
- private SystemSearchCopyToClipboardAction copyAction;
- private SystemPasteFromClipboardAction pasteAction;
-
- // for ISystemMessageLine
- private String _message, _errorMessage;
- private SystemMessage sysErrorMessage;
- private IStatusLineManager _statusLine = null;
-
-
- /**
- * Double click listener.
- */
- public class SystemSearchDoubleClickListener implements IDoubleClickListener {
-
- /**
- * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(DoubleClickEvent)
- */
- public void doubleClick(DoubleClickEvent event) {
- IStructuredSelection selection = (IStructuredSelection) (event.getSelection());
-
- if (!selection.isEmpty()) {
- Object element = selection.getFirstElement();
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- adapter.setViewer(currentViewer);
- adapter.handleDoubleClick(element);
- }
- }
- }
-
- class SelectAllAction extends Action {
-
- public SelectAllAction() {
- super(SystemResources.ACTION_SELECT_ALL_LABEL, null);
- }
-
- public void run() {
-
- if ((currentViewer != null) && (currentViewer instanceof TableViewer)) {
- TableViewer viewer = (TableViewer) currentViewer;
- viewer.getTable().selectAll();
- // force viewer selection change
- viewer.setSelection(viewer.getSelection());
- }
- }
- }
-
- public class CancelAction extends Action {
-
- public CancelAction() {
- super(SystemResources.ACTION_CANCEL_SEARCH_LABEL, RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_STOP_ID));
- setToolTipText(SystemResources.ACTION_CANCEL_SEARCH_TOOLTIP);
- RSEUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, RSEUIPlugin.HELPPREFIX + "search_cancel"); //$NON-NLS-1$
- }
-
- public void run() {
-
- if (currentViewer == null) {
- return;
- }
-
- Object input = currentViewer.getInput();
-
- if (input != null) {
-
- if (input instanceof IHostSearchResultSet) {
- IHostSearchResultSet resultSet = (IHostSearchResultSet)input;
- setEnabled(false);
- resultSet.cancel();
- }
- }
- }
-
- public void updateEnableState(IAdaptable input) {
-
- // no input yet, so disable it
- if (input == null) {
- setEnabled(false);
- }
-
- if (input instanceof IHostSearchResultSet) {
- IHostSearchResultSet set = (IHostSearchResultSet)input;
-
- // running, so enable it
- if (set.isRunning()) {
- setEnabled(true);
- }
- // otherwise, disable
- else {
- setEnabled(false);
- }
- }
- // some other input, disable it
- else {
- setEnabled(false);
- }
- }
- }
-
- /**
- * Constructor for SystemSearchViewPart.
- */
- public SystemSearchViewPart() {
- super();
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchPart#createPartControl(Composite)
- */
- public void createPartControl(Composite parent) {
-
- // create the page book
- pageBook = new PageBook(parent, SWT.NONE);
-
- // pageBook.showPage(createDummyControl());
-
- // get view site
- IViewSite site = getViewSite();
-
- // set a dummy selection provider
- // getSite().setSelectionProvider(createDummySelectionProvider());
-
- // get action bars
- actionBars = site.getActionBars();
-
- // get the menu manager
- mMgr = actionBars.getMenuManager();
-
- // get the tool bar manager
- tbMgr = actionBars.getToolBarManager();
-
- _statusLine = actionBars.getStatusLineManager();
-
-
- // initialize toolbar actions
- initToolBarActions(tbMgr);
-
- // get the status line manager
- //slMgr = actionBars.getStatusLineManager();
-
- // update action bars
- actionBars.updateActionBars();
-
- // add view as a system listener
- RSECorePlugin.getTheSystemRegistry().addSystemResourceChangeListener(this);
-
- // set help
- SystemWidgetHelpers.setHelp(pageBook, RSEUIPlugin.HELPPREFIX + "srch0000"); //$NON-NLS-1$
- }
-
- private void initToolBarActions(IToolBarManager tbMgr) {
-
- // create cancel action
- if (cancelAction == null) {
- cancelAction = new CancelAction();
-
- if (currentViewer == null) {
- cancelAction.setEnabled(false);
- }
- else if (currentViewer.getInput() == null){
- cancelAction.setEnabled(false);
- }
- else {
- cancelAction.setEnabled(true);
- }
- }
-
- // create remove selected matches action
- if (removeSelectedAction == null) {
- removeSelectedAction = new SystemSearchRemoveSelectedMatchesAction(this, getShell());
-
- if (currentViewer == null) {
- removeSelectedAction.setEnabled(false);
- }
- else {
- removeSelectedAction.setEnabled(isRemoveSelectedEnabled());
- }
- }
-
- // create remove all matches action
- if (removeAllAction == null) {
- removeAllAction = new SystemSearchRemoveAllMatchesAction(this, getShell());
-
- if (currentViewer == null) {
- removeAllAction.setEnabled(false);
- }
- else {
- Object input = currentViewer.getInput();
- removeAllAction.setEnabled(isRemoveAllEnabled((IAdaptable)input));
- }
- }
-
- // add cancel action
- tbMgr.add(cancelAction);
-
- // add remove selected action
- tbMgr.add(removeSelectedAction);
-
- // add remove all action
- tbMgr.add(removeAllAction);
-
- // clipboard
- Clipboard clipboard = RSEUIPlugin.getTheSystemRegistryUI().getSystemClipboard();
- Shell shell = RSEUIPlugin.getTheSystemRegistryUI().getShell();
-
- copyAction = new SystemSearchCopyToClipboardAction(shell, clipboard);
- pasteAction = new SystemPasteFromClipboardAction(shell, clipboard);
-
- CellEditorActionHandler editorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
-
- editorActionHandler.setCopyAction(copyAction);
- editorActionHandler.setPasteAction(pasteAction);
- editorActionHandler.setDeleteAction(removeSelectedAction);
- // editorActionHandler.setSelectAllAction(new SelectAllAction());
- }
-
- /**
- * Updates the remove selected action.
- * @return <code>true</code> if remove selected action should be enabled, <code>false</code> otherwise.
- */
- private boolean isRemoveSelectedEnabled() {
-
- ISelection selection = getSelection();
-
- if (selection == null) {
- return false;
- }
- else if (selection.isEmpty()) {
- return false;
- }
- else {
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection strSel = (IStructuredSelection)selection;
-
- // note that SystemSearchTableView returns the current input
- // if the actual selection is null
- // so we check for it and return null
- if (strSel.getFirstElement() == currentViewer.getInput()) {
- return false;
- }
- else {
- return true;
- }
- }
- else {
- return false;
- }
- }
- }
-
- /**
- * Updates the remove all matches action.
- * @param input the input to the current viewer, or <code>null</code> if there is currently no input.
- * @return <code>true</code> if remove all action should be enabled, <code>false</code> otherwise.
- */
- private boolean isRemoveAllEnabled(IAdaptable input) {
-
- if (input == null) {
- return false;
- }
-
- ISystemViewElementAdapter adapter = getViewAdapter(input);
-
- if (adapter == null) {
- return false;
- }
- else {
- return adapter.hasChildren(input);
- }
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- pageBook.setFocus();
- }
-
- /**
- * @see org.eclipse.ui.IViewPart#init(IViewSite, IMemento)
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- }
-
- /**
- * @see org.eclipse.ui.IViewPart#saveState(IMemento)
- */
- public void saveState(IMemento memento) {
- super.saveState(memento);
- }
-
- /**
- * Add a search result set.
- * @param resultSet the search result set
- */
- public void addSearchResult(IAdaptable resultSet) {
-
- // if the correct adapter is not registered, then return
- ISystemViewElementAdapter adapter = getViewAdapter(resultSet);
-
- if (adapter == null) {
- return;
- }
-
- if (resultSet instanceof IHostSearchResultSet) {
- currentViewer = createSearchResultsTable((IHostSearchResultSet)resultSet, adapter);
- }
- else {
- currentViewer = createSearchResultsTree(resultSet, adapter);
-
- TreeViewer treeViewer = (TreeViewer)currentViewer;
- MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(this);
- Tree tree = (Tree)treeViewer.getControl();
- Menu menu = menuMgr.createContextMenu(tree);
- tree.setMenu(menu);
- }
-
- // set input
- currentViewer.setInput(resultSet);
-
- // add as selection changed listener to current viewer
- currentViewer.addSelectionChangedListener(this);
-
- // set as selection provider
- getSite().setSelectionProvider(currentViewer);
-
- // add double click listener
- currentViewer.addDoubleClickListener(new SystemSearchDoubleClickListener());
-
- // set help for control
- SystemWidgetHelpers.setHelp(currentViewer.getControl(), RSEUIPlugin.HELPPREFIX + "srch0000"); //$NON-NLS-1$
-
- // add current viewer to viewer list
- viewers.add(currentViewer);
-
- // get title to use from adapter
- String title = adapter.getText(resultSet);
-
- // set the title of the view
- setContentDescription(title);
-
- int num = viewers.size()-1;
-
- // create history action
- SystemSearchHistoryAction historyAction = new SystemSearchHistoryAction(title, RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SEARCH_RESULT_ID), this, num);
-
- // add to list of history actions
- historyActions.add(historyAction);
-
- // if this is the first result set, add the clear history action
- if (viewers.size() == 1) {
-
- // create a group for history actions
- mMgr.add(new GroupMarker(MENU_HISTORY_GROUP_NAME));
-
- // create a separator with a group for clear history action
- mMgr.add(new Separator(MENU_CLEAR_HISTORY_GROUP_NAME));
-
- // add the clear history action to the group
- clearHistoryAction = new SystemSearchClearHistoryAction(this, getShell());
- mMgr.appendToGroup(MENU_CLEAR_HISTORY_GROUP_NAME, clearHistoryAction);
- }
-
- // add history action to the menu manager
- mMgr.appendToGroup(MENU_HISTORY_GROUP_NAME, historyAction);
-
- // add global actions
- // actionBars.setGlobalActionHandler(ActionFactory.DELETE, new SystemSearchDeleteAction(this));
-
- // update action bars
- actionBars.updateActionBars();
-
- // show the control
- pageBook.showPage(currentViewer.getControl());
-
- // enable/disable state for this input
- if (cancelAction != null) {
- cancelAction.updateEnableState(resultSet);
- }
-
- // enable/disable state
- if (removeSelectedAction != null) {
- removeSelectedAction.setEnabled(isRemoveSelectedEnabled());
- }
-
- // enable/disable state for this input
- if (removeAllAction != null) {
- removeAllAction.setEnabled(isRemoveAllEnabled(resultSet));
- }
- }
-
- private StructuredViewer createSearchResultsTree(IAdaptable resultSet, ISystemViewElementAdapter adapter)
- {
-
- // create the current tree
- Tree currentControl = new Tree(pageBook, SWT.MULTI);
-
- // create the current viewer
- TreeViewer currentViewer = new TreeViewer(currentControl);
- currentViewer.setUseHashlookup(true);
- currentViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
-
- // create a new content provider
- SystemSearchViewContentProvider contentProvider = new SystemSearchViewContentProvider();
- // save the viewpart to the provider
- contentProvider.setViewPart(this);
- // add the content provider to the viewer
- currentViewer.setContentProvider(contentProvider);
-
- // create a new label provider
- SystemSearchViewLabelProvider labelProvider = new SystemSearchViewLabelProvider();
-
- // add the label provider to the viewer
- currentViewer.setLabelProvider(labelProvider);
-
- return currentViewer;
- }
-
- private StructuredViewer createSearchResultsTable(IHostSearchResultSet resultSet, ISystemViewElementAdapter adapter) {
-
- // create table portion
- // TODO change to tabletree when eclipse fixes the swt widget
- //TableTree table = new TableTree(pageBook, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
- Tree tabletree = new Tree(pageBook, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
- SystemSearchTableView viewer = new SystemSearchTableView(tabletree, resultSet, this);
-
- getSite().registerContextMenu(viewer.getContextMenuManager(), viewer);
- return viewer;
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
- public void dispose() {
-
- // remove as resource change listener
- RSECorePlugin.getTheSystemRegistry().removeSystemResourceChangeListener(this);
-
- // clear viewers
- clearViewers();
-
- // clear arrays
- viewers.clear();
- historyActions.clear();
-
- // call super as required
- super.dispose();
- }
-
- /**
- * Remove current viewer as selection provider, removes children of all the inputs and disposes
- * the controls if they haven't already been disposed.
- */
- private void clearViewers() {
-
- // remove current viewer as selection provider if it exists
- if (currentViewer != null) {
-
- // remove as selection changed listener to current viewer
- currentViewer.removeSelectionChangedListener(this);
-
- if (getSite().getSelectionProvider() == currentViewer) {
- getSite().setSelectionProvider(null);
- }
- }
-
- for (int i = 0; i < viewers.size(); i++) {
-
- Object viewer = viewers.get(i);
-
- // if we're dealing with universal search
- if (viewer instanceof SystemSearchTableView) {
-
- SystemSearchTableView tableView = (SystemSearchTableView)viewer;
-
- Object input = tableView.getInput();
-
- // dispose the remote search result set
- // which cancels the search and removes contents from the input
- // (i.e. removes from model)
- if (input instanceof IHostSearchResultSet) {
- IHostSearchResultSet set = (IHostSearchResultSet)input;
- set.dispose();
- }
-
- // dispose viewer
- tableView.dispose();
- }
- // other search
- else if (viewer instanceof TreeViewer){
-
- TreeViewer treeView = (TreeViewer)viewer;
-
- Object input = treeView.getInput();
-
- ISystemViewElementAdapter adapter = getViewAdapter(input);
-
- if (adapter != null && adapter instanceof ISystemRemoveElementAdapter) {
- ISystemRemoveElementAdapter rmAdapter = (ISystemRemoveElementAdapter)adapter;
- rmAdapter.removeAllChildren(input);
-
- Control control = treeView.getControl();
-
- if (!control.isDisposed()) {
- control.dispose();
- }
- }
- }
- }
- }
-
- /**
- * Show search result with the given index.
- * @param index the index in the result history list
- */
- public void showSearchResult(int index) {
-
- // remove as selection listener from current viewer
- if (currentViewer != null) {
- currentViewer.removeSelectionChangedListener(this);
- }
-
- // get viewer with this index and make it current
- currentViewer = (StructuredViewer)(viewers.get(index));
-
- // set as selection provider
- getSite().setSelectionProvider(currentViewer);
-
- // add as selection changed listener to current viewer
- currentViewer.addSelectionChangedListener(this);
-
- // get the input
- IAdaptable resultSet = (IAdaptable)(currentViewer.getInput());
-
- if (resultSet == null) {
- return;
- }
-
- ISystemViewElementAdapter adapter = getViewAdapter(resultSet);
-
- // if the correct adapter is not registered, then return
- if (adapter == null) {
- return;
- }
-
- // get title to use from adapter
- String title = adapter.getText(resultSet);
-
- // set the title of the view
- setContentDescription(title);
-
- // get the associated control
- Control currentControl = currentViewer.getControl();
-
- // show the control
- pageBook.showPage(currentControl);
-
- // enable/disable state for this input
- if (cancelAction != null) {
- cancelAction.updateEnableState(resultSet);
- }
-
- // enable/disable state
- if (removeSelectedAction != null) {
- removeSelectedAction.setEnabled(isRemoveSelectedEnabled());
- }
-
- // enable/disable state for this input
- if (removeAllAction != null) {
- removeAllAction.setEnabled(isRemoveAllEnabled(resultSet));
- }
- }
-
- /**
- * Delete the selected object in the view.
- * @return <code>true</code> if the selection has been deleted, <code>false</code> otherwise.
- */
- public boolean deleteSelected() {
-
- if (currentViewer == null) {
- return false;
- }
-
- IStructuredSelection selection = (IStructuredSelection)(currentViewer.getSelection());
-
- if (selection == null || selection.isEmpty()) {
- return false;
- }
-
- Object input = currentViewer.getInput();
-
- ISystemViewElementAdapter adapter = getViewAdapter(input);
-
- // adapter should be an instance of ISystemRemoveElementAdapter
- if (adapter == null || !(adapter instanceof ISystemRemoveElementAdapter)) {
- return false;
- }
-
- Iterator elements = selection.iterator();
-
- ArrayList removeElements = new ArrayList();
-
- while (elements.hasNext()) {
- Object element = elements.next();
- ((ISystemRemoveElementAdapter)adapter).remove(input, element);
- removeElements.add(element);
- }
-
- // current viewer should be an instance of tree viewer
- // remove the elements from it to update the view
- if (currentViewer instanceof TreeViewer) {
- ((TreeViewer)currentViewer).remove(removeElements.toArray());
- }
-
- // get title to use from adapter
- String title = adapter.getText(input);
-
- // set the title of the view
- setContentDescription(title);
-
- // enable/disable state for this input
- if (cancelAction != null) {
- cancelAction.updateEnableState((IAdaptable)input);
- }
-
- // enable/disable state for this input
- if (removeSelectedAction != null) {
- removeSelectedAction.setEnabled(isRemoveSelectedEnabled());
- }
-
- // enable/disable state for this input
- if (removeAllAction != null) {
- removeAllAction.setEnabled(isRemoveAllEnabled((IAdaptable)input));
- }
-
- return true;
- }
-
- /**
- * Deletes all the pages in the view.
- * @return <code>true</code> if all pages have been deleted, <code>false</code> otherwise.
- */
- public boolean deleteAllPages() {
-
- // first show a dummy control in page book
- // this must be done before viewers are cleared
- // reason is that current showing control in page book can not be disposed
- // SWT doesn't seem to like it
- // This is fixed in 3.0
- pageBook.showPage(createDummyControl());
-
- // clear viewers
- clearViewers();
-
- // current viewer is null again
- currentViewer = null;
-
- // clear the viewer list
- viewers.clear();
-
- // disable cancel action
- cancelAction.setEnabled(false);
-
- // disable remove all action
- removeSelectedAction.setEnabled(false);
-
- // disable remove all action
- removeAllAction.setEnabled(false);
-
- // clear the history action list
- historyActions.clear();
-
- // get rid of all menu manager actions
- mMgr.removeAll();
-
- // update action bars
- actionBars.updateActionBars();
-
- // clear the content description
- setContentDescription(""); //$NON-NLS-1$
-
- return true;
- }
-
- /**
- * Creates a dummy control to show in the page book.
- * @return a dummy control.
- */
- private Control createDummyControl() {
- Control control = new Composite(pageBook, SWT.NONE);
- return control;
- }
-
- /**
- * Deletes the current page.
- * @return <code>true</code> if the current page has been deleted, <code>false</code> otherwise.
- */
- public boolean deleteCurrentPage() {
-
- // remove current viewer as selection provider if it exists
- if (currentViewer != null) {
-
- // remove as selection changed listener to current viewer
- currentViewer.removeSelectionChangedListener(this);
-
- if (getSite().getSelectionProvider() == currentViewer) {
- getSite().setSelectionProvider(null);
- }
- }
- else {
- return false;
- }
-
- Object input = currentViewer.getInput();
-
- ISystemViewElementAdapter adapter = getViewAdapter(input);
-
- // universal search
- if (currentViewer instanceof SystemSearchTableView)
- {
-
- SystemSearchTableView tableView = (SystemSearchTableView)currentViewer;
-
- // remove viewer as listener
- tableView.removeAsListener();
-
- // clear model
- if (input instanceof IHostSearchResultSet) {
- IHostSearchResultSet set = (IHostSearchResultSet)input;
- set.dispose();
- }
-
- // now refresh viewer
- // but flush cache of the provider first for an accurate refresh
- SystemTableTreeViewProvider provider = (SystemTableTreeViewProvider)(tableView.getContentProvider());
- provider.flushCache();
- tableView.refresh();
- }
- // other search
- else if (currentViewer instanceof TreeViewer){
-
- TreeViewer treeView = (TreeViewer)currentViewer;
-
- if (adapter != null && adapter instanceof ISystemRemoveElementAdapter) {
- ISystemRemoveElementAdapter rmAdapter = (ISystemRemoveElementAdapter)adapter;
- rmAdapter.removeAllChildren(input);
- treeView.refresh();
- }
- }
-
- // get title to use from adapter
- String title = null;
- if (adapter != null)
- title = adapter.getText(input);
-
- // set the title of the view
- setContentDescription(title);
-
- // disable cancel action
- cancelAction.setEnabled(false);
-
- // disable remove selected action
- removeSelectedAction.setEnabled(false);
-
- // disable remove all action
- removeAllAction.setEnabled(false);
-
- return true;
- }
-
- /**
- * Get the adapter for the given object.
- * @param element the object the object for which I want the adapter.
- * @return the adapter for the object.
- */
- public ISystemViewElementAdapter getViewAdapter(Object element) {
- return SystemAdapterHelpers.getViewAdapter(element);
- }
-
- /**
- * Get the shell.
- * @return the shell
- */
- public Shell getShell() {
- return getSite().getShell();
- }
-
- public void systemResourceChanged(ISystemResourceChangeEvent event) {
-
- // need to introduce another event type for this....
- if (event.getType() == ISystemResourceChangeEvents.EVENT_SEARCH_FINISHED) {
-
- // the view is added as a system listener when the part is created
- // so the current viewer may not exist if the search results has not been added yet
- if (currentViewer == null) {
- return;
- }
-
- Object actualSource = event.getSource();
-
- if (actualSource instanceof IHostSearchResultConfiguration) {
-
- IHostSearchResultSet source = ((IHostSearchResultConfiguration)actualSource).getParentResultSet();
-
- // get title to use from adapter
- ISystemViewElementAdapter adapter = getViewAdapter(source);
-
- if (adapter == null) {
- return;
- }
-
- int index = -1;
-
- // if the source is the input to the current viewer
- // update view title and cancel action
- // also update the history action corresponding to the current view
- if (currentViewer.getInput() == source) {
-
- // end of a search
- String title = adapter.getText(source);
-
- // set the title of the view
- setContentDescription(title);
-
- // enable/disable state for this input
- if (cancelAction != null) {
- cancelAction.updateEnableState((IAdaptable)source);
- }
-
- // enable/disable state for this input
- if (removeSelectedAction != null) {
- removeSelectedAction.setEnabled(isRemoveSelectedEnabled());
- }
-
- // enable/disable state for this input
- if (removeAllAction != null) {
- removeAllAction.setEnabled(isRemoveAllEnabled((IAdaptable)source));
- }
-
- // find out where the current viewer is in the viewer list
- index = viewers.indexOf(currentViewer);
- }
- // if the source is not the input to the current view
- // we simply update the history action
- else {
-
- for (int i = 0; i < viewers.size(); i++) {
-
- SystemSearchTableView view = (SystemSearchTableView)viewers.get(i);
-
- if (view.getInput() == source) {
- index = i;
- break;
- }
- }
- }
-
- // since the history actions list paralles the viewer list, use the index to
- // get the history action
- if (index >= 0) {
- SystemSearchHistoryAction historyAction = (SystemSearchHistoryAction)historyActions.get(index);
- historyAction.setText(adapter.getText(source));
- }
- }
- }
- }
-
- //------------------------------------------------------
- // Methods used by the tree view pop-up menu
- //------------------------------------------------------
- /**
- * Fill context for the tree view pop-up menu.
- * @param menu the menu manager.
- */
- public void fillContextMenu(IMenuManager menu)
- {
- IStructuredSelection selection = (IStructuredSelection)currentViewer.getSelection();
-
- if (selection == null) {
- return;
- }
-
- int selectionCount = selection.size();
-
- if (selectionCount == 0) { // nothing selected
- return;
- }
- else {
-
- // if only one selection, check if selection is the input
- // if so add no actions
- if (selectionCount == 1) {
-
- if (selection.getFirstElement() == currentViewer.getInput()) {
- return;
- }
- }
-
- // if selection count is more than 1
- // check if all have same parent
- // if not, check if they have ancestor relationship
- // if so, add no actions
-// if (selectionCount > 1) {
-// boolean allSelectionsFromSameParent = sameParent();
-//
-// // if all selections do not have the same parent, do not show anything in the menu
-// if (!allSelectionsFromSameParent) {
-//
-// if (selectionHasAncestryRelationship()) {
-// // don't show the menu because actions with
-// // multiple select on objects that are ancestors
-// // of each other is problematic
-// // still create the standard groups
-// SystemView.createStandardGroups(menu);
-// return;
-// }
-// }
-// }
-
- // partition into groups...
- SystemView.createStandardGroups(menu);
-
- // adapter actions
- SystemMenuManager ourMenu = new SystemMenuManager(menu);
- Object element = selection.getFirstElement();
- ISystemViewElementAdapter adapter = getViewAdapter(element);
- adapter.setViewer(currentViewer);
- adapter.addActions(ourMenu, selection,
- getShell(),
- ISystemContextMenuConstants.GROUP_ADAPTERS);
- }
- }
-
- /**
- * 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.
- * <p>
- * Designed to be as fast as possible by going directly to the SWT widgets
- */
- public boolean sameParent()
- {
- boolean same = true;
-
- Tree tree = null;
-
- if (currentViewer instanceof AbstractTreeViewer) {
- tree = (Tree)(currentViewer.getControl());
- }
- else {
- return false;
- }
-
- TreeItem[] items = tree.getSelection();
-
- if ((items == null) || (items.length == 0))
- return true;
-
- TreeItem prevParent = null;
- TreeItem currParent = null;
-
- for (int idx=0; same && (idx<items.length); idx++)
- {
- currParent = items[idx].getParentItem();
-
- if ((idx>0) && (currParent != prevParent))
- {
- same = false;
- }
- else
- {
- prevParent = currParent;
- }
- }
-
- return same;
- }
-
- /**
- * Called when the context menu is about to open.
- * Calls {@link #fillContextMenu(IMenuManager)}
- */
- public void menuAboutToShow(IMenuManager menu)
- {
- fillContextMenu(menu);
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener)
- {
- currentViewer.addSelectionChangedListener(listener);
- }
-
- /**
- * Returns the current selection for this provider.
- *
- * @return the current selection
- */
- public ISelection getSelection()
- {
- if (currentViewer == null) {
- return null;
- }
- else {
- return currentViewer.getSelection();
- }
- }
- /**
- * Removes the given selection change listener from this selection provider.
- * Has no affect if an identical listener is not registered.
- *
- * @param listener a selection changed listener
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener)
- {
- currentViewer.removeSelectionChangedListener(listener);
- }
- /**
- * Sets the current selection for this selection provider.
- *
- * @param selection the new selection
- */
- public void setSelection(ISelection selection)
- {
- currentViewer.setSelection(selection);
- }
- /**
- * Set the title of this view part
- * @param title
- */
- public void setViewPartTitle(String title)
- {
- setContentDescription(title);
- }
-
- /**
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
-
- if (event.getSelectionProvider() == currentViewer) {
- removeSelectedAction.setEnabled(isRemoveSelectedEnabled());
- }
- else {
- removeSelectedAction.setEnabled(false);
- }
-
- IStructuredSelection sel = (IStructuredSelection)(event.getSelection());
-
- Iterator iter = sel.iterator();
-
- // set viewer for adapters of the selected elements
- while (iter.hasNext()) {
- ISystemViewElementAdapter adapter = getViewAdapter(iter.next());
- adapter.setViewer(currentViewer);
- }
-
- copyAction.setEnabled(copyAction.updateSelection(sel));
- pasteAction.setEnabled(pasteAction.updateSelection(sel));
- }
-
- /**
- * Gets the current viewer, i.e. the viewer whose control is being currently displayed in the view.
- * @return the current viewer, or <code>null</code> if there is no current viewer.
- */
- public StructuredViewer getCurrentViewer() {
- return currentViewer;
- }
-
- public Viewer getRSEViewer()
- {
- return currentViewer;
- }
-
-// -------------------------------
- // ISystemMessageLine interface...
- // -------------------------------
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage()
- {
- _errorMessage = null;
- sysErrorMessage = null;
- if (_statusLine != null)
- _statusLine.setErrorMessage(_errorMessage);
- }
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage()
- {
- _message = null;
- if (_statusLine != null)
- _statusLine.setMessage(_message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage()
- {
- return _errorMessage;
- }
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null<code> is returned.
- */
- public String getMessage()
- {
- return _message;
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message)
- {
- this._errorMessage = message;
- if (_statusLine != null)
- _statusLine.setErrorMessage(message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public SystemMessage getSystemErrorMessage()
- {
- return sysErrorMessage;
- }
-
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(SystemMessage message)
- {
- sysErrorMessage = message;
- setErrorMessage(message.getLevelOneText());
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(Throwable exc)
- {
- setErrorMessage(exc.getMessage());
- }
-
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message)
- {
- this._message = message;
- if (_statusLine != null)
- _statusLine.setMessage(message);
- }
- /**
- *If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(SystemMessage message)
- {
- setMessage(message.getLevelOneText());
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemResourceAdaptableProfile.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemResourceAdaptableProfile.java
deleted file mode 100644
index 02629c149..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemResourceAdaptableProfile.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.rse.core.model.ISystemProfile;
-
-/**
- * This class wrappers a SystemProfile and adapts it to an IResource
- * by mapping to its underlying folder.
- */
-public class SystemResourceAdaptableProfile
-{
- /**
- * Constructor
- */
- public SystemResourceAdaptableProfile(ISystemProfile profile)
- {
- super();
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamView.java
deleted file mode 100644
index c6cdae4eb..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamView.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-import java.util.Vector;
-
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
-import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
-import org.eclipse.rse.core.events.ISystemResourceChangeListener;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemWidgetHelpers;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.ISystemSelectAllTarget;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swt.widgets.Widget;
-
-
-//import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-
-/**
- * We specialize tree viewer for the Team view, so we know
- * when we are dealing with the team view in common code.
- */
-public class SystemTeamView extends TreeViewer
- implements ISystemSelectAllTarget, ISystemResourceChangeListener,
- ISystemShellProvider
-{
- private SystemTeamViewPart teamViewPart;
-
- /**
- * @param parent
- */
- public SystemTeamView(Composite parent, SystemTeamViewPart teamViewPart)
- {
- super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); // DKM - putting style here to avoid SWT.BORDER (defect 168972)
- this.teamViewPart = teamViewPart;
- SystemWidgetHelpers.setHelp(getTree(), RSEUIPlugin.HELPPREFIX+"teamview"); //$NON-NLS-1$
- }
-
- /**
- * @param parent
- * @param style
- */
- public SystemTeamView(Composite parent, int style, SystemTeamViewPart teamViewPart)
- {
- super(parent, style);
- this.teamViewPart = teamViewPart;
- SystemWidgetHelpers.setHelp(getTree(), RSEUIPlugin.HELPPREFIX+"teamview"); //$NON-NLS-1$
- }
-
- /**
- * @param tree
- */
- public SystemTeamView(Tree tree, SystemTeamViewPart teamViewPart)
- {
- super(tree);
- this.teamViewPart = teamViewPart;
- SystemWidgetHelpers.setHelp(getTree(), RSEUIPlugin.HELPPREFIX+"teamview"); //$NON-NLS-1$
- }
-
- /**
- * Return the part view part of this tree view
- */
- public SystemTeamViewPart getTeamViewPart()
- {
- return teamViewPart;
- }
-
- /**
- * This returns an array containing each element in the tree, up to but not including the root.
- * The array is in reverse order, starting at the leaf and going up.
- */
- public Object[] getElementNodes(Object element)
- {
- Widget w = findItem(element);
- if ((w != null) && (w instanceof TreeItem))
- return getElementNodes((TreeItem)w);
- return null;
- }
- /**
- * This returns an array containing each element in the tree, up to but not including the root.
- * The array is in reverse order, starting at the leaf and going up.
- * This flavour is optimized for the case when you have the tree item directly.
- */
- public Object[] getElementNodes(TreeItem item)
- {
- Vector v = new Vector();
- v.addElement(item.getData());
- while (item != null)
- {
- item = item.getParentItem();
- if (item != null)
- v.addElement(item.getData());
- }
- Object[] nodes = new Object[v.size()];
- for (int idx=0; idx<nodes.length; idx++)
- nodes[idx] = v.elementAt(idx);
- return nodes;
- }
-
- /**
- * Use findItem to find a tree item given its data object, or null if given object not in tree.
- */
- public TreeItem findTreeItem(Object dataObject)
- {
- Widget widget = findItem(dataObject);
- if (widget instanceof TreeItem)
- return (TreeItem)widget;
- else
- return null;
- }
- /**
- * Given a tree item, search the immediate children for an item representing the given object.
- */
- public TreeItem findChildTreeItem(TreeItem parentItem, Object dataObject)
- {
- TreeItem[] childItems = parentItem.getItems();
- TreeItem childItem = null;
- for (int idx=0; (childItem==null) && (idx<childItems.length); idx++)
- {
- if ((childItems[idx].getData() != null) && childItems[idx].getData().equals(dataObject))
- childItem = childItems[idx];
- }
- return childItem;
- }
-
- /**
- * Called when a property is updated and we need to inform the Property Sheet viewer.
- * There is no formal mechanism for this so we simulate a selection changed event as
- * this is the only event the property sheet listens for.
- */
- public void updatePropertySheet()
- {
- ISelection selection = getSelection();
- if (selection == null)
- return;
- // create an event
- SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
- // fire the event
- fireSelectionChanged(event);
- }
-
- // ----------------------------------------
- // ISystemResourceChangeListener methods...
- // ----------------------------------------
-
- /**
- * Called when something changes in the model
- */
- public void systemResourceChanged(ISystemResourceChangeEvent event)
- {
- int type = event.getType();
- switch(type)
- {
- case ISystemResourceChangeEvents.EVENT_COLLAPSE_ALL:
- collapseToLevel(getInput(), AbstractTreeViewer.ALL_LEVELS);
- break;
- }
- }
-
- /**
- * Return the shell
- */
- public Shell getShell()
- {
- return super.getControl().getShell();
- }
-
- // -----------------------------------------------------------------
- // ISystemSelectAllTarget methods to facilitate the global action...
- // -----------------------------------------------------------------
- /**
- * Return true if select all should be enabled for the given object.
- * For a tree view, you should return true if and only if the selected object has children.
- * You can use the passed in selection or ignore it and query your own selection.
- */
- public boolean enableSelectAll(IStructuredSelection selection)
- {
- Tree tree = getTree();
- TreeItem[] items = tree.getSelection();
- if ((items==null) || (items.length!=1)) // only allow for single selections
- return false;
-
- TreeItem ti = items[0];
- int count = getItemCount(ti);
- if (count == 1) // is it a dummy?
- {
- if ((getItems(ti)[0]).getData() == null)
- count = 0; // assume a dummy
- }
- return (count > 0);
- }
- /**
- * 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
- * of the given selected object. You can use the passed in selected object
- * or ignore it and query the selected object yourself.
- */
- public void doSelectAll(IStructuredSelection selection)
- {
- Tree tree = getTree();
- TreeItem[] currSel = tree.getSelection();
- TreeItem[] childItems = currSel[0].getItems();
- if (childItems.length == 0)
- return;
- tree.setSelection(childItems);
- Object[] childObjects = new Object[childItems.length];
- for (int idx=0; idx<childObjects.length; idx++)
- childObjects[idx] = childItems[idx].getData();
- fireSelectionChanged(
- new SelectionChangedEvent(this,
- new StructuredSelection(childObjects)));
- }
-
- /**
- * Handles a collapse-selected request
- */
- public void collapseSelected()
- {
- TreeItem[] selectedItems = ((Tree)getControl()).getSelection();
- if ((selectedItems != null) && (selectedItems.length>0))
- {
- for (int idx=0; idx<selectedItems.length; idx++)
- selectedItems[idx].setExpanded(false);
- }
- }
- /**
- * Handles an expand-selected request
- */
- public void expandSelected()
- {
- TreeItem[] selectedItems = ((Tree)getControl()).getSelection();
- if ((selectedItems != null) && (selectedItems.length>0))
- {
- for (int idx=0; idx<selectedItems.length; idx++)
- {
- if (!selectedItems[idx].getExpanded())
- {
- createChildren(selectedItems[idx]);
- }
- selectedItems[idx].setExpanded(true);
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewCategoryAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewCategoryAdapter.java
deleted file mode 100644
index bf79f15a1..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewCategoryAdapter.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David Dykstal (IBM) - 180562: remove implementation of IRSEUserIdConstants
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * David Dykstal (IBM) - [197036] rewrote getSubSystemConfigurationNodes to get filter pools
- * in a way that delays the loading of subsystem configurations
- * Xuan Chen (IBM) - [223126] [api][breaking] Remove API related to User Actions in RSE Core/UI
- * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.IPropertySet;
-import org.eclipse.rse.core.model.IPropertySetContainer;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
-import org.eclipse.rse.core.subsystems.SubSystemConfiguration;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.view.SystemViewResources;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-
-/**
- * Adapter for displaying and processing SystemTeamViewCategoryNode objects in tree views, such as
- * the Team view.
- */
-public class SystemTeamViewCategoryAdapter
- extends AbstractSystemViewAdapter {
-
- private boolean actionsCreated = false;
- //private Hashtable categoriesByProfile = new Hashtable();
-
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
-
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given element.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- if (!actionsCreated)
- createActions();
- //menu.add(menuGroup, copyAction);
- }
- private void createActions()
- {
- actionsCreated = true;
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- return category.getImageDescriptor();
- }
-
- /**
- * Return the label for this object
- */
- public String getText(Object element)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- return category.getLabel();
- }
-
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- return category.getLabel();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- return category.getProfile() + "." + category.getLabel(); //$NON-NLS-1$
- }
-
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- return SystemViewResources.RESID_PROPERTY_TEAM_CATEGORY_TYPE_VALUE;
- }
-
- /**
- * Return the string to display in the status line when the given object is selected.
- * We return:
- */
- public String getStatusLineText(Object element)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- return SystemResources.RESID_TEAMVIEW_CATEGORY_VALUE + ": " + category.getLabel() + " - " + category.getDescription(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Return the parent of this object. We return the RemoteSystemsConnections project
- */
- public Object getParent(Object element)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- return category.getProfile();
- }
-
- /**
- * Return the children of this profile.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- ISystemProfile profile = category.getProfile();
- String categoryType = category.getMementoHandle();
- if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_CONNECTIONS))
- {
- return profile.getHosts();
- }
- else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_PROPERTYSETS))
- {
- return createSystemTeamViewPropertySetNodes(profile, category);
- }
- else
- return createSubSystemConfigurationNodes(profile, category);
- }
-
-
- /**
- * Create subsystem configuration child nodes for expanded category node.
- */
- private SystemTeamViewSubSystemConfigurationNode[] createSubSystemConfigurationNodes(ISystemProfile profile, SystemTeamViewCategoryNode category) {
- // create a sorted set to hold the subsystem configurations based on the proxy ordering
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- final List proxies = Arrays.asList(sr.getSubSystemConfigurationProxies());
- Comparator comparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- ISubSystemConfiguration c1 = (SubSystemConfiguration) o1;
- ISubSystemConfiguration c2 = (SubSystemConfiguration) o2;
- ISubSystemConfigurationProxy proxy1 = c1.getSubSystemConfigurationProxy();
- ISubSystemConfigurationProxy proxy2 = c2.getSubSystemConfigurationProxy();
- Integer p1 = new Integer(proxies.indexOf(proxy1));
- Integer p2 = new Integer(proxies.indexOf(proxy2));
- int result = p1.compareTo(p2);
- return result;
- }
- };
- SortedSet activeSubsystemConfigurations = new TreeSet(comparator);
- // find the active subsystem configurations
- for (Iterator z = proxies.iterator(); z.hasNext();) {
- ISubSystemConfigurationProxy proxy = (ISubSystemConfigurationProxy) z.next();
- if (proxy.isSubSystemConfigurationActive()) {
- ISubSystemConfiguration config = proxy.getSubSystemConfiguration();
- activeSubsystemConfigurations.add(config);
- }
- }
- // construct the nodes for the view based on these configurations
- List nodes = new ArrayList();
- String categoryType = category.getMementoHandle();
- for (Iterator z = activeSubsystemConfigurations.iterator(); z.hasNext();) {
- ISubSystemConfiguration ssf = (ISubSystemConfiguration) z.next();
- boolean createNode = false;
- if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS)) {
- createNode = ssf.supportsFilters() && (profile.getFilterPools(ssf).length > 0);
- } else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_TARGETS)) {
- createNode = ssf.supportsTargets(); // && profile.getTargets(ssf).length > 0;
- }
- if (createNode) {
- nodes.add(new SystemTeamViewSubSystemConfigurationNode(profile, category, ssf));
- }
- }
- SystemTeamViewSubSystemConfigurationNode[] result = new SystemTeamViewSubSystemConfigurationNode[nodes.size()];
- nodes.toArray(result);
- return result;
- }
-
- /**
- * Create subsystem configuration child nodes for expanded category node.
- */
- private SystemTeamViewPropertySetNode[] createSystemTeamViewPropertySetNodes(IPropertySetContainer profile, SystemTeamViewCategoryNode category) {
-
- IPropertySet[] propertySets = profile.getPropertySets();
- if (null == propertySets || propertySets.length == 0)
- {
- return new SystemTeamViewPropertySetNode[0];
- }
- // construct the nodes for the view based on these configurations
- List nodes = new ArrayList();
- //String categoryType = category.getMementoHandle();
- for (int i = 0; i < propertySets.length; i++) {
- nodes.add(new SystemTeamViewPropertySetNode(profile, propertySets[i]));
- }
- SystemTeamViewPropertySetNode[] result = new SystemTeamViewPropertySetNode[nodes.size()];
- nodes.toArray(result);
- return result;
- }
-
- /**
- * Return true if this profile has children. We return true.
- */
- public boolean hasChildren(IAdaptable element)
- {
- return true;
- }
-
- // Property sheet descriptors defining all the properties we expose in the Property Sheet
- /**
- * Return our unique property descriptors, which getPropertyDescriptors adds to the common properties.
- */
- protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- /*
- propertyDescriptorArray = new PropertyDescriptor[1];
- RSEUIPlugin plugin = RSEUIPlugin.getDefault();
- int idx = 0;
- // status
- propertyDescriptorArray[idx] = new PropertyDescriptor(ISystemPropertyConstants.P_IS_ACTIVE,
- SystemViewResources.RESID_PROPERTY_PROFILESTATUS_LABEL);
- propertyDescriptorArray[idx].setDescription(SystemViewResources.RESID_PROPERTY_PROFILESTATUS_DESCRIPTION));
- ++idx;
- */
- }
- return propertyDescriptorArray;
- }
-
- /**
- * Returns the current value for the named property.
- * The parent handles P_TEXT and P_TYPE only, and we augment that here.
- * @param key - the name of the property as named by its property descriptor
- * @return the current value of the property
- */
- public Object internalGetPropertyValue(Object key)
- {
- /*
- if (name.equals(P_IS_ACTIVE))
- {
- boolean active = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName());
- if (active)
- return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL);
- else
- return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL);
- }
- else
- */
- return null;
- }
-
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- */
- public String getMementoHandle(Object element)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- return category.getMementoHandle();
- }
- /**
- * Return a short string to uniquely identify the type of resource.
- */
- public String getMementoHandleKey(Object element)
- {
- SystemTeamViewCategoryNode category = (SystemTeamViewCategoryNode)element;
- return category.getProfile().getName() + "." + category.getLabel(); //$NON-NLS-1$
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewCategoryNode.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewCategoryNode.java
deleted file mode 100644
index 4448293d7..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewCategoryNode.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.rse.core.model.ISystemProfile;
-
-
-/**
- * This class represents a child node under a profile, in the Team view.
- * It represents expandable categories such as "Connections", "Filter Pools",
- * "User Actions" and "Compile Commands".
- */
-public class SystemTeamViewCategoryNode implements IAdaptable
-{
- private String label, mementoHandle, description;
- private ImageDescriptor imageDescriptor;
- private ISystemProfile profile;
- public static final String MEMENTO_CONNECTIONS = "conns"; //$NON-NLS-1$
- public static final String MEMENTO_FILTERPOOLS = "pools"; //$NON-NLS-1$
- public static final String MEMENTO_USERACTIONS = "actions"; //$NON-NLS-1$
- public static final String MEMENTO_COMPILECMDS = "cmds"; //$NON-NLS-1$
- public static final String MEMENTO_PROPERTYSETS = "propertysets"; //$NON-NLS-1$
- public static final String MEMENTO_TARGETS = "targets"; //$NON-NLS-1$
-
- /**
- * Constructor
- */
- public SystemTeamViewCategoryNode(ISystemProfile profile)
- {
- super();
- this.profile = profile;
- }
-
- /**
- * This is the method required by the IAdaptable interface.
- * Given an adapter class type, return an object castable to the type, or
- * null if this is not possible.
- */
- public Object getAdapter(Class adapterType)
- {
- return Platform.getAdapterManager().getAdapter(this, adapterType);
- }
-
- /**
- * Return this node's image
- * @return the image to show in the tree, for this node
- */
- public ImageDescriptor getImageDescriptor()
- {
- return imageDescriptor;
- }
-
- /**
- * Return this node's label
- * @return the translated label to show in the tree, for this node
- */
- public String getLabel()
- {
- return label;
- }
-
- /**
- * Set the image for this node
- * @param descriptor ... the image to show in the tree, for this node
- */
- public void setImageDescriptor(ImageDescriptor descriptor)
- {
- imageDescriptor = descriptor;
- }
-
- /**
- * Set the label for this node
- * @param string ... the label to show in the tree, for this node
- */
- public void setLabel(String string)
- {
- label = string;
- }
- /**
- * Convert to string. We call getLabel()
- */
- public String toString()
- {
- return getLabel();
- }
-
- /**
- * @return profile this category is associated with
- */
- public ISystemProfile getProfile()
- {
- return profile;
- }
-
- /**
- * @param profile ... the profile this category is associated with
- */
- public void setProfile(ISystemProfile profile)
- {
- this.profile = profile;
- }
-
- /**
- * @return the untranslated value to store in the memento, to uniquely identify this node
- */
- public String getMementoHandle()
- {
- return mementoHandle;
- }
-
- /**
- * Set the untranslated value to store in the memento, to uniquely identify this node
- * @param string - untranslated value
- */
- public void setMementoHandle(String string)
- {
- mementoHandle = string;
- }
-
- /**
- * Return the description of this node. Shown on status line.
- */
- public String getDescription()
- {
- return description;
- }
-
- /**
- * Set the description of this node. Shown on status line.
- */
- public void setDescription(String string)
- {
- description = string;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewContentProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewContentProvider.java
deleted file mode 100644
index b220e3d4a..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewContentProvider.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
- * David Dykstal (IBM) - [189858] Removed the remote systems project in the team view
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.IContextObject;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-
-
-/**
- * Content provider for the RSE's Team view part.
- */
-public class SystemTeamViewContentProvider extends WorkbenchContentProvider
-{
- private SystemTeamViewInputProvider inputProvider = null;
- private Viewer viewer;
- /**
- * Constructor
- */
- public SystemTeamViewContentProvider()
- {
- }
-
- /**
- * Return the children of the given node, when it is expanded
- */
- public Object[] getChildren(Object element)
- {
- Object[] children;
- // for the project root node, return the SystemProfile objects
- if (element instanceof IProject)
- {
- //IProject rseProject = (IProject)element;
- ISystemProfile[] profiles = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().getSystemProfiles();
- children = profiles;
- //return profiles;
- }
- else
- {
- ISystemViewElementAdapter adapter = getSystemViewAdapter(element);
- if (adapter != null)
- children = adapter.getChildren((IAdaptable)element, new NullProgressMonitor());
- else
- children = super.getChildren(element);
- }
- /*
- String name = element.getClass().getName();
- if (element instanceof SystemTeamViewSubSystemConfigurationNode)
- {
- SystemTeamViewSubSystemConfigurationNode ssfNode = (SystemTeamViewSubSystemConfigurationNode)element;
- name = ssfNode.getParentCategory().getLabel() + "." + ssfNode.getSubSystemConfiguration().getName();
- }
- else if (element instanceof SystemTeamViewCategoryNode)
- {
- SystemTeamViewCategoryNode catNode = (SystemTeamViewCategoryNode)element;
- name = catNode.getLabel();
- }
- System.out.println(" "+Integer.toString(counter-1)+". In getChildren for object '"+name +"', returned "+((children==null)?"null":Integer.toString(children.length)));
- */
- return children;
- }
-
- /**
- * Return the parent of the given node
- */
- public Object getParent(Object element)
- {
- if (element instanceof ISystemProfile)
-// return SystemResourceManager.getRemoteSystemsProject();
- return null;
- ISystemViewElementAdapter adapter = getSystemViewAdapter(element);
- if (adapter != null)
- return adapter.getParent(element);
- return super.getParent(element);
- }
-
- /**
- * Return true if given element has children.
- */
- public boolean hasChildren(Object element)
- {
- if (element instanceof IContextObject)
- {
- element = ((IContextObject)element).getModelObject();
- }
- boolean children = false;
- if (element instanceof IProject)
- children = (getChildren(element).length > 0);
- else
- {
- ISystemViewElementAdapter adapter = getSystemViewAdapter(element);
- if (adapter != null)
- children = adapter.hasChildren((IAdaptable)element);
- else
- children = super.hasChildren(element);
- }
- /* debug info
- String name = element.getClass().getName();
- if (element instanceof SystemTeamViewSubSystemConfigurationNode)
- {
- SystemTeamViewSubSystemConfigurationNode ssfNode = (SystemTeamViewSubSystemConfigurationNode)element;
- name = ssfNode.getParentCategory().getLabel() + "." + ssfNode.getSubSystemConfiguration().getName();
- }
- else if (element instanceof SystemTeamViewCategoryNode)
- {
- SystemTeamViewCategoryNode catNode = (SystemTeamViewCategoryNode)element;
- name = catNode.getLabel();
- }
- System.out.println(Integer.toString(counter++)+". In hasChildren for object: '"+name+"', returned "+children);
- */
- return children;
- }
-
- /**
- * Return the roots elements to display in the tree initially.
- * For us, this is the RSE singleton project.
- */
- public Object[] getElements(Object element)
- {
- if (inputProvider == null)
- return new Object[0];
- else
- return inputProvider.getRoots(); // returns our single RSE project
- }
-
- /**
- * View is going away: dispose of any local resources
- */
- public void dispose()
- {
- super.dispose();
- // we need to remove this provider from the Workspace
- // ResourceChange listeners list. The parent dispose will
- // not do this for us.
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- }
-
- /**
- * This hooks this content provider as an IResourceChangeListener.<br>
- * We will not use parent code.
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- this.viewer = viewer;
-
- // TODO DKM - replace this with appropriate thing
- // super.viewer = viewer;
-
- // TODO DKM - get rid of inputChanged. I put it here temporarily so that there's a way to set super.viewer in 3.0
- super.inputChanged(viewer, oldInput, newInput);
-
- //System.out.println("inside inputChanged. oldInput = " + oldInput + ", newInput = " + newInput);
- if (newInput != null)
- {
- if (newInput instanceof SystemTeamViewInputProvider)
- {
- inputProvider = (SystemTeamViewInputProvider)newInput;
- /*
- getResourceDeltaHandler().registerTreeViewer((TreeViewer)viewer);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
- //IResourceChangeEvent.POST_AUTO_BUILD
- //IResourceChangeEvent.PRE_AUTO_BUILD
- IResourceChangeEvent.POST_CHANGE
- // IResourceChangeEvent.PRE_CLOSE
- //| IResourceChangeEvent.PRE_DELETE
- //| IResourceChangeEvent.POST_AUTO_BUILD
- );
- */
- }
- }
- }
-
- /**
- * Returns the implementation of ISystemViewElement for the given
- * object. Returns null if the adapter is not defined or the
- * object is not adaptable.
- */
- protected ISystemViewElementAdapter getSystemViewAdapter(Object o)
- {
- ISystemViewElementAdapter adapter = null;
- if (o == null)
- {
- SystemBasePlugin.logWarning("ERROR: null passed to getAdapter in SystemTeamViewContentProvider"); //$NON-NLS-1$
- return null;
- }
- if (!(o instanceof IAdaptable))
- adapter = (ISystemViewElementAdapter)Platform.getAdapterManager().getAdapter(o,ISystemViewElementAdapter.class);
- else
- adapter = (ISystemViewElementAdapter)((IAdaptable)o).getAdapter(ISystemViewElementAdapter.class);
- //if (adapter == null)
- // RSEUIPlugin.logWarning("ADAPTER IS NULL FOR ELEMENT OF TYPE: " + o.getClass().getName());
- if ((adapter!=null) && (viewer != null))
- {
- Shell shell = null;
- if (viewer instanceof ISystemShellProvider)
- shell = ((ISystemShellProvider)viewer).getShell();
- else if (viewer != null)
- shell = viewer.getControl().getShell();
- if (shell != null)
- adapter.setShell(shell);
- adapter.setViewer(viewer);
- if (viewer.getInput() instanceof ISystemViewInputProvider)
- {
- ISystemViewInputProvider inputProvider = (ISystemViewInputProvider)viewer.getInput();
- adapter.setInput(inputProvider);
- }
- }
- else if (viewer == null)
- SystemBasePlugin.logWarning("VIEWER IS NULL FOR SystemTeamViewContentProvider"); //$NON-NLS-1$
- return adapter;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewInputProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewInputProvider.java
deleted file mode 100644
index c4c7a0eb8..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewInputProvider.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * David Dykstal (IBM) - [189858] Removed the remote systems project in the team view
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- * Martin Oberhuber (Wind River) - [218524][api] Remove deprecated ISystemViewInputProvider#getShell()
- * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.IPropertySet;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.internal.core.model.SystemProfileManager;
-
-
-/**
- * Represents the input to the team viewer.
- * For now, this really doesn't do much since we always list the same thing.
- */
-public class SystemTeamViewInputProvider implements IAdaptable, ISystemViewInputProvider
-{
- private Viewer viewer;
-
- /**
- * Constructor for SystemTeamViewInputProvider.
- */
- public SystemTeamViewInputProvider()
- {
- super();
- }
-
- /**
- * Return the roots to display in the team viewer.
- * This is simply the RSE singleton project
- */
- public Object[] getRoots()
- {
- ISystemProfile[] roots = SystemProfileManager.getDefault().getSystemProfiles();
- return roots;
- }
-
- /**
- * This is the method required by the IAdaptable interface.
- * Given an adapter class type, return an object castable to the type, or
- * null if this is not possible.
- */
- public Object getAdapter(Class adapterType)
- {
- return Platform.getAdapterManager().getAdapter(this, adapterType);
- }
-
- // ----------------------------------------
- // Methods from ISystemViewInputProvider...
- // ----------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#getSystemViewRoots()
- */
- public Object[] getSystemViewRoots()
- {
- return getRoots();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#hasSystemViewRoots()
- */
- public boolean hasSystemViewRoots()
- {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#showingConnections()
- */
- public boolean showingConnections()
- {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#getConnectionChildren(org.eclipse.rse.ui.model.IHost)
- */
- public Object[] getConnectionChildren(IHost selectedConnection)
- {
- IPropertySet[] propertySets = selectedConnection.getPropertySets();
- if (null == propertySets || propertySets.length == 0)
- {
- return new SystemTeamViewPropertySetNode[0];
- }
- List nodes = new ArrayList();
- for (int i = 0; i < propertySets.length; i++) {
- nodes.add(new SystemTeamViewPropertySetNode(selectedConnection, propertySets[i]));
- }
- SystemTeamViewPropertySetNode[] result = new SystemTeamViewPropertySetNode[nodes.size()];
- nodes.toArray(result);
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#hasConnectionChildren(org.eclipse.rse.ui.model.IHost)
- */
- public boolean hasConnectionChildren(IHost selectedConnection)
- {
- IPropertySet[] sets = selectedConnection.getPropertySets();
- if (sets == null || sets.length == 0){
- return false;
- }
- else {
- return true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#setViewer(org.eclipse.jface.viewers.Viewer)
- */
- public void setViewer(Object viewer)
- {
- this.viewer = (Viewer)viewer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.ui.view.ISystemViewInputProvider#getViewer()
- */
- public Object getViewer()
- {
- return viewer;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewLabelProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewLabelProvider.java
deleted file mode 100644
index 1659eeccc..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewLabelProvider.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemViewInputProvider;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.model.ISystemShellProvider;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-
-/**
- * Base label provider for System Team View part
- */
-public class SystemTeamViewLabelProvider extends LabelProvider
-{
-
- public static final String Copyright =
- "(C) Copyright IBM Corp. 2002, 2003. All Rights Reserved."; //$NON-NLS-1$
-
- // Used to grab Workbench standard icons.
- private WorkbenchLabelProvider aWorkbenchLabelProvider = new WorkbenchLabelProvider();
- private Viewer viewer;
- /**
- * The cache of images that have been dispensed by this provider.
- * Maps ImageDescriptor->Image.
- */
- private Map imageTable = new Hashtable(40);
-
- /**
- * Constructor
- */
- public SystemTeamViewLabelProvider(Viewer viewer)
- {
- super();
- this.viewer = viewer;
- }
- /**
- * Get the image to display
- */
- public Image getImage(Object element)
- {
- Image image = null;
-
- if (element instanceof ISystemProfile)
- {
- ISystemProfile profile = (ISystemProfile)element;
- if (RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName()))
- return RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_PROFILE_ACTIVE_ID);
- else
- return RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_PROFILE_ID);
- }
-
- // If we have a project, return the resource project images.
- else if (element instanceof IProject)
- {
- Image projectImage = aWorkbenchLabelProvider.getImage(element);
- return projectImage;
- }
-
- // User system view element adapter
- ISystemViewElementAdapter adapter = getSystemViewAdapter(element);
- if (adapter != null)
- {
- //return adapter.getImage(element);
- ImageDescriptor descriptor = adapter.getImageDescriptor(element);
- if (descriptor != null)
- {
- return getImageFromImageDescriptor(descriptor);
- }
- }
-
- // use Workbench stuff.
- image = aWorkbenchLabelProvider.getImage(element);
- if (image != null)
- {
- return image;
- }
-
- // all failed, use parent code.
- return super.getImage(element);
- }
- /**
- * Turn image descriptor into image
- */
- private Image getImageFromImageDescriptor(ImageDescriptor descriptor)
- {
- if (descriptor == null)
- return null;
- Image image = (Image) imageTable.get(descriptor);
- if (image == null)
- {
- image = descriptor.createImage();
- imageTable.put(descriptor, image);
- }
- return image;
-
- }
-
- /**
- * Get the label to display
- */
- public String getText(Object element)
- {
- ISystemViewElementAdapter adapter = getSystemViewAdapter(element);
- if (adapter != null)
- return adapter.getText(element);
-
- // If we have a project, return the resource project images.
- if (element instanceof IProject)
- {
- return ((IProject)element).getName();
- }
- // use Workbench stuff.
- String text = aWorkbenchLabelProvider.getText(element);
- if (text.length() > 0)
- return text;
-
- // all failed, use parent code.
- return super.getText(element);
- }
-
- /**
- * Dispose of images created here.<br>
- */
- public void dispose()
- {
- // The following we got from WorkbenchLabelProvider
- if (imageTable != null)
- {
- Collection imageValues = imageTable.values();
- if (imageValues!=null)
- {
- Iterator images = imageValues.iterator();
- if (images!=null)
- while (images.hasNext())
- ((Image)images.next()).dispose();
- imageTable = null;
- }
- }
- }
-
- /**
- * Returns the implementation of ISystemViewElement for the given
- * object. Returns null if the adapter is not defined or the
- * object is not adaptable.
- */
- protected ISystemViewElementAdapter getSystemViewAdapter(Object o)
- {
- ISystemViewElementAdapter adapter = null;
- if (o == null)
- {
- SystemBasePlugin.logWarning("ERROR: null passed to getAdapter in SystemTeamViewLabelProvider"); //$NON-NLS-1$
- return null;
- }
- if (!(o instanceof IAdaptable))
- adapter = (ISystemViewElementAdapter)Platform.getAdapterManager().getAdapter(o,ISystemViewElementAdapter.class);
- else
- adapter = (ISystemViewElementAdapter)((IAdaptable)o).getAdapter(ISystemViewElementAdapter.class);
- //if (adapter == null)
- // RSEUIPlugin.logWarning("ADAPTER IS NULL FOR ELEMENT OF TYPE: " + o.getClass().getName());
- if ((adapter!=null) && (viewer != null))
- {
- Shell shell = null;
- if (viewer instanceof ISystemShellProvider)
- shell = ((ISystemShellProvider)viewer).getShell();
- else if (viewer != null)
- shell = viewer.getControl().getShell();
- if (shell != null)
- adapter.setShell(shell);
- adapter.setViewer(viewer);
- if (viewer.getInput() instanceof ISystemViewInputProvider)
- {
- ISystemViewInputProvider inputProvider = (ISystemViewInputProvider)viewer.getInput();
- adapter.setInput(inputProvider);
- }
- }
- else if (viewer == null)
- SystemBasePlugin.logWarning("VIEWER IS NULL FOR SystemTeamViewLabelProvider"); //$NON-NLS-1$
- return adapter;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewMakeActiveProfileAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewMakeActiveProfileAction.java
deleted file mode 100644
index bfc311051..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewMakeActiveProfileAction.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemProfileManager;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.internal.core.model.SystemProfileManager;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.actions.SystemBaseAction;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * The action allows users to activate all selected profiles
- */
-public class SystemTeamViewMakeActiveProfileAction extends SystemBaseAction
-
-{
-
- /**
- * Constructor
- */
- public SystemTeamViewMakeActiveProfileAction(Shell parent) {
- super(SystemResources.ACTION_PROFILE_MAKEACTIVE_LABEL, SystemResources.ACTION_PROFILE_MAKEACTIVE_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptor(
- ISystemIconConstants.ICON_SYSTEM_MAKEPROFILEACTIVE_ID), parent);
- allowOnMultipleSelection(true);
- setContextMenuGroup(ISystemContextMenuConstants.GROUP_CHANGE);
- setHelp(RSEUIPlugin.HELPPREFIX + "ActionMakeActive"); //$NON-NLS-1$
- }
-
- /**
- * Here we decide whether to enable ths action or not. We enable it
- * if every selected object is a profile, and if its not the case
- * that every selected profile is already active.
- * @see SystemBaseAction#updateSelection(IStructuredSelection)
- */
- public boolean updateSelection(IStructuredSelection selection) {
- ISystemProfileManager manager = SystemProfileManager.getDefault();
- ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
- boolean enabled = false;
- if (!getSelection().isEmpty()) {
- enabled = true;
- Object currsel = getFirstSelection();
- while (currsel != null && enabled) {
- if (currsel instanceof ISystemProfile) {
- ISystemProfile profile = (ISystemProfile) currsel;
- if (profile.isActive() || profile == defaultProfile) {
- enabled = false;
- }
- } else {
- enabled = false;
- }
- currsel = getNextSelection();
- }
- }
- return enabled;
- }
-
- /**
- * This is the method called when the user selects this action.
- * It walks through all the selected profiles and make them all active
- */
- public void run() {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- ISystemProfile profile = (ISystemProfile) getFirstSelection();
- while (profile != null) {
- sr.setSystemProfileActive(profile, true);
- profile = (ISystemProfile) getNextSelection();
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewMakeInActiveProfileAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewMakeInActiveProfileAction.java
deleted file mode 100644
index 6f25c2603..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewMakeInActiveProfileAction.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemProfileManager;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.internal.core.model.SystemProfileManager;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.actions.SystemBaseAction;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * The action allows users to de-activate all selected profiles
- */
-public class SystemTeamViewMakeInActiveProfileAction extends SystemBaseAction
-
-{
-
- /**
- * Constructor
- */
- public SystemTeamViewMakeInActiveProfileAction(Shell parent) {
- super(SystemResources.ACTION_PROFILE_MAKEINACTIVE_LABEL, SystemResources.ACTION_PROFILE_MAKEINACTIVE_TOOLTIP, RSEUIPlugin.getDefault().getImageDescriptor(
- ISystemIconConstants.ICON_SYSTEM_MAKEPROFILEINACTIVE_ID), parent);
- allowOnMultipleSelection(true);
- setContextMenuGroup(ISystemContextMenuConstants.GROUP_CHANGE);
- setHelp(RSEUIPlugin.HELPPREFIX + "ActionMakeInactive"); //$NON-NLS-1$
- }
-
- /**
- * Here we decide whether to enable ths action or not. We enable it
- * if every selected object is a profile, and if its not the case
- * that every selected profile is already inactive.
- * @see SystemBaseAction#updateSelection(IStructuredSelection)
- */
- public boolean updateSelection(IStructuredSelection selection) {
- ISystemProfileManager manager = SystemProfileManager.getDefault();
- ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
- boolean enabled = false;
- if (!getSelection().isEmpty()) {
- enabled = true;
- Object currsel = getFirstSelection();
- while (currsel != null && enabled) {
- if (currsel instanceof ISystemProfile) {
- ISystemProfile profile = (ISystemProfile) currsel;
- if (!profile.isActive() || profile == defaultProfile) {
- enabled = false;
- }
- } else {
- enabled = false;
- }
- currsel = getNextSelection();
- }
- }
- return enabled;
- }
-
- /**
- * This is the method called when the user selects this action.
- * It walks through all the selected profiles and make them all inactive
- */
- public void run() {
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- ISystemProfile profile = (ISystemProfile) getFirstSelection();
- while (profile != null) {
- sr.setSystemProfileActive(profile, false);
- profile = (ISystemProfile) getNextSelection();
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPart.java
deleted file mode 100644
index 021778706..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPart.java
+++ /dev/null
@@ -1,1585 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * David Dykstal (IBM) - [189858] Removed the remote systems project in the team view
- * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands
- * API to the user actions plugin
- * Rupen Mardirossian (IBM) - [187741] Implemented the handleDoubleClick method
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
- * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.SameShellProvider;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.SystemResourceManager;
-import org.eclipse.rse.core.events.ISystemModelChangeEvent;
-import org.eclipse.rse.core.events.ISystemModelChangeEvents;
-import org.eclipse.rse.core.events.ISystemModelChangeListener;
-import org.eclipse.rse.core.filters.ISystemFilter;
-import org.eclipse.rse.core.filters.ISystemFilterPool;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemProfileManager;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.actions.SystemCollapseAllAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonSelectAllAction;
-import org.eclipse.rse.internal.ui.actions.SystemNewProfileAction;
-import org.eclipse.rse.internal.ui.actions.SystemSubMenuManager;
-import org.eclipse.rse.internal.ui.actions.SystemTeamReloadAction;
-import org.eclipse.rse.internal.ui.view.ISystemMementoConstants;
-import org.eclipse.rse.internal.ui.view.SystemViewMenuListener;
-import org.eclipse.rse.internal.ui.view.SystemViewPart;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemDeleteTarget;
-import org.eclipse.rse.ui.ISystemRenameTarget;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.actions.ISystemAction;
-import org.eclipse.rse.ui.messages.ISystemMessageLine;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.rse.ui.view.IRSEViewPart;
-import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
-import org.eclipse.rse.ui.view.SystemAdapterHelpers;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.part.ISetSelectionTarget;
-import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.Bundle;
-
-
-/**
- * The viewer and view part for the Team view
- */
-public class SystemTeamViewPart
- extends ViewPart
- implements ISetSelectionTarget, ISelectionProvider, ISystemModelChangeListener,
- ISystemMessageLine, ISelectionChangedListener,
- ISystemDeleteTarget, ISystemRenameTarget, IRSEViewPart
-{
-
- private boolean menuListenerAdded;
- public static final String ID = "org.eclipse.rse.ui.view.teamView"; //$NON-NLS-1$
-
- private SystemTeamViewInputProvider input = null;
- private SystemTeamView treeViewer = null;
- //private FrameList frameList = null;
- private IStatusLineManager statusLine = null;
- private String message, errorMessage;
- private SystemMessage sysErrorMessage;
-
- // selectionChangedListeners
- private ListenerList selectionChangedListeners = new ListenerList(ListenerList.IDENTITY);
-
- // context menu actions for project...
- protected SystemTeamReloadAction reloadRSEAction;
- protected SystemNewProfileAction newProfileAction;
- // common context menu actions...
- protected SystemCommonDeleteAction deleteAction;
- protected PropertyDialogAction propertyDialogAction;
- protected SystemTeamViewRefreshAllAction toolBarRefreshAllAction, menuRefreshAllAction;
- protected SystemCollapseAllAction collapseAllAction;
-
-
- // remember-state variables...
- private IMemento fMemento;
- // state...
- static final String TAG_RELEASE= "release"; //$NON-NLS-1$
- static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
- static final String TAG_EXPANDED_TO= "expandedTo"; //$NON-NLS-1$
- static final String TAG_EXPANDED= "expanded"; //$NON-NLS-1$
- static final String TAG_ELEMENT= "element"; //$NON-NLS-1$
- static final String TAG_PATH= "path"; //$NON-NLS-1$
- static final String TAG_INPUT= "svInput"; //$NON-NLS-1$
- static final String TAG_VERTICAL_POSITION= "verticalPosition"; //$NON-NLS-1$
- static final String TAG_HORIZONTAL_POSITION= "horizontalPosition"; //$NON-NLS-1$
- static final String MEMENTO_DELIM = "///"; //$NON-NLS-1$
-
- /**
- * Remove a selection change listener
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener)
- {
- selectionChangedListeners.remove(listener);
- }
- /**
- * Add a selection change listener
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener)
- {
- selectionChangedListeners.add(listener);
- }
-
- /**
- * Returns selection for the tree view
- */
- public ISelection getSelection()
- {
- return treeViewer.getSelection();
- }
-
- public void setSelection(ISelection selection)
- {
- treeViewer.setSelection(selection);
- }
-
- /**
- * Returns the tree viewer selection as a structured selection
- */
- public IStructuredSelection getStructuredSelection()
- {
- // we know we have a ss.
- return (IStructuredSelection) (treeViewer.getSelection());
- }
-
- public TreeViewer getTreeViewer() {
- return treeViewer;
- }
-
- public Viewer getRSEViewer()
- {
- return treeViewer;
- }
-
- /**
- * We are getting focus
- */
- public void setFocus()
- {
- if (treeViewer == null)
- return;
- Tree tree = treeViewer.getTree();
- if (tree != null)
- treeViewer.getTree().setFocus();
- }
-
- /**
- * Create the viewer to go in this view part.
- */
- public void createPartControl(Composite parent)
- {
- treeViewer =
- //new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- new SystemTeamView(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, this);
- treeViewer.setUseHashlookup(true);
- treeViewer.setContentProvider(new SystemTeamViewContentProvider());
- treeViewer.setLabelProvider(new SystemTeamViewLabelProvider(treeViewer));
-
- treeViewer.setInput(getInput());
-
- addTreeViewerListeners();
-
- // create the frame list.
- //frameList = createFrameList();
-
- // now update title of the view part.
- updateTitle();
-
- // Handle menus:
- // think about menu manager id later.
- MenuManager menuMgr = new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
- treeViewer.getTree().setMenu(menu);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- fillContextMenu(manager);
- addMenuListener(manager);
- }
- });
- getSite().registerContextMenu(menuMgr, treeViewer);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- scrubOtherContributions(manager);
- }
- });
- // important to add our listener after registering, so we are called second!
- // This gives us the opportunity to scrub the contributions added by others, to screen out
- // non-team additions.
- /*
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- SystemTeamViewPart.this.fillContextMenu(manager);
- }
- });*/
-
- // Fill the action bars and update the global action handlers'
- // enabled state to match the current selection. We pass the selection
- // based on the iSeries object model. The action group will handle
- // delegating the correct object model to the actions.
- fillActionBars(getViewSite().getActionBars());
- //updateActionBars(getStructuredSelection());
-
- // this is a must here to get Properties Pages to work.
- getSite().setSelectionProvider(treeViewer);
- //getSite().setSelectionProvider(this);
-
- // Update status line.
- statusLine = getViewSite().getActionBars().getStatusLineManager();
- //updateStatusLine(getStructuredSelection());
-
- // we need to refresh viewer when page gets activated for Marker updates
- //pageListener = new CurrentPageListener(getSite().getPage());
- //getSite().getWorkbenchWindow().addPageListener(pageListener);
-
- // update F1 help
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IF1HelpContextID.NAV01);
-
- RSECorePlugin.getTheSystemRegistry().addSystemModelChangeListener(this);
-
- treeViewer.setAutoExpandLevel(2); // dang, it doesn't work!
-
- // ----------------------
- // Restore previous state
- // ----------------------
- if (fMemento != null)
- restoreState(fMemento);
- fMemento= null;
- }
-
- private void addMenuListener(IMenuManager menu) {
- if (!menuListenerAdded)
- {
- if (menu instanceof MenuManager)
- {
- Menu m = ((MenuManager)menu).getMenu();
- if (m != null)
- {
- menuListenerAdded = true;
- SystemViewMenuListener ml = new SystemViewMenuListener();
- ml.setShowToolTipText(true, this);
- m.addMenuListener(ml);
- }
- }
- }
- }
-
- // -------------------------------------------
- // MEMENTO SUPPORT (SAVING/RESTORING STATE)...
- // -------------------------------------------
- /**
- * Initializes this view with the given view site. A memento is passed to
- * the view which contains a snapshot of the views state from a previous
- * session. Where possible, the view should try to recreate that state
- * within the part controls.
- * <p>
- * The parent's default implementation will ignore the memento and initialize
- * the view in a fresh state. Subclasses may override the implementation to
- * perform any state restoration as needed.
- */
- public void init(IViewSite site,IMemento memento) throws PartInitException
- {
- super.init(site,memento);
- fMemento = memento;
- //System.out.println("INSIDE INIT");
- }
-
- /**
- * Adds the listeners to the tree viewer.
- */
- protected void addTreeViewerListeners()
- {
- treeViewer.addDoubleClickListener(new IDoubleClickListener()
- {
- public void doubleClick(DoubleClickEvent event) {
- handleDoubleClick(event);
- }
- });
-
- //System.out.println("Add key listener");
-
- treeViewer.getControl().addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- handleKeyReleased(e);
- } });
- treeViewer.getControl().addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- handleKeyPressed(e);
- } });
-
- treeViewer.addSelectionChangedListener(this);
-
- treeViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- handleOpen(event);
- }
- });
- }
-
-
- /**
- * Returns the shell to use for opening dialogs.
- * Used in this class, and in the actions.
- */
- public Shell getShell()
- {
- return getViewSite().getShell();
- }
-
- /**
- * Handles double-click in viewer. It is responsible for expanding
- * and collapsing nodes in the tree.
- * @param event the double click event to handle.
- * Contains the selection on which to operate.
- */
- private void handleDoubleClick(DoubleClickEvent event) {
- ITreeSelection s = (ITreeSelection) event.getSelection();
- Object element = s.getFirstElement(); // double-click only has 0 or 1 elements
- if (element != null) {
- ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) element).getAdapter(ISystemViewElementAdapter.class);
- if (adapter != null) {
- if (adapter.hasChildren((IAdaptable) element)) {
- // Get the path for the element and use it for setting expanded state,
- // so the proper TreeItem is expanded/collapsed
- TreePath[] paths = s.getPathsFor(element);
- if (paths != null && paths.length > 0 && paths[0] != null) {
- TreePath elementPath = paths[0];
- if (treeViewer.getExpandedState(elementPath)) {
- treeViewer.collapseSelected();
- } else {
- treeViewer.expandSelected();
- }
- }
- } else {
- adapter.handleDoubleClick(element);
- }
- }
- }
- }
-
- /**
- * Handles an open event from the viewer.
- * Opens an editor on the selected file.
- */
- protected void handleOpen(OpenEvent event)
- {
- }
-
- /**
- * Handles key events in viewer.<br>
- * This is needed for various keys (eg: delete key) and for model dump.
- */
- private void handleKeyReleased(KeyEvent event)
- {
- //System.out.println("in handleKeyPressed. keyCode == SWT.F5? " + (event.keyCode==SWT.F5) + ", keyCode: "+event.keyCode);
- if (event.keyCode == SWT.F5)
- {
- getRefreshAllToolbarAction(getStructuredSelection()).run();
- }
- }
- /**
- * Handles key events in viewer.<br>
- * This is needed for various keys (eg: delete key) and for model dump.
- */
- private void handleKeyPressed(KeyEvent event)
- {
- //System.out.println("in handleKeyPressed. keyCode == SWT.F5? " + (event.keyCode==SWT.F5) + ", keyCode: "+event.keyCode);
- IStructuredSelection selection = (IStructuredSelection)getSelection();
- /*
- * DKM - taking this out since the delete key should be handled by the retargetable action
- *
- if ((event.character == SWT.DEL) && (event.stateMask == 0) && (selection.size()>0) )
- {
- if (showDelete() && canDelete())
- {
- SystemCommonDeleteAction dltAction = (SystemCommonDeleteAction)getDeleteAction(selection);
- dltAction.setShell(getShell());
- dltAction.setSelection(getSelection());
- dltAction.setViewer(getViewer());
- dltAction.run();
- }
- }
- else
- */
- if ((event.character == '-') && (event.stateMask == SWT.CTRL) )
- {
- SystemCollapseAllAction collapseAllAction = getCollapseAllAction();
- collapseAllAction.setShell(getShell());
- collapseAllAction.run();
- }
- else if ((event.character == '-') && (selection.size()>0) )
- {
- //System.out.println("Inside Ctrl+- processing");
- treeViewer.collapseSelected();
- }
- else if ((event.character == '+') && (selection.size()>0) )
- {
- //System.out.println("Inside Ctrl++ processing");
- treeViewer.expandSelected();
- }
-
- }
-
- /**
- * Reveal and selects the passed selection in viewer.<br>
- */
- public void selectReveal(ISelection selection)
- {
- if (!(selection instanceof StructuredSelection))
- return;
- StructuredSelection ssel = (StructuredSelection)selection;
- if (!ssel.isEmpty()) {
- // select and reveal the item
- treeViewer.setSelection(ssel, true);
- }
- }
-
- /**
- * Called when the context menu is about to open.
- */
- private void fillContextMenu(IMenuManager menu)
- {
- SystemMenuManager ourMenu = new SystemMenuManager(menu);
-
- // Populate with our stuff...
- IStructuredSelection selection = getStructuredSelection();
- Object firstSelection = selection.getFirstElement();
- createStandardGroups(menu);
- if (firstSelection instanceof IProject)
- {
- // Scrub unrelated menu items
- if (selection.size() == 1)
- fillProjectContextMenu(ourMenu, selection);
- }
- else
- {
- ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(firstSelection, treeViewer);
- if (adapter != null)
- {
- if ((firstSelection instanceof SystemTeamViewSubSystemConfigurationNode) ||
- // FIXME - compile actions separate now (firstSelection instanceof SystemTeamViewCompileTypeNode) ||
- (firstSelection instanceof ISystemProfile))
- {
- addActions(ourMenu, selection);
- }
- else if (firstSelection instanceof ISystemFilterPool)
- {
- //SystemTestingAction testAction = new SystemTestingAction(getShell(), this);
- //testAction.setSelection(getSelection());
- //ourMenu.add(ISystemContextMenuConstants.GROUP_CHANGE, testAction);
- }
- }
- }
- // whale through all actions, updating shell and selection
- IContributionItem[] items = menu.getItems();
- for (int idx=0; idx < items.length; idx++)
- {
- if ((items[idx] instanceof ActionContributionItem) &&
- (((ActionContributionItem)items[idx]).getAction() instanceof ISystemAction))
- {
- ISystemAction item = (ISystemAction) ( ((ActionContributionItem)items[idx]).getAction() );
- try{
- item.setInputs(getShell(), getViewer(), selection);
- } catch (Exception e)
- {
- SystemBasePlugin.logError("Error configuring action " + item.getClass().getName(),e); //$NON-NLS-1$
- System.err.println("Error configuring action " + item.getClass().getName()); //$NON-NLS-1$
- }
- }
- else if (items[idx] instanceof SystemSubMenuManager)
- {
- SystemSubMenuManager item = (SystemSubMenuManager)items[idx];
- item.setInputs(getShell(), getViewer(), selection);
- }
- }
- PropertyDialogAction pdAction = getPropertyDialogAction(selection);
- if (pdAction.isApplicableForSelection())
- menu.appendToGroup(ISystemContextMenuConstants.GROUP_PROPERTIES, pdAction);
- }
-
- /**
- * Let each object add their own actions...
- * @param ourMenu the menu for the team view
- * @param selection the current selection in the view
- */
- protected void addActions(SystemMenuManager ourMenu, IStructuredSelection selection)
- {
- // ADAPTER SPECIFIC ACTIONS
- Iterator elements= selection.iterator();
- Hashtable adapters = new Hashtable();
- while (elements.hasNext())
- {
- Object element= elements.next();
- ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(element, treeViewer);
- if (adapter != null)
- adapters.put(adapter,element); // want only unique adapters
- }
- Enumeration uniqueAdapters = adapters.keys();
- Shell shell = getShell();
- while (uniqueAdapters.hasMoreElements())
- {
- ISystemViewElementAdapter nextAdapter = (ISystemViewElementAdapter)uniqueAdapters.nextElement();
- nextAdapter.addActions(ourMenu,selection,shell,ISystemContextMenuConstants.GROUP_ADAPTERS);
- //if (nextAdapter instanceof AbstractSystemViewAdapter)
- // ((AbstractSystemViewAdapter)nextAdapter).addCommonRemoteActions(ourMenu,selection,shell,ISystemContextMenuConstants.GROUP_ADAPTERS);
- }
-
- // wail through all actions, updating shell and selection
- IContributionItem[] items = ourMenu.getMenuManager().getItems();
- for (int idx=0; idx < items.length; idx++)
- {
- if ((items[idx] instanceof ActionContributionItem) &&
- (((ActionContributionItem)items[idx]).getAction() instanceof ISystemAction))
- {
- ISystemAction item = (ISystemAction) ( ((ActionContributionItem)items[idx]).getAction() );
- try{
- item.setInputs(getShell(), treeViewer, selection);
- } catch (Exception e)
- {
- SystemBasePlugin.logError("Error configuring action " + item.getClass().getName(),e); //$NON-NLS-1$
- System.out.println("Error configuring action " + item.getClass().getName()); //$NON-NLS-1$
- }
- }
- else if (items[idx] instanceof SystemSubMenuManager)
- {
- SystemSubMenuManager item = (SystemSubMenuManager)items[idx];
- item.setInputs(getShell(), treeViewer, selection);
- }
- }
- }
-
- /**
- * Creates the Systems plugin standard groups in a context menu.
- */
- public void createStandardGroups(IMenuManager menu)
- {
- //if (!menu.isEmpty())
- // return;
- // simply sets partitions in the menu, into which actions can be directed.
- // Each partition can be delimited by a separator (new Separator) or not (new GroupMarker).
- // Deleted groups are not used yet.
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_NEW)); // new->
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_NEW_NONCASCADING)); // new stuff
- /*
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_GOTO)); // goto into, go->
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_EXPANDTO)); // expand to->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_EXPAND)); // expand, collapse
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_OPEN)); // open xxx
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_OPENWITH)); // open with->
- menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_BROWSEWITH)); // open with->
- */
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_WORKWITH)); // work with->
- 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 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
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_STARTSERVER)); // Start Remote Server cascading menu
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_IMPORTEXPORT)); // get or put actions
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_ADAPTERS)); // actions queried from adapters
- */
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_ADDITIONS)); // user or BP/ISV additions
- //menu.add(new Separator(ISystemContextMenuConstants.GROUP_VIEWER_SETUP)); // ? Probably View->by xxx, yyy
- //menu.add(new Separator(ISystemContextMenuConstants.GROUP_TEAM)); // Team
- menu.add(new Separator(ISystemContextMenuConstants.GROUP_PROPERTIES)); // Properties
- }
-
-
- /**
- * Fill context menu for IProjects
- */
- private void fillProjectContextMenu(SystemMenuManager menu, IStructuredSelection selection)
- {
- menu.add(ISystemContextMenuConstants.GROUP_BUILD,getRefreshAllMenuAction(selection));
- menu.add(ISystemContextMenuConstants.GROUP_BUILD,getReloadRSEAction(selection));
- menu.add(ISystemContextMenuConstants.GROUP_NEW,getNewProfileAction(selection));
- //menu.add(new Separator(ISystemContextMenuConstants.GROUP_PROPERTIES));
- //menu.appendToGroup(ISystemContextMenuConstants.GROUP_PROPERTIES, getPropertyDialogAction(selection));
- }
-
- /**
- * Get the properties dialog action
- */
- private PropertyDialogAction getPropertyDialogAction(IStructuredSelection selection)
- {
- if (propertyDialogAction == null)
- propertyDialogAction = new PropertyDialogAction(new SameShellProvider(getShell()), treeViewer);
- propertyDialogAction.selectionChanged(selection);
- return propertyDialogAction;
- }
- /**
- * Get the reload RSE action for the context menu
- */
- private SystemTeamReloadAction getReloadRSEAction(IStructuredSelection selection)
- {
- boolean privateProfileStillExists = (RSECorePlugin.getTheSystemProfileManager().getDefaultPrivateSystemProfile() != null);
- if (reloadRSEAction == null)
- reloadRSEAction = new SystemTeamReloadAction(getShell());
- reloadRSEAction.setSelection(selection);
- if (privateProfileStillExists)
- reloadRSEAction.setEnabled(false);
- return reloadRSEAction;
- }
- /**
- * Get the refresh All action for the context menu
- */
- private SystemTeamViewRefreshAllAction getRefreshAllMenuAction(IStructuredSelection selection)
- {
- if (menuRefreshAllAction == null)
- menuRefreshAllAction = new SystemTeamViewRefreshAllAction(getShell(), this);
- menuRefreshAllAction.setSelection(selection);
- return menuRefreshAllAction;
- }
- /**
- * Get the refresh All action for the toolbar
- */
- private SystemTeamViewRefreshAllAction getRefreshAllToolbarAction(IStructuredSelection selection)
- {
- if (toolBarRefreshAllAction == null)
- toolBarRefreshAllAction = new SystemTeamViewRefreshAllAction(getShell(), this);
- toolBarRefreshAllAction.setSelection(selection);
- return toolBarRefreshAllAction;
- }
-
- /**
- * Get the profile adapter for a given profile
- */
- private SystemTeamViewProfileAdapter getProfileAdapter(ISystemProfile profile) {
- RSEUIPlugin plugin = RSEUIPlugin.getDefault();
-
- IAdapterFactory factory = plugin.getSystemViewAdapterFactory();
- SystemTeamViewProfileAdapter adapter = (SystemTeamViewProfileAdapter) factory.getAdapter(profile, SystemTeamViewProfileAdapter.class);
- return adapter;
- }
-
- /**
- * Get the New Profile action
- */
- private SystemNewProfileAction getNewProfileAction(IStructuredSelection selection)
- {
- if (newProfileAction == null)
- {
- newProfileAction = new SystemNewProfileAction(getShell(), false);
- newProfileAction.setViewer(getViewer());
- }
- newProfileAction.setSelection(selection);
- return newProfileAction;
- }
- /**
- * Rather than pre-defined this common action we wait until it is first needed,
- * for performance reasons.
- */
- protected IAction getDeleteAction(IStructuredSelection selection)
- {
- if (deleteAction == null)
- {
- deleteAction = new SystemCommonDeleteAction(getShell(),this);
- deleteAction.setViewer(getViewer());
- deleteAction.setHelp(RSEUIPlugin.HELPPREFIX+"actndlpr"); //$NON-NLS-1$
- deleteAction.setDialogHelp(RSEUIPlugin.HELPPREFIX+"ddltprfl"); //$NON-NLS-1$
- deleteAction.setPromptLabel(SystemResources.RESID_DELETE_PROFILES_PROMPT);
- }
- deleteAction.setSelection(selection);
- return deleteAction;
- }
-
- /**
- * Scrub the popup menu to remove everything but team-related stuff...
- */
- private void scrubOtherContributions(IMenuManager menuMgr) {
- IStructuredSelection selection = getStructuredSelection();
- Object firstSelection = selection.getFirstElement();
- if (firstSelection instanceof IProject) {
- boolean privateProfileStillExists = (RSECorePlugin.getTheSystemProfileManager().getDefaultPrivateSystemProfile() != null);
- IContributionItem items[] = menuMgr.getItems();
- if (items != null) {
- for (int idx = 0; idx < items.length; idx++) {
- IContributionItem item = items[idx];
- if (item.getId() != null) {
- if (!item.getId().equals("team.main") || privateProfileStillExists) menuMgr.remove(item); //$NON-NLS-1$
- }
- }
- }
- }
- }
-
- public void dispose()
- {
- RSECorePlugin.getTheSystemRegistry().removeSystemModelChangeListener(this);
- super.dispose();
- }
-
- /**
- * Return our viewer.
- */
- public TreeViewer getViewer()
- {
- return treeViewer;
- }
-
- /**
- * Updates the title text and title tool tip.
- * Called whenever the input of the viewer changes.
- */
- public void updateTitle()
- {
-// Object input = getTreeViewer().getInput();
-// String viewName = getConfigurationElement().getAttribute("name");
- setPartName(getTitle());
- setTitleToolTip(""); //$NON-NLS-1$
- }
-
- /**
- * Determines the input for the viewer. This is needed for the "Open
- * in New Window" action that sets the input to the workbench page,
- * and expects the viewers to use it.
- */
- protected IAdaptable getInput()
- {
- if (input == null)
- input = new SystemTeamViewInputProvider();
- return input;
- }
-
- /**
- * Adds the actions in this group and its subgroups to the action bars.
- */
- public void fillActionBars(IActionBars actionBars)
- {
- IStructuredSelection selection = getStructuredSelection();
- actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), getPropertyDialogAction(selection));
- SystemTeamViewRefreshAllAction refreshAllAction = getRefreshAllToolbarAction(selection);
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAllAction);
-
- actionBars.getToolBarManager().add(getNewProfileAction(selection));
- // now add the global Refresh action in the view tool bar.
- actionBars.getToolBarManager().add(refreshAllAction);
-
- actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getDeleteAction(selection));
-
- // add rename action
- SystemCommonRenameAction renameAction = new SystemCommonRenameAction(getShell(), this);
- renameAction.setViewer(getViewer());
- // renameAction.setSelection(selection);
- actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
-
- SystemCommonSelectAllAction selAllAction = new SystemCommonSelectAllAction(getShell(), treeViewer, treeViewer);
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selAllAction);
-
- actionBars.getToolBarManager().add(new Separator());
- actionBars.getToolBarManager().add(getCollapseAllAction());
-
- statusLine = actionBars.getStatusLineManager();
- }
-
- /**
- * Return the collapseAll action
- */
- protected SystemCollapseAllAction getCollapseAllAction()
- {
- if (collapseAllAction == null)
- {
- collapseAllAction = new SystemCollapseAllAction(getShell());
- collapseAllAction.setSelectionProvider(treeViewer);
- collapseAllAction.setViewer(treeViewer);
- collapseAllAction.setImageDescriptor(getNavigatorImageDescriptor("elcl16/collapseall.gif")); //$NON-NLS-1$
- // DKM - changed this icon from clcl16 since navigator no longer has it
- collapseAllAction.setHoverImageDescriptor(getNavigatorImageDescriptor("elcl16/collapseall.gif")); //$NON-NLS-1$
- }
- return collapseAllAction;
- }
-
- /**
- * Updates the actions which were added to the action bars.
- */
- public void updateActionBars(IStructuredSelection selection)
- {
- getPropertyDialogAction(selection);
- getRefreshAllToolbarAction(selection);
- getDeleteAction(selection);
- }
-
- /**
- * This is the method in your class that will be called when a resource in the
- * RSE model changes. You will be called after the resource is changed.
- * @see ISystemModelChangeEvent
- */
- public void systemModelResourceChanged(ISystemModelChangeEvent event)
- {
- int resourceType = event.getResourceType();
- boolean testMode = false;
- if ((event.getEventType() == ISystemModelChangeEvents.SYSTEM_RESOURCE_ALL_RELOADED) ||
- (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE))
- {
- getTreeViewer().refresh();
- treeViewer.updatePropertySheet();
- if (testMode && (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE))
- System.out.println("Profile change event of type: " + event.getEventType()); //$NON-NLS-1$
- }
- else if (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_FILTER)
- {
- if (testMode)
- System.out.println("Filter change event of type: " + event.getEventType()); //$NON-NLS-1$
- ISystemFilter filter = (ISystemFilter)event.getResource();
- ISystemFilterPool pool = filter.getParentFilterPool();
- if (pool == null) // maybe for transient filters?
- return;
- if (isModelObjectExpanded(pool)) // if parent is expanded...
- treeViewer.refresh(pool); // refresh the parent.
- }
- else if (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_FILTERPOOL)
- {
- if (testMode)
- System.out.println("Filter Pool change event of type: " + event.getEventType()); //$NON-NLS-1$
- ISystemFilterPool pool = (ISystemFilterPool)event.getResource();
- ISystemProfile profile = ((ISubSystemConfiguration)pool.getProvider()).getSystemProfile(pool);
- TreeItem filterCategoryItem = getCategoryNodeTreeItem(profile, SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS);
- if ((filterCategoryItem!=null) && filterCategoryItem.getExpanded())
- treeViewer.refresh(filterCategoryItem.getData());
- }
- else if (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_CONNECTION)
- {
- if (testMode)
- System.out.println("Connection change event of type: " + event.getEventType()); //$NON-NLS-1$
- IHost conn = (IHost)event.getResource();
- ISystemProfile profile = conn.getSystemProfile();
-
- TreeItem connCategoryItem = getCategoryNodeTreeItem(profile, SystemTeamViewCategoryNode.MEMENTO_CONNECTIONS);
- if ((connCategoryItem != null) && connCategoryItem.getExpanded())
- {
- treeViewer.refresh(connCategoryItem.getData());
- }
- }
- else if (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_SUBSYSTEM)
- {
- if (testMode)
- System.out.println("SubSystem change event of type: " + event.getEventType()); //$NON-NLS-1$
- }
-
-// FIXME - user actions separate now
-// else if (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_USERACTION)
-// {
-// if (testMode)
-// System.out.println("User Action change event of type: " + event.getEventType());
-// SystemUDActionElement action = (SystemUDActionElement)event.getResource();
-// ISystemProfile profile = action.getProfile();
-// TreeItem actionCategoryItem = getCategoryNodeTreeItem(profile, SystemTeamViewCategoryNode.MEMENTO_USERACTIONS);
-// if ((actionCategoryItem!=null) && actionCategoryItem.getExpanded())
-// {
-// // note if the updated action is currently selected, we lose that selection because
-// // when we save actions, their wrapper objects are recreated (yes, its bad but who
-// // has time to fix it?) and so the binary address of the old no longer exists.
-// // To circumvent we need to detect the situation and reselect the new one. But how to tell
-// // if one action is equal to another? Compare their xml element nodes.
-// ISelection s = getSelection();
-// boolean reselect = false;
-// if (s instanceof StructuredSelection)
-// {
-// Object firstSel = ((StructuredSelection)s).getFirstElement();
-// if (firstSel instanceof SystemUDActionElement)
-// if ( ((SystemUDActionElement)firstSel).getElement() ==
-// action.getElement() )
-// reselect = true;
-// }
-// // the problem we have here is refresh will cause yet another fresh set of SystemUDActionElement objects
-// // to be created! We really should fix that.
-//
-// //if (event.getEventType() != ISystemModelChangeEvents.SYSTEM_RESOURCE_CHANGED)
-// treeViewer.refresh(actionCategoryItem.getData());
-// // I tried this and update didn't update the label, damn.
-// //else
-// //{
-// //String[] allProps = {IBasicPropertyConstants.P_TEXT,IBasicPropertyConstants.P_IMAGE};
-// //treeViewer.update(actionCategoryItem.getData(), allProps);
-// //}
-// if (reselect)
-// treeViewer.setSelection(new StructuredSelection(action));
-// }
-// }
-// else if (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_NAMEDTYPE)
-// {
-// if (testMode)
-// System.out.println("Named Type change event of type: " + event.getEventType()); //$NON-NLS-1$
-// }
-
-// compile actions separate now
-// else if (resourceType == ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_COMPILECMD)
-// {
-// if (testMode)
-// System.out.println("Compile Command change event of type: " + event.getEventType());
-// SystemCompileCommand cmd = (SystemCompileCommand)event.getResource();
-// ISystemProfile profile = cmd.getParentType().getParentProfile().getProfile();
-// TreeItem actionCategoryItem = getCategoryNodeTreeItem(profile, SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS);
-// if ((actionCategoryItem!=null) && actionCategoryItem.getExpanded())
-// treeViewer.refresh(actionCategoryItem.getData());
-// }
- }
- /**
- * Return true if the given profile is expanded
- */
- private boolean isModelObjectExpanded(Object object)
- {
- TreeItem item = treeViewer.findTreeItem(object);
- return ((item != null) && item.getExpanded());
- }
- /**
- * Find a category node of a particular type, under the node of a given profile
- */
- private TreeItem getCategoryNodeTreeItem(ISystemProfile profile, String mementoKey)
- {
- TreeItem item = treeViewer.findTreeItem(profile);
- if ((item==null) || !item.getExpanded() )
- return null;
-
- TreeItem[] childItems = item.getItems();
- item = null;
- if (childItems != null)
- {
- boolean found = false;
- for (int idx=0; !found && (idx<childItems.length); idx++)
- {
- if (childItems[idx].getData() instanceof SystemTeamViewCategoryNode)
- {
- SystemTeamViewCategoryNode node = (SystemTeamViewCategoryNode)childItems[idx].getData();
- if ((node!=null) && node.getMementoHandle().equals(mementoKey))
- {
- found = true;
- item = childItems[idx];
- }
- }
- }
- }
- return item;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.ui.ISystemDeleteTarget#showDelete()
- */
- public boolean showDelete()
- {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.ui.ISystemDeleteTarget#canDelete()
- */
- public boolean canDelete() {
- boolean ok = false;
- IStructuredSelection selection = getStructuredSelection();
- if (!selection.isEmpty()) {
- ok = true;
- ISystemProfileManager manager = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager();
- ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
- for (Iterator z = selection.iterator(); z.hasNext() && ok;) {
- Object object = z.next();
- if (object instanceof ISystemProfile) {
- ISystemProfile profile = (ISystemProfile) object;
- if (profile == defaultProfile) {
- ok = false;
- }
- } else {
- ok = false;
- }
- }
- }
- return ok;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.ui.ISystemDeleteTarget#doDelete()
- */
- public boolean doDelete(IProgressMonitor monitor) {
- boolean ok = true;
- IStructuredSelection selection = getStructuredSelection();
- Iterator elements = selection.iterator();
- while (ok && elements.hasNext()) {
- ISystemProfile profile = (ISystemProfile) elements.next();
- try {
- SystemTeamViewProfileAdapter profileAdapter = getProfileAdapter(profile);
- ok = profileAdapter.doDelete(getShell(), profile, monitor);
- } catch (Exception exc) {
- String msg = "Exception deleting profile " + profile.getName(); //$NON-NLS-1$
- SystemBasePlugin.logError(msg, exc);
- SystemMessageDialog.displayExceptionMessage(getShell(), exc);
- ok = false;
- }
- }
- return ok;
- }
-
- // ------------------------------
- // ISystemRenameTarget methods...
- // ------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.ui.ISystemRenameTarget#showRename()
- */
- public boolean showRename()
- {
- return true;
- }
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.ui.ISystemRenameTarget#canRename()
- */
- public boolean canRename()
- {
- boolean ok = true;
- IStructuredSelection selection= getStructuredSelection();
- Iterator elements= selection.iterator();
- while (ok && elements.hasNext())
- {
- Object currObj = elements.next();
- if (!(currObj instanceof ISystemProfile))
- ok = false;
- }
- //System.out.println("Inside canRename: "+ok);
- return ok;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.ui.ISystemRenameTarget#doRename(java.lang.String[])
- */
- public boolean doRename(String[] newNames) {
- boolean ok = true;
- IStructuredSelection selection = getStructuredSelection();
- Iterator elements = selection.iterator();
- int idx = 0;
- while (ok && elements.hasNext()) {
- ISystemProfile profile = (ISystemProfile) elements.next();
- try {
- SystemTeamViewProfileAdapter profileAdapter = getProfileAdapter(profile);
- profileAdapter.doRename(getShell(), profile, newNames[idx++], null);
- } catch (SystemMessageException exc) {
- SystemMessageDialog.displayMessage(getShell(), exc);
- ok = false;
- } catch (Exception exc) {
- String msg = "Exception renaming profile "; //$NON-NLS-1$
- SystemBasePlugin.logError(msg, exc);
- SystemMessageDialog.displayExceptionMessage(getShell(), exc);
- ok = false;
- }
- }
- return ok;
- }
-
- /**
- * Returns the image descriptor with the given relative path.
- */
- protected ImageDescriptor getNavigatorImageDescriptor(String relativePath) {
- String iconPath = "icons/full/"; //$NON-NLS-1$
- try {
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- URL installURL = bundle.getEntry(""); //$NON-NLS-1$
- URL url = new URL(installURL, iconPath + relativePath);
- return ImageDescriptor.createFromURL(url);
- } catch (MalformedURLException e) {
- // should not happen
- return ImageDescriptor.getMissingImageDescriptor();
- }
- }
-
- // ----------------
- // MEMENTO STUFF...
- // ----------------
-
- /**
- * Method declared on IViewPart.
- */
- public void saveState(IMemento memento)
- {
- if (treeViewer == null)
- {
- // part has not been created
- if (fMemento != null) //Keep the old state;
- memento.putMemento(fMemento);
- return;
- }
-
- // We record the current release for future in case anything significant changes from release to release
- memento.putString(TAG_RELEASE, RSECorePlugin.CURRENT_RELEASE_NAME);
-
- /*
- String inputMemento = memento.getString("factoryID"); // see IWorkbenchWindow ... this is only clue I can figure out!
- if (inputMemento != null)
- {
- saveInputState(memento);
- return;
- }*/
-
- Tree tree = treeViewer.getTree();
-
- // SAVE EXPANSION STATE
- Object expandedElements[]= treeViewer.getVisibleExpandedElements();
- if ( (expandedElements!=null) && (expandedElements.length > 0) )
- {
- IMemento expandedMem= memento.createChild(TAG_EXPANDED);
- for (int i= 0; i < expandedElements.length; i++)
- {
- Object o = expandedElements[i];
- String mementoHandle = getMementoHandle(o);
- if (mementoHandle != null)
- {
- IMemento elementMem= expandedMem.createChild(TAG_ELEMENT);
- elementMem.putString(TAG_PATH, getMementoHandle(o));
- //System.out.println("Added to saved expansion list: " + getMementoHandle(o));
- }
- }
- }
-
- // SAVE SELECTION STATE
- Object elements[]= ((IStructuredSelection) treeViewer.getSelection()).toArray();
- if ( (elements!=null) && (elements.length > 0) )
- {
- IMemento selectionMem= memento.createChild(TAG_SELECTION);
- for (int i= 0; i < elements.length; i++)
- {
- Object o= elements[i];
- String mementoHandle = getMementoHandle(o);
- if (mementoHandle != null)
- {
- IMemento elementMem= selectionMem.createChild(TAG_ELEMENT);
- elementMem.putString(TAG_PATH, getMementoHandle(o));
- }
- }
- }
-
- //save vertical position
- ScrollBar bar= tree.getVerticalBar();
- int position= bar != null ? bar.getSelection() : 0;
- memento.putString(TAG_VERTICAL_POSITION, String.valueOf(position));
- //save horizontal position
- bar= tree.getHorizontalBar();
- position= bar != null ? bar.getSelection() : 0;
- memento.putString(TAG_HORIZONTAL_POSITION, String.valueOf(position));
-
- }
- /**
- * Return the memento handle key plus the memento handle for
- * each part leading up to the current object.
- */
- protected String getMementoHandle(Object o)
- {
- String mementoKey = internalGetMementoHandleKey(o);
- if (mementoKey == null)
- return null;
- StringBuffer idBuffer = new StringBuffer(mementoKey);
- Object[] elementNodes = treeViewer.getElementNodes(o);
- if (elementNodes != null)
- {
- for (int idx=elementNodes.length-1; idx>=0; idx--)
- {
- o = elementNodes[idx];
- idBuffer.append(MEMENTO_DELIM+internalGetMementoHandle(o));
- }
- }
- //System.out.println("MEMENTO HANDLE: " + idBuffer.toString());
- return idBuffer.toString();
- }
- /**
- * Encapsulate code to look at object class type and determine what to return for
- * a memento handle key
- */
- protected String internalGetMementoHandleKey(Object o)
- {
- ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(o, treeViewer);
- String handle = null;
- if (adapter != null)
- handle = adapter.getMementoHandleKey(o);
- else if (o instanceof IResource)
- {
- if (o instanceof IProject)
- handle = "Project"; //$NON-NLS-1$
- else if (o instanceof IFolder)
- handle = "Folder"; //$NON-NLS-1$
- else
- handle = "File"; //$NON-NLS-1$
- }
- else if (o instanceof ISystemProfile)
- handle = "Profile"; //$NON-NLS-1$
- else if (o instanceof SystemTeamViewCategoryNode)
- {
- //handle = "Category";
- //handle = null; // decided not to re-expand past profiles
- }
-
- return handle;
- }
- /**
- * Encapsulate code to look at object class type and determine what to return for
- * a memento handle
- */
- protected String internalGetMementoHandle(Object o)
- {
- ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(o, treeViewer);
- String handle = null;
- if (adapter != null)
- handle = adapter.getMementoHandle(o);
- else if (o instanceof IResource)
- handle = ((IResource)o).getName();
- else if (o instanceof ISystemProfile)
- handle = ((ISystemProfile)o).getName();
- else if (o instanceof SystemTeamViewCategoryNode)
- handle = ((SystemTeamViewCategoryNode)o).getMementoHandle();
- return handle;
- }
-
- /**
- * Our own method for restoring state
- */
- void restoreState(IMemento memento)
- {
- RestoreStateRunnable restoreAction = new RestoreStateRunnable(memento);
- Display.getDefault().syncExec(restoreAction);
- }
-
- /**
- * Inner class for running restore-state in a thread
- */
- public class RestoreStateRunnable implements Runnable
- {
- private IMemento _memento;
- public RestoreStateRunnable(IMemento memento)
- {
- _memento = memento;
- }
-
- public void run()
- {
- IMemento memento = _memento;
- IMemento childMem = null;
-
- // restore expansion state
- childMem = memento.getChild(TAG_EXPANDED);
- if (childMem != null)
- {
- ArrayList elements = new ArrayList();
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
- for (int i = 0; i < elementMem.length; i++)
- {
- Object element = getObjectFromMemento(elementMem[i].getString(TAG_PATH));
- if (element != null)
- elements.add(element);
- }
- // expand objects...
- treeViewer.setExpandedElements(elements.toArray());
- }
-
- // restoreSelection
- childMem = memento.getChild(TAG_SELECTION);
- if (childMem != null)
- {
- ArrayList list = new ArrayList();
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
- for (int i = 0; i < elementMem.length; i++)
- {
- Object element = getObjectFromMemento(elementMem[i].getString(TAG_PATH));
- if (element != null)
- list.add(element);
- }
- treeViewer.setSelection(new StructuredSelection(list));
- }
-
- Tree tree = treeViewer.getTree();
- //restore vertical position
- ScrollBar bar = tree.getVerticalBar();
- if (bar != null)
- {
- try
- {
- String posStr = memento.getString(TAG_VERTICAL_POSITION);
- if (posStr != null)
- {
- int position;
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- //restore vertical position
- bar = tree.getHorizontalBar();
- if (bar != null)
- {
- try
- {
- String posStr = memento.getString(TAG_HORIZONTAL_POSITION);
- if (posStr != null)
- {
- int position;
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- /**
- * Private method to deconstruct an expanded/selected memento into an actual object
- */
- protected Object getObjectFromMemento(String memento)
- {
- if (memento == null)
- return null;
-
- ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
- ISystemProfile profile = null;
- IProject project = null;
- SystemTeamViewCategoryNode category = null;
- String elementType = ""; //$NON-NLS-1$
-
- //System.out.println("PARSING MEMENTO: " + memento);
-
- Vector v = SystemViewPart.tokenize(memento, MEMENTO_DELIM);
-
- // 0. element type
- // 1. RSE Project
- // 2. Profiles
- // 3. Categories
-
- for (int idx=0; idx<v.size(); idx++)
- {
- String token = (String)v.elementAt(idx);
- switch (idx)
- {
- // type of element
- case 0: elementType = token; break;
- // profile
- case 1:
- project = SystemResourceManager.getRemoteSystemsProject(false);
- break;
- case 2:
- profile = sr.getSystemProfile(token);
- break;
- case 3:
- if (profile != null) {
-
-
- SystemTeamViewProfileAdapter profileAdapter = (SystemTeamViewProfileAdapter)((IAdaptable)profile).getAdapter(ISystemViewElementAdapter.class);
- category = profileAdapter.restoreCategory(profile, token);
- }
- //System.out.println("Restored category: "+(category==null?"null":category.getLabel()));
- break;
- }
- }
-
- if (elementType.equals("Project")) //$NON-NLS-1$
- {
- //System.out.println("...PARSED INTO A PROJECT: " + project.getName());
- return project;
- }
- else if (elementType.equals(ISystemMementoConstants.MEMENTO_KEY_PROFILE))
- {
- //System.out.println("...PARSED INTO A PROFILE: " + profile.getName());
- return profile;
- }
- if (elementType.equals("Category")) //$NON-NLS-1$
- {
- //System.out.println("...PARSED INTO A CATEGORY: " + category.getLabel());
- return category;
- }
- else
- {
- //System.out.println("...UNKNOWN MEMENTO ");
- }
- return null;
- }
-
- // -----------------------------
- // ISelectionListener methods...
- // -----------------------------
-
- /**
- * Handles selection changed in viewer.
- * Updates global actions.
- * Links to editor (if option enabled)
- */
- public void selectionChanged(SelectionChangedEvent event)
- {
- IStructuredSelection sel = (IStructuredSelection)event.getSelection();
- updateActionBars(sel);
- Object firstSelection = sel.getFirstElement();
- if (firstSelection == null)
- return;
- ISystemViewElementAdapter adapter = SystemAdapterHelpers.getViewAdapter(firstSelection);
- if (adapter != null)
- {
- setMessage(adapter.getStatusLineText(firstSelection));
- //if ((mouseButtonPressed == LEFT_BUTTON) && (!expandingTreeOnly)) //d40615
- //adapter.selectionChanged(firstSelection); //d40615
- }
- else
- setMessage(internalGetMementoHandle(firstSelection));
-
- if (newProfileAction != null)
- newProfileAction.refreshEnablement(); // not selection related, but we have no other trigger
- }
-
- // -------------------------------
- // ISystemMessageLine interface...
- // -------------------------------
- /**
- * Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage()
- {
- errorMessage = null;
- sysErrorMessage = null;
- if (statusLine != null)
- statusLine.setErrorMessage(errorMessage);
- }
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage()
- {
- message = null;
- if (statusLine != null)
- statusLine.setMessage(message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public String getErrorMessage()
- {
- return errorMessage;
- }
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed <code>null<code> is returned.
- */
- public String getMessage()
- {
- return message;
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message)
- {
- this.errorMessage = message;
- if (statusLine != null)
- statusLine.setErrorMessage(message);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed <code>null</code> is returned.
- */
- public SystemMessage getSystemErrorMessage()
- {
- return sysErrorMessage;
- }
-
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(SystemMessage message)
- {
- sysErrorMessage = message;
- setErrorMessage(message.getLevelOneText());
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(Throwable exc)
- {
- setErrorMessage(exc.getMessage());
- }
-
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message)
- {
- this.message = message;
- if (statusLine != null)
- statusLine.setMessage(message);
- }
- /**
- *If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(SystemMessage message)
- {
- setMessage(message.getLevelOneText());
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewProfileAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewProfileAdapter.java
deleted file mode 100644
index ac796fde5..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewProfileAdapter.java
+++ /dev/null
@@ -1,401 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David Dykstal (IBM) - 180562: remove implementation of IRSEUserIdConstants
- * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * David Dykstal (IBM) - [191130] use new getRemoteSystemsProject(boolean) call
- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
- * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
- * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
- * David Dykstal (IBM) - [cleanup] formatted
- * Xuan Chen (IBM) - [222263] Need to provide a PropertySet Adapter for System Team View
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.SystemResourceManager;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.model.ISystemProfileManager;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
-import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
-import org.eclipse.rse.internal.ui.actions.SystemProfileNameCopyAction;
-import org.eclipse.rse.internal.ui.view.ISystemMementoConstants;
-import org.eclipse.rse.internal.ui.view.SystemViewResources;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.validators.ISystemValidator;
-import org.eclipse.rse.ui.validators.ValidatorProfileName;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.rse.ui.view.ISystemPropertyConstants;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-/**
- * Adapter for displaying and processing SystemProfile objects in tree views, such as
- * the Team view.
- */
-public class SystemTeamViewProfileAdapter extends AbstractSystemViewAdapter {
-
- private boolean actionsCreated = false;
- private Hashtable categoriesByProfile = new Hashtable();
- // context menu actions for profiles...
- protected SystemTeamViewMakeActiveProfileAction makeProfileActiveAction;
- protected SystemTeamViewMakeInActiveProfileAction makeProfileInactiveAction;
- protected SystemCommonRenameAction renameAction;
- protected SystemCommonDeleteAction deleteAction;
- protected SystemProfileNameCopyAction copyProfileAction;
-
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given element.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup) {
- if (!actionsCreated) {
- createActions();
- }
- copyProfileAction.setProfile((ISystemProfile) selection.getFirstElement());
- menu.add(ISystemContextMenuConstants.GROUP_CHANGE, makeProfileActiveAction);
- menu.add(ISystemContextMenuConstants.GROUP_CHANGE, makeProfileInactiveAction);
- menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE, copyProfileAction);
- menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE, deleteAction);
- menu.add(ISystemContextMenuConstants.GROUP_REORGANIZE, renameAction);
- }
-
- private void createActions() {
- makeProfileActiveAction = new SystemTeamViewMakeActiveProfileAction(getShell());
- makeProfileInactiveAction = new SystemTeamViewMakeInActiveProfileAction(getShell());
- copyProfileAction = new SystemProfileNameCopyAction(getShell());
-
- deleteAction = new SystemCommonDeleteAction(getShell(), getTeamViewPart());
- deleteAction.setHelp(RSEUIPlugin.HELPPREFIX + "actndlpr"); //$NON-NLS-1$
- deleteAction.setDialogHelp(RSEUIPlugin.HELPPREFIX + "ddltprfl"); //$NON-NLS-1$
- deleteAction.setPromptLabel(SystemResources.RESID_DELETE_PROFILES_PROMPT);
-
- renameAction = new SystemCommonRenameAction(getShell(), getTeamViewPart());
- renameAction.setHelp(RSEUIPlugin.HELPPREFIX + "actnrnpr"); //$NON-NLS-1$
- renameAction.setDialogSingleSelectionHelp(RSEUIPlugin.HELPPREFIX + "drnsprfl"); //$NON-NLS-1$
- renameAction.setDialogMultiSelectionHelp(RSEUIPlugin.HELPPREFIX + "drnmprfl"); //$NON-NLS-1$
- renameAction.setSingleSelectPromptLabel(SystemResources.RESID_SIMPLE_RENAME_PROFILE_PROMPT_LABEL, SystemResources.RESID_SIMPLE_RENAME_PROFILE_PROMPT_TIP);
- renameAction.setMultiSelectVerbiage(SystemResources.RESID_MULTI_RENAME_PROFILE_VERBIAGE);
-
- actionsCreated = true;
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element) {
- ISystemProfile profile = (ISystemProfile) element;
- if (RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName()))
- return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROFILE_ACTIVE_ID);
- else
- return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROFILE_ID);
- }
-
- /**
- * Return the team view part
- */
- private SystemTeamViewPart getTeamViewPart() {
- SystemTeamView viewer = (SystemTeamView) getViewer();
- return viewer.getTeamViewPart();
- }
-
- /**
- * Return the label for this object
- */
- public String getText(Object element) {
- return ((ISystemProfile) element).getName();
- }
-
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element) {
- return ((ISystemProfile) element).getName();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element) {
- return ((ISystemProfile) element).getName();
- }
-
- /**
- * Return the type label for this object
- */
- public String getType(Object element) {
- return SystemViewResources.RESID_PROPERTY_PROFILE_TYPE_VALUE;
- }
-
- /**
- * Return the string to display in the status line when the given object is selected.
- * We return:
- * Connection: name - Host name: hostName - Description: description
- */
- public String getStatusLineText(Object element) {
- ISystemProfile profile = (ISystemProfile) element;
- boolean active = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName());
- return getType(element) + ": " + profile.getName() + ", " + //$NON-NLS-1$ //$NON-NLS-2$
- SystemViewResources.RESID_PROPERTY_PROFILESTATUS_LABEL + ": " + //$NON-NLS-1$
- (active ? SystemViewResources.RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL : SystemViewResources.RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL);
- }
-
- /**
- * Return the parent of this object. We return the RemoteSystemsConnections project
- */
- public Object getParent(Object element) {
- return SystemResourceManager.getRemoteSystemsProject(false);
- }
-
- /**
- * Return the children of this profile.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor) {
- ISystemProfile profile = (ISystemProfile) element;
- return getCategoryChildren(profile);
- }
-
- /**
- * Given a profile, return all the category children for it. If this child objects have yet to be created,
- * create them now.
- */
- public SystemTeamViewCategoryNode[] getCategoryChildren(ISystemProfile profile) {
- SystemTeamViewCategoryNode[] children = (SystemTeamViewCategoryNode[]) categoriesByProfile.get(profile);
- if (children == null) {
- children = new SystemTeamViewCategoryNode[3]; //5];
- for (int idx = 0; idx < children.length; idx++)
- children[idx] = new SystemTeamViewCategoryNode(profile);
- children[0].setLabel(SystemResources.RESID_TEAMVIEW_CATEGORY_CONNECTIONS_LABEL);
- children[0].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_CONNECTIONS_TOOLTIP);
- children[0].setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTION_ID));
- children[0].setMementoHandle(SystemTeamViewCategoryNode.MEMENTO_CONNECTIONS);
-
- children[1].setLabel(SystemResources.RESID_TEAMVIEW_CATEGORY_FILTERPOOLS_LABEL);
- children[1].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_FILTERPOOLS_TOOLTIP);
- children[1].setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FILTERPOOL_ID));
- children[1].setMementoHandle(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS);
-
- children[2].setLabel(SystemResources.RESID_TEAMVIEW_CATEGORY_PROPERTYSET_LABEL);
- children[2].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_PROPERTYSET_TOOLTIP);
- children[2].setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROPERTIES_ID));
- children[2].setMementoHandle(SystemTeamViewCategoryNode.MEMENTO_PROPERTYSETS);
-/*
- children[2].setLabel(SystemResources.RESID_TEAMVIEW_CATEGORY_USERACTIONS_LABEL);
- children[2].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_USERACTIONS_TOOLTIP);
- children[2].setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_USERACTION_USR_ID));
- children[2].setMementoHandle(SystemTeamViewCategoryNode.MEMENTO_USERACTIONS);
-
- children[3].setLabel(SystemResources.RESID_TEAMVIEW_CATEGORY_COMPILECMDS_LABEL);
- children[3].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_COMPILECMDS_TOOLTIP);
- children[3].setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_COMPILE_ID));
- children[3].setMementoHandle(SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS);
- */
- /*
- children[4].setLabel(SystemResources.RESID_TEAMVIEW_CATEGORY_TARGETS_LABEL);
- children[4].setDescription(SystemResources.RESID_TEAMVIEW_CATEGORY_TARGETS_TOOLTIP);
- children[4].setImageDescriptor(RSEUIPlugin.getDefault().getImageDescriptor(ISystemConstants.ICON_SYSTEM_TARGET_ID));
- children[4].setMementoHandle(SystemTeamViewCategoryNode.MEMENTO_TARGETS);
- */
-
- categoriesByProfile.put(profile, children);
- }
- return children;
- }
-
- /**
- * Given a profile and memento handle, return the appropriate category node. This is used when
- * restoring the expansion and selection state of the team view.
- */
- public SystemTeamViewCategoryNode restoreCategory(ISystemProfile profile, String mementoHandle) {
- SystemTeamViewCategoryNode[] children = getCategoryChildren(profile);
- SystemTeamViewCategoryNode category = null;
- for (int idx = 0; (category == null) && (idx < 2); idx++) {
- if (children[idx].getMementoHandle().equals(mementoHandle)) category = children[idx];
- }
- return category;
- }
-
- /**
- * Return true if this profile has children. We return true.
- */
- public boolean hasChildren(IAdaptable element) {
- return true;
- }
-
- // Property sheet descriptors defining all the properties we expose in the Property Sheet
- /**
- * Return our unique property descriptors, which getPropertyDescriptors adds to the common properties.
- */
- protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors() {
- if (propertyDescriptorArray == null) {
- propertyDescriptorArray = new PropertyDescriptor[1];
- int idx = 0;
- // status
- propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_ACTIVE, SystemViewResources.RESID_PROPERTY_PROFILESTATUS_LABEL,
- SystemViewResources.RESID_PROPERTY_PROFILESTATUS_TOOLTIP);
- }
- return propertyDescriptorArray;
- }
-
- /**
- * Returns the current value for the named property.
- * The parent handles P_TEXT and P_TYPE only, and we augment that here.
- * @param key - the name of the property as named by its property descriptor
- * @return the current value of the property
- */
- public Object internalGetPropertyValue(Object key) {
- String name = (String) key;
- ISystemProfile profile = (ISystemProfile) propertySourceInput;
-
- if (name.equals(ISystemPropertyConstants.P_IS_ACTIVE)) {
- boolean active = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName());
- if (active)
- return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL;
- else
- return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL;
- } else
- return null;
- }
-
- // FOR COMMON DELETE ACTIONS
- /**
- * Return true if this object is deletable by the user. If so, when selected,
- * the Edit->Delete menu item will be enabled.
- */
- public boolean canDelete(Object element) {
- boolean ok = true;
- if (!(element instanceof ISystemProfile)) {
- ok = false;
- } else {
- ISystemProfile profile = (ISystemProfile) element;
- ISystemProfileManager manager = RSECorePlugin.getTheSystemProfileManager();
- ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile();
- if (profile == defaultProfile) {
- ok = false;
- }
- }
- return ok;
- }
-
- /**
- * Perform the delete action.
- */
- public boolean doDelete(Shell shell, Object element, IProgressMonitor monitor) throws Exception {
- boolean ok = true;
- RSECorePlugin.getTheSystemRegistry().deleteSystemProfile((ISystemProfile) element);
- return ok;
- }
-
- // FOR COMMON RENAME ACTIONS
- /**
- * Return true if this object is renamable by the user. If so, when selected,
- * the Rename popup menu item will be enabled.
- */
- public boolean canRename(Object element) {
- boolean ok = true;
- if (!(element instanceof ISystemProfile)) ok = false;
- return ok;
- }
-
- /**
- * Perform the rename action.
- */
- public boolean doRename(Shell shell, Object element, String newName, IProgressMonitor monitor) throws Exception {
- boolean ok = true;
- RSECorePlugin.getTheSystemRegistry().renameSystemProfile((ISystemProfile) element, newName);
- return ok;
- }
-
- /**
- * Return a validator for verifying the new name is correct.
- */
- public ISystemValidator getNameValidator(Object element) {
- String[] nameArray = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().getSystemProfileNames();
- Vector names = new Vector(nameArray.length);
- names.addAll(Arrays.asList(nameArray));
- ISystemValidator validator = new ValidatorProfileName(names);
- return validator;
- }
-
- /**
- * Parent override.
- * <p>
- * Form and return a new canonical (unique) name for this object, given a candidate for the new
- * name. This is called by the generic multi-rename dialog to test that all new names are unique.
- * To do this right, sometimes more than the raw name itself is required to do uniqueness checking.
- * <p>
- * Returns profile.connectionName, upperCased
- */
- public String getCanonicalNewName(Object element, String newName) {
- return newName.toUpperCase();
- }
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- */
- public String getMementoHandle(Object element) {
- ISystemProfile profile = (ISystemProfile) element;
- return profile.getName();
- }
-
- /**
- * Return a short string to uniquely identify the type of resource.
- */
- public String getMementoHandleKey(Object element) {
- return ISystemMementoConstants.MEMENTO_KEY_PROFILE;
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPropertySetAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPropertySetAdapter.java
deleted file mode 100644
index a31f768fe..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPropertySetAdapter.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*********************************************************************************
- * Copyright (c) 2008 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xuan Chen (IBM) - [222263] initial contribution.
- * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API type
- *********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.model.IProperty;
-import org.eclipse.rse.core.model.IPropertySet;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.view.SystemViewResources;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-
-/**
- * Adapter for displaying and processing SystemTeamViewSubSystemConfigurationNode objects in tree views, such as
- * the Team view.
- */
-public class SystemTeamViewPropertySetAdapter
- extends AbstractSystemViewAdapter
-{
- private boolean actionsCreated = false;
-
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
-
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given element.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- if (!actionsCreated)
- createActions();
- }
- private void createActions()
- {
- actionsCreated = true;
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- return ((SystemTeamViewPropertySetNode)element).getImageDescriptor();
- }
-
- /**
- * Return the label for this object
- */
- public String getText(Object element)
- {
- return ((SystemTeamViewPropertySetNode)element).getLabel();
- }
-
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- return ((SystemTeamViewPropertySetNode)element).getLabel();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- SystemTeamViewPropertySetNode factory = (SystemTeamViewPropertySetNode)element;
- return factory.getLabel();
- }
-
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- return SystemViewResources.RESID_PROPERTY_TEAM_PROPERTYSET_TYPE_VALUE;
- }
-
- /**
- * Return the string to display in the status line when the given object is selected.
- */
- public String getStatusLineText(Object element)
- {
- SystemTeamViewPropertySetNode factory = (SystemTeamViewPropertySetNode)element;
- return SystemResources.RESID_TEAMVIEW_PROPERTYSET_VALUE + ": " + factory.getLabel(); //$NON-NLS-1$
- }
-
- /**
- * Return the parent of this object. We return the RemoteSystemsConnections project
- */
- public Object getParent(Object element)
- {
- SystemTeamViewPropertySetNode factory = (SystemTeamViewPropertySetNode)element;
- return factory.getParent();
- }
-
- /**
- * Return the children of this profile.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- SystemTeamViewPropertySetNode propertySetNode = (SystemTeamViewPropertySetNode)element;
- IPropertySet propertySet = propertySetNode.getPropertySet();
- IPropertySet[] children = propertySet.getPropertySets();
- if (null == children || children.length == 0)
- {
- return new Object[0];
- }
-
- // construct the nodes for the view based on these configurations
- SystemTeamViewPropertySetNode[] nodes = new SystemTeamViewPropertySetNode[children.length];
- //String categoryType = category.getMementoHandle();
- for (int i = 0; i < children.length; i++)
- {
- nodes[i] = new SystemTeamViewPropertySetNode(propertySet, children[i]);
- }
- return nodes;
-
- }
-
- /**
- * Return true if this profile has children. We return true.
- */
- public boolean hasChildren(IAdaptable element)
- {
- SystemTeamViewPropertySetNode propertySetNode = (SystemTeamViewPropertySetNode)element;
- IPropertySet propertySet = propertySetNode.getPropertySet();
- IPropertySet[] children = propertySet.getPropertySets();
- if (null == children || children.length == 0)
- {
- return false;
- }
-
- return true;
-
- }
-
- /**
- * For PropertySet Node Adapter, we need to override this method since we don't want to display "name" and "type" twice.
- *
- * @return an array containing all descriptors.
- *
- * @see #internalGetPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- return internalGetPropertyDescriptors();
- }
-
- protected IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- SystemTeamViewPropertySetNode propertySetNode = (SystemTeamViewPropertySetNode)propertySourceInput;
- IPropertySet propertySet = propertySetNode.getPropertySet();
-
- String[] propertyKeys = propertySet.getPropertyKeys();
-
- int size = propertyKeys.length;
-
- IProperty nameProperty = propertySet.getProperty(SystemTeamViewPropertySetNode.NAME_PROPERTY);
- if (null == nameProperty)
- {
- nameProperty = propertySet.getProperty(SystemTeamViewPropertySetNode.NAME_PROPERTY1);
- }
- int startingIndex = 0;
- if (nameProperty == null)
- {
- size++;
- }
-
- propertyDescriptorArray = new PropertyDescriptor[size];
-
- if (nameProperty == null)
- {
- propertyDescriptorArray[startingIndex++] = createSimplePropertyDescriptor(SystemTeamViewPropertySetNode.NAME_PROPERTY, SystemTeamViewPropertySetNode.NAME_PROPERTY, propertySet.getName());
- }
-
- for (int i = startingIndex, j = 0; i < size; i++, j++)
- {
- propertyDescriptorArray[i] = createSimplePropertyDescriptor(propertyKeys[j], propertyKeys[j], propertySet.getPropertyValue(propertyKeys[j]));
- }
-
-
- return propertyDescriptorArray;
- }
-
-
- /**
- * Returns the current value for the named property.
- * The parent handles P_TEXT and P_TYPE only, and we augment that here.
- * @param key - the name of the property as named by its property descriptor
- * @return the current value of the property
- */
- public Object internalGetPropertyValue(Object key)
- {
- SystemTeamViewPropertySetNode propertySetNode = (SystemTeamViewPropertySetNode)propertySourceInput;
- IPropertySet propertySet = propertySetNode.getPropertySet();
- return propertySet.getPropertyValue((String)key);
- }
-
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- */
- public String getMementoHandle(Object element)
- {
- SystemTeamViewPropertySetNode factory = (SystemTeamViewPropertySetNode)element;
- return factory.getMementoHandle();
- }
- /**
- * Return a short string to uniquely identify the type of resource.
- */
- public String getMementoHandleKey(Object element)
- {
- SystemTeamViewPropertySetNode factory = (SystemTeamViewPropertySetNode)element;
- return factory.getLabel();
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPropertySetNode.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPropertySetNode.java
deleted file mode 100644
index 7efd45f45..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewPropertySetNode.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*********************************************************************************
- * Copyright (c) 2008 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xuan Chen (IBM) - [222263] initial contribution.
- *********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.rse.core.model.IProperty;
-import org.eclipse.rse.core.model.IPropertySet;
-import org.eclipse.rse.core.model.IPropertySetContainer;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-
-
-/**
- * This class represents a child node under category nodes, in the Team view.
- * It represents expandable subsystem factories such as "Files" or "iSeries Objects".
- */
-public class SystemTeamViewPropertySetNode implements IAdaptable
-{
- private String mementoHandle;
- private IPropertySetContainer parent;
- private IPropertySet propertySet;
- static public final String NAME_PROPERTY = "name"; //$NON-NLS-1$
- static public final String NAME_PROPERTY1 = "Name"; //$NON-NLS-1$
-
- /**
- * Constructor
- */
- public SystemTeamViewPropertySetNode(IPropertySetContainer parent, IPropertySet propertySet)
- {
- super();
- this.parent = parent;
- this.propertySet = propertySet;
- }
-
- /**
- * This is the method required by the IAdaptable interface.
- * Given an adapter class type, return an object castable to the type, or
- * null if this is not possible.
- */
- public Object getAdapter(Class adapterType)
- {
- return Platform.getAdapterManager().getAdapter(this, adapterType);
- }
-
- /**
- * Compare this node to another.
- */
- public boolean equals(Object o)
- {
- if (o instanceof SystemTeamViewPropertySetNode)
- {
- /*
- SystemTeamViewPropertySetNode other = (SystemTeamViewPropertySetNode)o;
- if ((ssf == other.getSubSystemConfiguration()) &&
- (parentCategory == other.getParentCategory()) &&
- (profile == other.getProfile()))
- return true;
- else
- return false;
- */
- return super.equals(o);
- }
- else
- return super.equals(o);
- }
-
- /**
- * Return this node's image
- * @return the image to show in the tree, for this node
- */
- public ImageDescriptor getImageDescriptor()
- {
- return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROPERTIES_ID);
- }
-
- public Object getParent()
- {
- return parent;
- }
-
- /**
- * Return this node's label
- * @return the translated label to show in the tree, for this node
- */
- public String getLabel()
- {
- String label = null;
- //First, check if this PropertySet has a property called "name"
- IProperty nameProperty = propertySet.getProperty(NAME_PROPERTY);
- if (null != nameProperty)
- {
- label = nameProperty.getValue();
- }
- else
- {
- label = propertySet.getName();
- }
- return label;
- }
-
- /**
- * Convert to string. We call getLabel()
- */
- public String toString()
- {
- return getLabel();
- }
-
-
-
- /**
- * @return PropertySet this node is associated with
- */
- public IPropertySet getPropertySet()
- {
- return propertySet;
- }
-
- /**
- * @return the untranslated value to store in the memento, to uniquely identify this node
- */
- public String getMementoHandle()
- {
- return mementoHandle;
- }
-
- /**
- * Set the untranslated value to store in the memento, to uniquely identify this node
- * @param string - untranslated value
- */
- public void setMementoHandle(String string)
- {
- mementoHandle = string;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewRefreshAllAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewRefreshAllAction.java
deleted file mode 100644
index 72d5b74af..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewRefreshAllAction.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Michael Berger (IBM) - 146339 Added refresh action graphic.
- * David Dykstal (IBM) - [191130] use new getRemoteSystemsProject(boolean) method
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.SystemResourceManager;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.ui.ISystemContextMenuConstants;
-import org.eclipse.rse.ui.ISystemIconConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.actions.SystemBaseAction;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * The action allows users to refresh the entire System Team tree view
- */
-public class SystemTeamViewRefreshAllAction extends SystemBaseAction
- //
-{
- private SystemTeamViewPart teamView;
-
- /**
- * Constructor for SystemRefreshAllAction
- */
- public SystemTeamViewRefreshAllAction(Shell parent, SystemTeamViewPart teamView)
- {
- super(SystemResources.ACTION_REFRESH_ALL_LABEL,SystemResources.ACTION_REFRESH_ALL_TOOLTIP,
- RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_REFRESH_ID),
- parent);
- this.teamView = teamView;
- allowOnMultipleSelection(true);
- setContextMenuGroup(ISystemContextMenuConstants.GROUP_BUILD);
- setSelectionSensitive(false);
-
- setHelp(RSEUIPlugin.HELPPREFIX+"actn0009"); //$NON-NLS-1$
- }
-
- /**
- * @see SystemBaseAction#updateSelection(IStructuredSelection)
- */
- public boolean updateSelection(IStructuredSelection selection)
- {
- boolean enable = true;
- return enable;
- }
-
- /**
- * This is the method called when the user selects this action.
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run()
- {
- try {
- IProject connectionsProject = SystemResourceManager.getRemoteSystemsProject(false);
- if (connectionsProject.isAccessible()) {
- connectionsProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- } catch (Exception exc) {}
- SystemTeamView teamViewer = (SystemTeamView)teamView.getTreeViewer();
- teamViewer.refresh();
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewResourceAdapterFactory.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewResourceAdapterFactory.java
deleted file mode 100644
index 145c0be62..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewResourceAdapterFactory.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David Dykstal (IBM) - [191130] fix unnecessary creation of the remote systems project
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.rse.core.SystemResourceManager;
-import org.eclipse.rse.core.model.ISystemRegistry;
-
-
-/**
- * Special adapter factory that maps Remote Systems Framework objects to underlying workbench resources
- */
-public class SystemTeamViewResourceAdapterFactory implements IAdapterFactory
-{
- /**
- * @see IAdapterFactory#getAdapterList()
- */
- public Class[] getAdapterList()
- {
- return new Class[] {IResource.class};
- }
- /**
- * Called by our plugin's startup method to register our adaptable object types
- * with the platform. We prefer to do it here to isolate/encapsulate all factory
- * logic in this one place.
- */
- public void registerWithManager(IAdapterManager manager)
- {
- manager.registerAdapters(this, ISystemRegistry.class);
- //manager.registerAdapters(this, SystemProfile.class); DEFERRED UNTIL NEXT RELEASE
- }
- /**
- * @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptableObject, Class adapterType)
- {
- Object adapter = null;
- if (adaptableObject instanceof ISystemRegistry)
- {
- //SystemRegistry sr = (SystemRegistry)adaptableObject;
- // [191130] do not force the creation of the project, just return its handle
- adapter = SystemResourceManager.getRemoteSystemsProject(false);
- }
- /* deferred
- else if (adaptableObject instanceof SystemProfile)
- {
- SystemProfile profile = (SystemProfile)adaptableObject;
- adapter = SystemResourceManager.getProfileFolder(profile);
- }*/
- return adapter;
- }
-
-
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationAdapter.java
deleted file mode 100644
index a83646c7d..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationAdapter.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation
- * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
- * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
- * Xuan Chen (IBM) - [223126] [api][breaking] Remove API related to User Actions in RSE Core/UI
- *******************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.rse.core.filters.ISystemFilterPoolManager;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.actions.SystemFilterWorkWithFilterPoolsAction;
-import org.eclipse.rse.internal.ui.view.SystemViewResources;
-import org.eclipse.rse.ui.SystemMenuManager;
-import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-
-/**
- * Adapter for displaying and processing SystemTeamViewSubSystemConfigurationNode objects in tree views, such as
- * the Team view.
- */
-public class SystemTeamViewSubSystemConfigurationAdapter
- extends AbstractSystemViewAdapter
-{
- private boolean actionsCreated = false;
- //private Hashtable categoriesByProfile = new Hashtable();
- private SystemFilterWorkWithFilterPoolsAction wwPoolsAction;
-
- // -------------------
- // property descriptors
- // -------------------
- private static PropertyDescriptor[] propertyDescriptorArray = null;
-
-
- /**
- * Returns any actions that should be contributed to the popup menu
- * for the given element.
- * @param menu The menu to contribute actions to
- * @param selection The window's current selection.
- * @param shell Shell of viewer
- * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first.
- */
- public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
- {
- if (!actionsCreated)
- createActions();
-
- SystemTeamViewSubSystemConfigurationNode ssfNode = (SystemTeamViewSubSystemConfigurationNode)selection.getFirstElement();
- SystemTeamViewCategoryNode category = ssfNode.getParentCategory();
- String categoryType = category.getMementoHandle();
-
- if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS) && ssfNode.getSubSystemConfiguration().supportsFilters())
- {
- wwPoolsAction.reset();
- wwPoolsAction.setShell(shell);
- wwPoolsAction.setFilterPoolManagerProvider(ssfNode.getSubSystemConfiguration());
- ISystemFilterPoolManager[] poolMgrs = new ISystemFilterPoolManager[1];
- poolMgrs[0] = ssfNode.getSubSystemConfiguration().getFilterPoolManager(ssfNode.getProfile());
- wwPoolsAction.setFilterPoolManagers(poolMgrs);
- menu.add(menuGroup, wwPoolsAction);
- }
- }
- private void createActions()
- {
- actionsCreated = true;
-
-// FIXME - user actions and compile actions no longer coupled to core
-// wwActionsAction = new SystemWorkWithUDAsAction(null, true);
-// wwCmdsAction = new SystemWorkWithCompileCommandsAction(null, true);
- wwPoolsAction = new SystemFilterWorkWithFilterPoolsAction(null, false);
- }
-
- /**
- * Returns an image descriptor for the image. More efficient than getting the image.
- * @param element The element for which an image is desired
- */
- public ImageDescriptor getImageDescriptor(Object element)
- {
- return ((SystemTeamViewSubSystemConfigurationNode)element).getImageDescriptor();
- }
-
- /**
- * Return the label for this object
- */
- public String getText(Object element)
- {
- return ((SystemTeamViewSubSystemConfigurationNode)element).getLabel();
- }
-
- /**
- * Return the name of this object, which may be different than the display text ({#link #getText(Object)}.
- * <p>
- * Called by common rename and delete actions.
- */
- public String getName(Object element)
- {
- return ((SystemTeamViewSubSystemConfigurationNode)element).getLabel();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier#getAbsoluteName(java.lang.Object)
- */
- public String getAbsoluteName(Object element)
- {
- SystemTeamViewSubSystemConfigurationNode factory = (SystemTeamViewSubSystemConfigurationNode)element;
- return factory.getProfile().getName() + "." + factory.getParentCategory().getLabel() + factory.getLabel(); //$NON-NLS-1$
- }
-
- /**
- * Return the type label for this object
- */
- public String getType(Object element)
- {
- return SystemViewResources.RESID_PROPERTY_TEAM_SSFACTORY_TYPE_VALUE;
- }
-
- /**
- * Return the string to display in the status line when the given object is selected.
- */
- public String getStatusLineText(Object element)
- {
- SystemTeamViewSubSystemConfigurationNode factory = (SystemTeamViewSubSystemConfigurationNode)element;
- return SystemResources.RESID_TEAMVIEW_SUBSYSFACTORY_VALUE + ": " + factory.getLabel(); //$NON-NLS-1$
- }
-
- /**
- * Return the parent of this object. We return the RemoteSystemsConnections project
- */
- public Object getParent(Object element)
- {
- SystemTeamViewSubSystemConfigurationNode factory = (SystemTeamViewSubSystemConfigurationNode)element;
- return factory.getParentCategory();
- }
-
- /**
- * Return the children of this profile.
- */
- public Object[] getChildren(IAdaptable element, IProgressMonitor monitor)
- {
- SystemTeamViewSubSystemConfigurationNode ssfNode = (SystemTeamViewSubSystemConfigurationNode)element;
- SystemTeamViewCategoryNode category = ssfNode.getParentCategory();
- ISystemProfile profile = ssfNode.getProfile();
- String categoryType = category.getMementoHandle();
- ISubSystemConfiguration ssf = ssfNode.getSubSystemConfiguration();
- if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS))
- {
- return profile.getFilterPools(ssf);
- }
- else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_USERACTIONS))
- {
- /* FIXME
- SystemUDActionElement[] children = profile.getUserActions(ssf);
- for (int idx=0; idx<children.length; idx++)
- {
- children[idx].setData(ssfNode);
- }
- return children;
- */
- return null;
- }
- else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS))
- {
- /* FIXME
- SystemCompileType[] types = profile.getCompileCommandTypes(ssf);
- if (types != null)
- {
- SystemTeamViewCompileTypeNode[] typeNodes = new SystemTeamViewCompileTypeNode[types.length];
- for (int idx=0; idx<types.length; idx++)
- typeNodes[idx] = new SystemTeamViewCompileTypeNode(ssfNode, types[idx]);
- return typeNodes;
- }
- else
- */
- return null;
- }
- else
- return null;
- }
-
- /**
- * Return true if this profile has children. We return true.
- */
- public boolean hasChildren(IAdaptable element)
- {
- SystemTeamViewSubSystemConfigurationNode ssConfNode = (SystemTeamViewSubSystemConfigurationNode)element;
- SystemTeamViewCategoryNode category = ssConfNode.getParentCategory();
- //ISystemProfile profile = ssConfNode.getProfile();
- String categoryType = category.getMementoHandle();
- //ISubSystemConfiguration ssConf = ssConfNode.getSubSystemConfiguration();
- if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_FILTERPOOLS))
- return true;
- else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_USERACTIONS))
- {
- /* FIXME
- return (profile.getUserActions(ssConf).length > 0);
- */
- return false;
- }
- else if (categoryType.equals(SystemTeamViewCategoryNode.MEMENTO_COMPILECMDS))
- {
- /* FIXME
- return (profile.getCompileCommandTypes(ssConf).length > 0);
- */
- return false;
- }
- else
- return false;
- }
-
- // Property sheet descriptors defining all the properties we expose in the Property Sheet
- /**
- * Return our unique property descriptors, which getPropertyDescriptors adds to the common properties.
- */
- protected org.eclipse.ui.views.properties.IPropertyDescriptor[] internalGetPropertyDescriptors()
- {
- if (propertyDescriptorArray == null)
- {
- /*
- propertyDescriptorArray = new PropertyDescriptor[1];
- RSEUIPlugin plugin = RSEUIPlugin.getDefault();
- int idx = 0;
- // status
- propertyDescriptorArray[idx] = new PropertyDescriptor(ISystemPropertyConstants.P_IS_ACTIVE,
- SystemViewResources.RESID_PROPERTY_PROFILESTATUS_LABEL);
- propertyDescriptorArray[idx].setDescription(SystemViewResources.RESID_PROPERTY_PROFILESTATUS_DESCRIPTION));
- ++idx;
- */
- }
- return propertyDescriptorArray;
- }
-
- /**
- * Returns the current value for the named property.
- * The parent handles P_TEXT and P_TYPE only, and we augment that here.
- * @param key - the name of the property as named by its property descriptor
- * @return the current value of the property
- */
- public Object internalGetPropertyValue(Object key)
- {
- /*
- if (name.equals(P_IS_ACTIVE))
- {
- boolean active = RSECorePlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName());
- if (active)
- return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_ACTIVE_LABEL);
- else
- return SystemViewResources.RESID_PROPERTY_PROFILESTATUS_NOTACTIVE_LABEL);
- }
- else
- */
- return null;
- }
-
-
- // ------------------------------------------------------------
- // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...
- // ------------------------------------------------------------
- /**
- * Return what to save to disk to identify this element in the persisted list of expanded elements.
- */
- public String getMementoHandle(Object element)
- {
- SystemTeamViewSubSystemConfigurationNode factory = (SystemTeamViewSubSystemConfigurationNode)element;
- return factory.getMementoHandle();
- }
- /**
- * Return a short string to uniquely identify the type of resource.
- */
- public String getMementoHandleKey(Object element)
- {
- SystemTeamViewSubSystemConfigurationNode factory = (SystemTeamViewSubSystemConfigurationNode)element;
- return factory.getProfile().getName() + "." + factory.getParentCategory().getLabel() + "." + factory.getLabel(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * This is a local RSE artifact so returning false
- *
- * @param element the object to check
- * @return false since this is not remote
- */
- public boolean isRemote(Object element) {
- return false;
- }
-}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationNode.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationNode.java
deleted file mode 100644
index 3bd2f032a..000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewSubSystemConfigurationNode.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/********************************************************************************
- * 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
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
- * Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
- * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading
- ********************************************************************************/
-
-package org.eclipse.rse.internal.ui.view.team;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.model.ISystemProfile;
-import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
-import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
-import org.eclipse.rse.internal.ui.SystemResources;
-import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapter;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
-
-
-/**
- * This class represents a child node under category nodes, in the Team view.
- * It represents expandable subsystem factories such as "Files" or "iSeries Objects".
- */
-public class SystemTeamViewSubSystemConfigurationNode implements IAdaptable
-{
- private String mementoHandle;
- private ISystemProfile profile;
- private ISubSystemConfiguration ssf;
- private SystemTeamViewCategoryNode parentCategory;
- private String name = null;
-
- /**
- * Constructor
- */
- public SystemTeamViewSubSystemConfigurationNode(ISystemProfile profile, SystemTeamViewCategoryNode parentCategory, ISubSystemConfiguration ssf)
- {
- super();
- this.profile = profile;
- this.ssf = ssf;
- this.parentCategory = parentCategory;
- }
-
- /**
- * This is the method required by the IAdaptable interface.
- * Given an adapter class type, return an object castable to the type, or
- * null if this is not possible.
- */
- public Object getAdapter(Class adapterType)
- {
- return Platform.getAdapterManager().getAdapter(this, adapterType);
- }
-
- /**
- * Compare this node to another.
- */
- public boolean equals(Object o)
- {
- if (o instanceof SystemTeamViewSubSystemConfigurationNode)
- {
- SystemTeamViewSubSystemConfigurationNode other = (SystemTeamViewSubSystemConfigurationNode)o;
- if ((ssf == other.getSubSystemConfiguration()) &&
- (parentCategory == other.getParentCategory()) &&
- (profile == other.getProfile()))
- return true;
- else
- return false;
- }
- else
- return super.equals(o);
- }
-
- /**
- * Return this node's image
- * @return the image to show in the tree, for this node
- */
- public ImageDescriptor getImageDescriptor()
- {
- ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssf.getAdapter(ISubSystemConfigurationAdapter.class);
- if (adapter != null) {
- return adapter.getImage(ssf);
- } else {
- // Fall back to using the Proxy -- see also
- // SystemViewSubSystemAdapter.getImageDescriptor()
- ISubSystemConfigurationProxy proxy = ssf.getSubSystemConfigurationProxy();
- SubSystemConfigurationProxyAdapter proxyAdapter = (SubSystemConfigurationProxyAdapter) Platform.getAdapterManager().getAdapter(proxy,
- SubSystemConfigurationProxyAdapter.class);
- if (proxyAdapter != null) {
- return proxyAdapter.getImageDescriptor();
- } else {
- SystemBasePlugin.logWarning("Unexpected error: SubSystemConfiguration has no adapter and no proxyAdapter: " + ssf.getId()); //$NON-NLS-1$
- return null;
- }
- }
- }
-
- /**
- * Return this node's label
- * @return the translated label to show in the tree, for this node
- */
- public String getLabel()
- {
- if (name == null)
- {
- StringBuffer buf = new StringBuffer();
- buf.append(ssf.getName());
- buf.append(" ("); //$NON-NLS-1$
- if (ssf.getSubSystemConfigurationProxy().supportsAllSystemTypes())
- {
- buf.append(SystemResources.TERM_ALL);
- }
- else
- {
- IRSESystemType[] types = ssf.getSystemTypes();
- for (int idx=0; idx<types.length; idx++)
- {
- if (idx>0) buf.append(", "); //$NON-NLS-1$
- buf.append(types[idx].getLabel());
- }
- }
- buf.append(")"); //$NON-NLS-1$
- name = buf.toString();
- }
- return name;
- }
-
- /**
- * Convert to string. We call getLabel()
- */
- public String toString()
- {
- return getLabel();
- }
-
- /**
- * @return profile this category is associated with
- */
- public ISystemProfile getProfile()
- {
- return profile;
- }
-
- /**
- * @param profile ... the profile this category is associated with
- */
- public void setProfile(ISystemProfile profile)
- {
- this.profile = profile;
- }
-
- /**
- * @return the untranslated value to store in the memento, to uniquely identify this node
- */
- public String getMementoHandle()
- {
- return mementoHandle;
- }
-
- /**
- * Set the untranslated value to store in the memento, to uniquely identify this node
- * @param string - untranslated value
- */
- public void setMementoHandle(String string)
- {
- mementoHandle = string;
- }
-
- /**
- * Return the subsystem factory this node represents
- */
- public ISubSystemConfiguration getSubSystemConfiguration()
- {
- return ssf;
- }
-
- /**
- * Set the subsystem factory this node represents
- */
- public void setSubSystemConfiguration(ISubSystemConfiguration factory)
- {
- ssf = factory;
- }
-
- /**
- * Return the parent category this is a child of.
- */
- public SystemTeamViewCategoryNode getParentCategory()
- {
- return parentCategory;
- }
-
- /**
- * Set the parent category this is a child of.
- */
- public void setParentCategory(SystemTeamViewCategoryNode node)
- {
- parentCategory = node;
- }
-
-} \ No newline at end of file

Back to the top