From 5271285e0ab605e589963b553785fd102d3f70d7 Mon Sep 17 00:00:00 2001 From: Tobias Schwarz Date: Fri, 13 Dec 2013 10:22:07 +0100 Subject: Target Explorer: rework peer model --- .../eclipse/tcf/te/runtime/model/ModelNode.java | 2 +- .../te/runtime/model/interfaces/IModelNode.java | 8 +- .../properties/IPropertiesContainer.java | 11 + .../te/runtime/properties/PropertiesContainer.java | 2 +- .../plugin.xml | 126 ++-- .../core/internal/operations/OpParsePath.java | 14 +- .../core/internal/operations/OpUser.java | 334 ++++---- .../internal/testers/TargetPropertyTester.java | 136 ++-- .../core/internal/url/TcfURLConnection.java | 6 +- .../filesystem/core/model/AbstractTreeNode.java | 6 +- .../tcf/te/tcf/filesystem/core/model/FSModel.java | 20 +- .../plugin.xml | 10 +- .../ui/controls/FSNavigatorContentProvider.java | 172 ++--- .../ui/controls/NavigatorContentProvider.java | 14 +- .../filesystem/ui/dialogs/FSOpenFileDialog.java | 6 +- .../adapters/FSTreeNodeAdapterFactory.java | 18 +- .../ui/internal/adapters/FSTreeNodeFactory.java | 12 +- .../ui/internal/adapters/PeerModelViewerInput.java | 40 - .../ui/internal/adapters/PeerNodeViewerInput.java | 40 + .../adapters/ViewerInputAdapterFactory.java | 162 ++-- .../ui/internal/handlers/MoveFilesHandler.java | 110 +-- .../ui/internal/handlers/RefreshViewerHandler.java | 92 +-- .../ui/internal/pages/FSExplorerEditorPage.java | 10 +- .../ui/internal/tabbed/BasicFolderSection.java | 10 +- .../internal/tabbed/LinuxPermissionsSection.java | 10 +- .../tabbed/WindowsAttributesCESection.java | 10 +- .../internal/tabbed/WindowsAttributesSection.java | 10 +- .../ui/internal/tabbed/WindowsFolderAISection.java | 10 +- .../ui/internal/wizards/NewNodeWizard.java | 20 +- .../ui/internal/wizards/NewNodeWizardPage.java | 8 +- .../ui/internal/wizards/TargetPatternFilter.java | 6 +- .../ui/internal/wizards/TargetSelectionPage.java | 24 +- .../org.eclipse.tcf.te.tcf.launch.core/plugin.xml | 462 ++++++------ .../tcf/te/tcf/launch/core/delegates/Launch.java | 4 +- .../core/internal/adapters/AdapterFactory.java | 18 +- .../adapters/AttachLaunchConfigAdapter.java | 4 +- .../services/ExportPersistenceService.java | 6 +- .../core/internal/services/PathMapService.java | 8 +- .../launch/core/steps/AbstractTcfLaunchStep.java | 18 +- .../AbstractTcfLaunchStepGroupIterator.java | 18 +- .../org.eclipse.tcf.te.tcf.launch.ui/plugin.xml | 14 +- .../AbstractTcfLaunchTabContainerEditorPage.java | 66 +- .../te/tcf/launch/ui/editor/PathMapEditorPage.java | 14 +- .../te/tcf/launch/ui/editor/tabs/PathMapTab.java | 10 +- .../handler/AbstractDiagnosticsCommandHandler.java | 14 +- .../AbstractLaunchContextMainTab.java | 6 +- .../META-INF/MANIFEST.MF | 1 - .../org.eclipse.tcf.te.tcf.locator/plugin.xml | 35 +- .../org/eclipse/tcf/te/tcf/locator/Scanner.java | 22 +- .../tcf/te/tcf/locator/ScannerRunnable.java | 70 +- .../tcf/locator/activator/CoreBundleActivator.java | 4 +- .../te/tcf/locator/interfaces/IModelListener.java | 8 +- .../tcf/te/tcf/locator/interfaces/ITracing.java | 2 +- .../locator/interfaces/nodes/ILocatorModel.java | 158 ---- .../tcf/locator/interfaces/nodes/IPeerModel.java | 152 +++- .../interfaces/nodes/IPeerModelProperties.java | 135 ---- .../interfaces/nodes/IPeerModelProvider.java | 26 - .../te/tcf/locator/interfaces/nodes/IPeerNode.java | 59 ++ .../interfaces/nodes/IPeerNodeProperties.java | 141 ++++ .../interfaces/nodes/IPeerNodeProvider.java | 26 + .../services/IDefaultContextService.java | 18 +- .../services/ILocatorModelLookupService.java | 90 --- .../ILocatorModelPeerNodeQueryService.java | 67 -- .../services/ILocatorModelRefreshService.java | 41 - .../interfaces/services/ILocatorModelService.java | 27 - .../services/ILocatorModelUpdateService.java | 81 -- .../services/IPeerModelLookupService.java | 90 +++ .../services/IPeerModelQueryService.java | 67 ++ .../services/IPeerModelRefreshService.java | 41 + .../interfaces/services/IPeerModelService.java | 26 + .../services/IPeerModelUpdateService.java | 81 ++ .../internal/LocatorModelPropertyTester.java | 228 ------ .../locator/internal/ModelNodeFactoryDelegate.java | 129 ++-- .../locator/internal/PeerModelPropertyTester.java | 228 ++++++ .../locator/internal/SimulatorPropertyTester.java | 8 +- .../locator/internal/adapters/AdapterFactory.java | 38 +- .../internal/adapters/PeerModelStepContext.java | 67 -- .../internal/adapters/PeerNodeStepContext.java | 67 ++ .../adapters/PeerPersistableURIProvider.java | 218 +++--- .../locator/internal/nodes/InvalidPeerModel.java | 538 ------------- .../internal/services/PropertiesAccessService.java | 24 +- .../AbstractPeerModelStepGroupIterator.java | 46 -- .../AbstractPeerNodeStepGroupIterator.java | 46 ++ .../locator/iterators/StartDebuggerIterator.java | 10 +- .../locator/iterators/StartSimulatorIterator.java | 100 +-- .../listener/ChannelStateChangeListener.java | 28 +- .../te/tcf/locator/listener/LocatorListener.java | 87 +-- .../tcf/te/tcf/locator/listener/ModelAdapter.java | 8 +- .../eclipse/tcf/te/tcf/locator/model/Model.java | 32 +- .../te/tcf/locator/nodes/ConnectablePeerModel.java | 179 ----- .../tcf/te/tcf/locator/nodes/LocatorModel.java | 785 ------------------- .../tcf/te/tcf/locator/nodes/PeerModel.java | 839 ++++++++++++++++----- .../eclipse/tcf/te/tcf/locator/nodes/PeerNode.java | 405 ++++++++++ .../persistence/GsonPeerPersistenceDelegate.java | 30 +- .../services/AbstractLocatorModelService.java | 42 -- .../locator/services/AbstractPeerModelService.java | 42 ++ .../locator/services/AbstractSimulatorService.java | 6 +- .../services/LocatorModelLookupService.java | 250 ------ .../services/LocatorModelPeerNodeQueryService.java | 246 ------ .../services/LocatorModelRefreshService.java | 620 --------------- .../services/LocatorModelUpdateService.java | 259 ------- .../locator/services/PeerModelLookupService.java | 247 ++++++ .../locator/services/PeerModelQueryService.java | 246 ++++++ .../locator/services/PeerModelRefreshService.java | 599 +++++++++++++++ .../locator/services/PeerModelUpdateService.java | 259 +++++++ .../locator/services/StepperOperationService.java | 10 +- .../selection/RuntimeServiceContextFilter.java | 16 +- .../tcf/locator/steps/AbstractPeerModelStep.java | 45 -- .../te/tcf/locator/steps/AbstractPeerNodeStep.java | 45 ++ .../tcf/te/tcf/locator/steps/CheckServiceStep.java | 6 +- .../tcf/locator/steps/SetAsDefaultContextStep.java | 2 +- .../te/tcf/locator/steps/SetWaitForReadyStep.java | 12 +- .../locator/steps/SignalPeerDisconnectedStep.java | 12 +- .../te/tcf/locator/steps/StartDebuggerStep.java | 20 +- .../te/tcf/locator/steps/StartSimulatorStep.java | 2 +- .../tcf/te/tcf/locator/steps/StopDebuggerStep.java | 110 +-- .../te/tcf/locator/steps/StopSimulatorStep.java | 90 +-- .../tcf/te/tcf/locator/steps/WaitForReadyStep.java | 10 +- .../tcf/te/tcf/locator/utils/SimulatorUtils.java | 50 +- .../core/activator/CoreBundleActivator.java | 242 +++--- .../te/tcf/processes/core/model/ModelManager.java | 26 +- .../model/interfaces/runtime/IRuntimeModel.java | 4 +- .../core/model/listener/ModelListener.java | 6 +- .../core/model/nodes/ProcessContextNode.java | 20 +- .../processes/core/model/runtime/RuntimeModel.java | 18 +- .../services/RuntimeModelChannelService.java | 4 +- .../tcf/processes/core/model/steps/AttachStep.java | 34 +- .../tcf/processes/core/model/steps/DetachStep.java | 6 +- .../processes/core/model/steps/TerminateStep.java | 6 +- .../org.eclipse.tcf.te.tcf.processes.ui/plugin.xml | 30 +- .../ui/editor/ProcessMonitorEditorPage.java | 10 +- .../processes/ui/editor/tree/ContentProvider.java | 12 +- .../ui/editor/tree/columns/PIDLabelProvider.java | 8 +- .../ui/editor/tree/columns/PPIDLabelProvider.java | 8 +- .../te/tcf/processes/ui/handler/AttachHandler.java | 24 +- .../handler/ConfigIntervalDynamicContribution.java | 8 +- .../ui/handler/ConfigRefreshIntervalHandler.java | 4 +- .../ui/handler/EditorHandlerDelegate.java | 4 +- .../ui/handler/RefreshProcessListHandler.java | 6 +- .../tcf/processes/ui/handler/TerminateHandler.java | 4 +- .../ui/interfaces/IProcessMonitorUIDelegate.java | 4 +- .../ui/internal/adapters/AdapterFactory.java | 10 +- .../ui/internal/dialogs/IntervalConfigDialog.java | 6 +- .../ui/internal/properties/ContextPage.java | 12 +- .../properties/GeneralInformationPage.java | 16 +- .../ui/internal/tabbed/BasicContextSection.java | 4 +- .../internal/tabbed/BasicInformationSection.java | 4 +- .../ui/internal/tabbed/ContextIDSection.java | 14 +- .../processes/ui/internal/tabbed/IDSection.java | 12 +- .../ui/internal/tabbed/MemorySection.java | 4 +- .../ui/navigator/runtime/ContentProvider.java | 8 +- .../navigator/runtime/LabelProviderDelegate.java | 4 +- .../tcf/processes/ui/search/ProcessSearchable.java | 18 +- .../services/contexts/internal/AdapterFactory.java | 184 ++--- .../org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml | 2 +- .../ui/launcher/TerminalsLauncherDelegate.java | 10 +- .../ui/launcher/TerminalsMementoHandler.java | 22 +- .../tcf/te/tcf/ui/views/scriptpad/ScriptPad.java | 18 +- .../tcf/ui/views/scriptpad/actions/PeerAction.java | 18 +- .../scriptpad/actions/PeersSubMenuAction.java | 22 +- .../tcf/ui/views/scriptpad/actions/PlayAction.java | 10 +- .../plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml | 48 +- .../ui/actions/AbstractPeerTypeToolbarAction.java | 64 +- .../eclipse/tcf/te/tcf/ui/activator/UIPlugin.java | 22 +- .../controls/DefaultContextStatusTrimControl.java | 14 +- .../te/tcf/ui/dialogs/AgentSelectionDialog.java | 370 --------- .../tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java | 287 +++++++ .../ui/dialogs/RedirectAgentSelectionDialog.java | 71 -- .../ui/dialogs/RedirectPeerSelectionDialog.java | 71 ++ .../ui/editor/AbstractConfigurationEditorPage.java | 19 +- .../tcf/te/tcf/ui/editor/OverviewEditorPage.java | 23 +- .../tcf/ui/editor/sections/AttributesSection.java | 50 +- .../editor/sections/GeneralInformationSection.java | 57 +- .../te/tcf/ui/editor/sections/ServicesSection.java | 30 +- .../ui/editor/sections/TcpTransportSection.java | 46 +- .../tcf/ui/editor/sections/TransportSection.java | 44 +- .../te/tcf/ui/filter/PeersByCurrentUserFilter.java | 12 +- .../tcf/te/tcf/ui/filter/RedirectPeersFilter.java | 96 +-- .../te/tcf/ui/filter/UnreachablePeersFilter.java | 104 +-- .../AbstractPeerModelEditorHandlerDelegate.java | 36 - .../AbstractPeerNodeEditorHandlerDelegate.java | 36 + .../tcf/te/tcf/ui/handler/DeleteHandler.java | 120 +-- .../tcf/te/tcf/ui/handler/RedirectHandler.java | 46 +- .../tcf/te/tcf/ui/handler/RefreshHandler.java | 24 +- .../tcf/te/tcf/ui/handler/RenameHandler.java | 24 +- .../te/tcf/ui/handler/ResetRedirectHandler.java | 36 +- .../tcf/ui/handler/StartDebugCommandHandler.java | 22 +- .../tcf/te/tcf/ui/help/IContextHelpIds.java | 2 +- .../tcf/te/tcf/ui/internal/PropertyTester.java | 6 +- .../tcf/ui/internal/adapters/AdapterFactory.java | 10 +- .../ui/internal/adapters/CategorizableAdapter.java | 33 +- .../ui/internal/adapters/EditorSaveAsAdapter.java | 26 +- .../tcf/ui/internal/adapters/PeerModelFactory.java | 80 -- .../tcf/ui/internal/adapters/PeerNodeFactory.java | 80 ++ .../ui/internal/adapters/PersistablePeerModel.java | 54 -- .../ui/internal/adapters/PersistablePeerNode.java | 47 ++ .../internal/services/DefaultContextService.java | 70 +- .../tcf/ui/internal/tabbed/PeerGeneralSection.java | 10 +- .../tabbed/PeerGeneralSectionContentProvider.java | 12 +- .../internal/tabbed/PeerGeneralSectionFilter.java | 4 +- .../tcf/te/tcf/ui/navigator/ContentProvider.java | 150 ++-- .../tcf/te/tcf/ui/navigator/ModelListener.java | 22 +- .../ui/navigator/PeerLabelProviderDelegate.java | 45 +- .../te/tcf/ui/navigator/TreeViewerListener.java | 20 +- .../tcf/te/tcf/ui/navigator/dnd/CommonDnD.java | 32 +- .../te/tcf/ui/navigator/events/EventListener.java | 4 +- .../te/tcf/ui/navigator/filter/GenericFilter.java | 8 +- .../ui/navigator/images/PeerImageDescriptor.java | 8 +- .../sections/AbstractContextSelectorSection.java | 12 +- .../ui/sections/SimulatorTypeSelectionSection.java | 99 ++- .../tcf/te/tcf/ui/tabbed/BaseTitledSection.java | 18 +- .../te/tcf/ui/wizards/AbstractConfigWizard.java | 26 +- .../tcf/te/tcf/ui/wizards/NewTargetWizard.java | 14 +- .../ui/wizards/pages/AbstractConfigWizardPage.java | 14 +- .../tcf/ui/wizards/pages/NewTargetWizardPage.java | 10 +- .../tcf/ui/wizards/pages/PeerExportWizardPage.java | 22 +- .../tcf/ui/wizards/pages/PeerImportWizardPage.java | 32 +- .../org/eclipse/tcf/te/tests/tcf/TcfTestCase.java | 22 +- .../te/tests/tcf/filesystem/FSPeerTestCase.java | 358 ++++----- .../tcf/filesystem/adapters/AdaptersTests.java | 48 +- .../adapters/PeerModelViewerInputTest.java | 23 - .../adapters/PeerNodeViewerInputTest.java | 23 + .../adapters/ViewerInputAdapterFactoryTest.java | 42 +- .../testers/TargetPropertyTesterTest.java | 54 +- .../tcf/te/tests/tcf/launch/TcfLaunchTests.java | 2 +- .../tcf/processes/model/ProcessModelTestCase.java | 6 +- .../tcf/te/tests/tcf/tests/TcfStepperTests.java | 160 ++-- .../org.eclipse.tcf.te.ui.terminals/plugin.xml | 2 +- .../plugins/org.eclipse.tcf.te.ui/plugin.xml | 4 +- .../ui/handler/AbstractEditorCommandHandler.java | 85 +++ .../ui/handler/AbstractStepperCommandHandler.java | 9 +- .../te/ui/handler/ConnectableCommandHandler.java | 9 +- .../src/org/eclipse/tcf/te/ui/nls/Messages.java | 3 + .../org/eclipse/tcf/te/ui/nls/Messages.properties | 4 + 234 files changed, 7243 insertions(+), 8214 deletions(-) delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PeerModelViewerInput.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PeerNodeViewerInput.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/ILocatorModel.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProvider.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProvider.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelLookupService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelPeerNodeQueryService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelRefreshService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelUpdateService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelLookupService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelQueryService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelRefreshService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelUpdateService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/LocatorModelPropertyTester.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelStepContext.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerNodeStepContext.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerModelStepGroupIterator.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerNodeStepGroupIterator.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractLocatorModelService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractPeerModelService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelUpdateService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelLookupService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelQueryService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelRefreshService.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelUpdateService.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerModelStep.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerNodeStep.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectAgentSelectionDialog.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectPeerSelectionDialog.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerModelEditorHandlerDelegate.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerNodeEditorHandlerDelegate.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PeerModelFactory.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PeerNodeFactory.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PersistablePeerModel.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PersistablePeerNode.java delete mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/PeerModelViewerInputTest.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/PeerNodeViewerInputTest.java create mode 100644 target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractEditorCommandHandler.java diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/ModelNode.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/ModelNode.java index 5e025f0d6..34ba099db 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/ModelNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/ModelNode.java @@ -120,7 +120,7 @@ public class ModelNode extends PropertiesContainer implements IModelNode, IModel */ @Override public boolean isVisible() { - return getBooleanProperty(PROPERTY_IS_VISIBLE); + return getBooleanProperty(PROPERTY_VISIBLE); } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/IModelNode.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/IModelNode.java index 0fb549d40..fac1e816f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/IModelNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.model/src/org/eclipse/tcf/te/runtime/model/interfaces/IModelNode.java @@ -28,24 +28,24 @@ public interface IModelNode extends IPropertiesContainer, ISchedulingRule { * It can be identical to the node object instance UUID, but * can be any other string or might be not even set. */ - public static final String PROPERTY_ID = "id"; //$NON-NLS-1$ + public static final String PROPERTY_ID = "id" + PERSISTENT_PROPERTY; //$NON-NLS-1$ /** * Property: Model node name. May be used to represent the node * in UI widgets. */ - public static final String PROPERTY_NAME = "name"; //$NON-NLS-1$ + public static final String PROPERTY_NAME = "name" + PERSISTENT_PROPERTY; //$NON-NLS-1$ /** * Property: Model node visible state. May be used to hide the node * in UI widgets like lists, tables or trees. */ - public static final String PROPERTY_IS_VISIBLE = "isVisible"; //$NON-NLS-1$ + public static final String PROPERTY_VISIBLE = "visible" + PERSISTENT_PROPERTY; //$NON-NLS-1$ /** * Property: Type. May be used to group nodes or set an node type id. */ - public static final String PROPERTY_TYPE = "type"; //$NON-NLS-1$ + public static final String PROPERTY_TYPE = "type" + PERSISTENT_PROPERTY; //$NON-NLS-1$ /** * Property: Type label. May be used to represent the group or node diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/interfaces/properties/IPropertiesContainer.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/interfaces/properties/IPropertiesContainer.java index 53d902eb4..de8fe96b6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/interfaces/properties/IPropertiesContainer.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/interfaces/properties/IPropertiesContainer.java @@ -19,6 +19,17 @@ import org.eclipse.core.runtime.IAdaptable; */ public interface IPropertiesContainer extends IAdaptable { + /** + * If a property key ends with ".silent", no change events will be fired. + */ + public static final String SILENT_PROPERTY = ".silent"; //$NON-NLS-1$ + + /** + * If a property key ends with ".persistent", it should be persisted when the properties container is saved. + * This string should always be used at the end of all other property key extensions! + */ + public static final String PERSISTENT_PROPERTY = ""; //$NON-NLS-1$ + /** * Returns the unique identified of the properties container. * diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java index 283458491..20b00f4c5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java @@ -222,7 +222,7 @@ public class PropertiesContainer extends PlatformObject implements IPropertiesCo protected boolean dropEvent(Object source, String key, Object oldValue, Object newValue) { Assert.isNotNull(source); Assert.isNotNull(key); - return !changeEventsEnabled || key.endsWith(".silent"); //$NON-NLS-1$ + return !changeEventsEnabled || key.endsWith(SILENT_PROPERTY); } /** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml index 21f8b39c8..4bd6a3acf 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml @@ -1,63 +1,63 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java index 88ad44f73..27b79ea54 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java @@ -26,8 +26,8 @@ import org.eclipse.tcf.te.tcf.filesystem.core.internal.testers.TargetPropertyTes import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; /** @@ -35,7 +35,7 @@ import org.eclipse.tcf.te.tcf.locator.model.Model; */ public class OpParsePath extends Operation { // The peer on which the file is located. - IPeerModel peer; + IPeerNode peer; // The path on the target. String path; // The parsing result. @@ -47,7 +47,7 @@ public class OpParsePath extends Operation { * @param peer The target peer. * @param path The path to be parsed. */ - public OpParsePath(IPeerModel peer, String path) { + public OpParsePath(IPeerNode peer, String path) { this.peer = peer; this.path = path; } @@ -66,21 +66,21 @@ public class OpParsePath extends Operation { String peerId = filePath.substring(0, slash); peerId = peerId.replace(CacheManager.PATH_ESCAPE_CHAR, ':'); - final AtomicReference peerModel = new AtomicReference(); + final AtomicReference peerNode = new AtomicReference(); final String finPeerId = peerId; Runnable runnable = new Runnable() { @Override public void run() { - peerModel.set(Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(finPeerId)); + peerNode.set(Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(finPeerId)); } }; if (Protocol.isDispatchThread()) runnable.run(); else Protocol.invokeAndWait(runnable); - this.peer = peerModel.get(); + this.peer = peerNode.get(); if (peer != null) { boolean hostWindows = Host.isWindowsHost(); boolean windows = TargetPropertyTester.isWindows(peer); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java index 1a43504b4..316eb1fcd 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java @@ -1,167 +1,167 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.osgi.util.NLS; -import org.eclipse.tcf.protocol.IChannel; -import org.eclipse.tcf.protocol.IToken; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.services.IFileSystem; -import org.eclipse.tcf.services.IFileSystem.DoneUser; -import org.eclipse.tcf.services.IFileSystem.FileSystemException; -import org.eclipse.tcf.te.tcf.core.Tcf; -import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFFileSystemException; -import org.eclipse.tcf.te.tcf.filesystem.core.model.UserAccount; -import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * The operation to get the user account of a specified peer. - */ -public class OpUser extends Operation { - // The key to save and retrieve the user account in a peer model. - /* default */ static final String USER_ACCOUNT_KEY = CorePlugin.getUniqueIdentifier()+".user.account"; //$NON-NLS-1$ - - // The target peer. - IPeerModel peerNode; - // The resulting account. - UserAccount result; - - /** - * Create an operation using the target peer. - * @param peerNode The peer whose user account to be checked. - */ - public OpUser(IPeerModel peerNode) { - this.peerNode = peerNode; - } - - /** - * Get the checking result. - * - * @return The user account checked. - */ - public UserAccount getUserAccount() { - return result; - } - - /* - * (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - if(peerNode != null) { - result = getUserFromPeer(peerNode); - if (result == null) { - final UserAccount[] accounts = new UserAccount[1]; - IChannel channel = null; - try { - channel = Operation.openChannel(peerNode.getPeer()); - if (channel != null) { - accounts[0] = getUserByChannel(channel); - if (accounts[0] != null) setUserToPeer(peerNode, accounts[0]); - } - } - catch (TCFException e) { - throw new InvocationTargetException(e); - } - finally { - if (channel != null) Tcf.getChannelManager().closeChannel(channel); - } - result = accounts[0]; - } - } - } - - /** - * Get the user account from the peer using the channel connected to the - * remote target. - * - * @param channel - * The channel connected to the remote target. - * @return The user account information or null if it fails. - */ - UserAccount getUserByChannel(final IChannel channel) throws TCFFileSystemException { - IFileSystem service = Operation.getBlockingFileSystem(channel); - if (service != null) { - final TCFFileSystemException[] errors = new TCFFileSystemException[1]; - final UserAccount[] accounts = new UserAccount[1]; - service.user(new DoneUser() { - @Override - public void doneUser(IToken token, FileSystemException error, int real_uid, int effective_uid, int real_gid, int effective_gid, String home) { - if (error == null) { - accounts[0] = new UserAccount(real_uid, real_gid, effective_uid, effective_gid, home); - }else { - errors[0] = newTCFException(IStatus.WARNING, error); - } - } - }); - if (errors[0] != null) { - throw errors[0]; - } - return accounts[0]; - } - String message = NLS.bind(Messages.Operation_NoFileSystemError, channel.getRemotePeer().getID()); - throw new TCFFileSystemException(IStatus.ERROR, message); - } - - /** - * Get the user account stored in the specified peer model using a key named - * "user.account" defined by the constant USER_ACCOUNT_KEY. - * - * @param peer - * The peer model from which the user account is retrieved. - * @return The user account if it exists or null if not. - */ - private UserAccount getUserFromPeer(final IPeerModel peer) { - Assert.isNotNull(peer); - if (Protocol.isDispatchThread()) { - return (UserAccount) peer.getProperty(USER_ACCOUNT_KEY); - } - final UserAccount[] accounts = new UserAccount[1]; - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - accounts[0] = (UserAccount) peer.getProperty(USER_ACCOUNT_KEY); - } - }); - return accounts[0]; - } - - /** - * Save the user account to the specified peer model using a key named - * "user.account" defined by the constant USER_ACCOUNT_KEY. - * - * @param peer - * The peer model to which the user account is saved. - */ - void setUserToPeer(final IPeerModel peer, final UserAccount account) { - Assert.isNotNull(peer); - Assert.isNotNull(account); - - if (Protocol.isDispatchThread()) { - peer.setProperty(USER_ACCOUNT_KEY, account); - } else { - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - peer.setProperty(USER_ACCOUNT_KEY, account); - } - }); - } - } -} +/******************************************************************************* + * Copyright (c) 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.services.IFileSystem; +import org.eclipse.tcf.services.IFileSystem.DoneUser; +import org.eclipse.tcf.services.IFileSystem.FileSystemException; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFFileSystemException; +import org.eclipse.tcf.te.tcf.filesystem.core.model.UserAccount; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * The operation to get the user account of a specified peer. + */ +public class OpUser extends Operation { + // The key to save and retrieve the user account in a peer model. + /* default */ static final String USER_ACCOUNT_KEY = CorePlugin.getUniqueIdentifier()+".user.account"; //$NON-NLS-1$ + + // The target peer. + IPeerNode peerNode; + // The resulting account. + UserAccount result; + + /** + * Create an operation using the target peer. + * @param peerNode The peer whose user account to be checked. + */ + public OpUser(IPeerNode peerNode) { + this.peerNode = peerNode; + } + + /** + * Get the checking result. + * + * @return The user account checked. + */ + public UserAccount getUserAccount() { + return result; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + if(peerNode != null) { + result = getUserFromPeer(peerNode); + if (result == null) { + final UserAccount[] accounts = new UserAccount[1]; + IChannel channel = null; + try { + channel = Operation.openChannel(peerNode.getPeer()); + if (channel != null) { + accounts[0] = getUserByChannel(channel); + if (accounts[0] != null) setUserToPeer(peerNode, accounts[0]); + } + } + catch (TCFException e) { + throw new InvocationTargetException(e); + } + finally { + if (channel != null) Tcf.getChannelManager().closeChannel(channel); + } + result = accounts[0]; + } + } + } + + /** + * Get the user account from the peer using the channel connected to the + * remote target. + * + * @param channel + * The channel connected to the remote target. + * @return The user account information or null if it fails. + */ + UserAccount getUserByChannel(final IChannel channel) throws TCFFileSystemException { + IFileSystem service = Operation.getBlockingFileSystem(channel); + if (service != null) { + final TCFFileSystemException[] errors = new TCFFileSystemException[1]; + final UserAccount[] accounts = new UserAccount[1]; + service.user(new DoneUser() { + @Override + public void doneUser(IToken token, FileSystemException error, int real_uid, int effective_uid, int real_gid, int effective_gid, String home) { + if (error == null) { + accounts[0] = new UserAccount(real_uid, real_gid, effective_uid, effective_gid, home); + }else { + errors[0] = newTCFException(IStatus.WARNING, error); + } + } + }); + if (errors[0] != null) { + throw errors[0]; + } + return accounts[0]; + } + String message = NLS.bind(Messages.Operation_NoFileSystemError, channel.getRemotePeer().getID()); + throw new TCFFileSystemException(IStatus.ERROR, message); + } + + /** + * Get the user account stored in the specified peer model using a key named + * "user.account" defined by the constant USER_ACCOUNT_KEY. + * + * @param peer + * The peer model from which the user account is retrieved. + * @return The user account if it exists or null if not. + */ + private UserAccount getUserFromPeer(final IPeerNode peer) { + Assert.isNotNull(peer); + if (Protocol.isDispatchThread()) { + return (UserAccount) peer.getProperty(USER_ACCOUNT_KEY); + } + final UserAccount[] accounts = new UserAccount[1]; + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + accounts[0] = (UserAccount) peer.getProperty(USER_ACCOUNT_KEY); + } + }); + return accounts[0]; + } + + /** + * Save the user account to the specified peer model using a key named + * "user.account" defined by the constant USER_ACCOUNT_KEY. + * + * @param peer + * The peer model to which the user account is saved. + */ + void setUserToPeer(final IPeerNode peer, final UserAccount account) { + Assert.isNotNull(peer); + Assert.isNotNull(account); + + if (Protocol.isDispatchThread()) { + peer.setProperty(USER_ACCOUNT_KEY, account); + } else { + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + peer.setProperty(USER_ACCOUNT_KEY, account); + } + }); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java index c7775f6c6..5f240fce1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java @@ -1,68 +1,68 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.filesystem.core.internal.testers; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * The property tester to test if the target OS is a Windows OS. - */ -public class TargetPropertyTester extends PropertyTester { - - /* - * (non-Javadoc) - * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) - */ - @Override - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if(receiver instanceof IPeerModel) { - final IPeerModel peerModel = (IPeerModel) receiver; - if(property.equals("isWindows")) { //$NON-NLS-1$ - return isWindows(peerModel); - } - } - return false; - } - - /** - * Test if the target represented by the peer model is a windows target. - * - * @param peerModel The peer model of the target. - * @return true if it is a windows target. - */ - public static boolean isWindows(final IPeerModel peerModel) { - final String osName = getOSName(peerModel); - return osName == null ? false : (osName.startsWith("Windows")); //$NON-NLS-1$ - } - - /** - * Get the OS name from the peer model. - * - * @param peerModel The peer model. - * @return OS name. - */ - public static String getOSName(final IPeerModel peerModel) { - final String[] osName = new String[1]; - if (Protocol.isDispatchThread()) { - osName[0] = peerModel.getPeer().getOSName(); - } - else { - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - osName[0] = peerModel.getPeer().getOSName(); - } - }); - } - return osName[0]; - } -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.core.internal.testers; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * The property tester to test if the target OS is a Windows OS. + */ +public class TargetPropertyTester extends PropertyTester { + + /* + * (non-Javadoc) + * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) + */ + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if(receiver instanceof IPeerNode) { + final IPeerNode peerNode = (IPeerNode) receiver; + if(property.equals("isWindows")) { //$NON-NLS-1$ + return isWindows(peerNode); + } + } + return false; + } + + /** + * Test if the target represented by the peer model is a windows target. + * + * @param peerNode The peer model of the target. + * @return true if it is a windows target. + */ + public static boolean isWindows(final IPeerNode peerNode) { + final String osName = getOSName(peerNode); + return osName == null ? false : (osName.startsWith("Windows")); //$NON-NLS-1$ + } + + /** + * Get the OS name from the peer model. + * + * @param peerNode The peer model. + * @return OS name. + */ + public static String getOSName(final IPeerNode peerNode) { + final String[] osName = new String[1]; + if (Protocol.isDispatchThread()) { + osName[0] = peerNode.getPeer().getOSName(); + } + else { + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + osName[0] = peerNode.getPeer().getOSName(); + } + }); + } + return osName[0]; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java index 33fc6a3f1..fe60d29ad 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java @@ -32,8 +32,8 @@ import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFChannelException; import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation; import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; /** @@ -117,7 +117,7 @@ public class TcfURLConnection extends URLConnection { public void run() { IPeer p = Protocol.getLocator().getPeers().get(peerId); if (p == null) { - IPeerModel peerNode = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId); + IPeerNode peerNode = Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(peerId); if (peerNode != null) p = peerNode.getPeer(); } peer.set(p); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java index d0172ba98..9e490d632 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java @@ -23,7 +23,7 @@ import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel; import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.NullOpExecutor; import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpUser; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * The base class of FSTreeNode and ProcessTreeNode which provides base members and methods. @@ -45,7 +45,7 @@ public abstract class AbstractTreeNode extends PlatformObject { /** * The peer node the file system tree node is associated with. */ - public IPeerModel peerNode = null; + public IPeerNode peerNode = null; /** * Flag to mark once the children of the node got queried @@ -130,7 +130,7 @@ public abstract class AbstractTreeNode extends PlatformObject { * @param peerNode The peer node of the TCF agent. * @return The user account that runs the agent. */ - protected UserAccount getUserAccount(IPeerModel peerNode) { + protected UserAccount getUserAccount(IPeerNode peerNode) { OpUser user = new OpUser(peerNode); new NullOpExecutor().execute(user); return user.getUserAccount(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSModel.java index 1c5229336..890ce3c3a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSModel.java @@ -14,7 +14,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * The file system model implementation. @@ -26,19 +26,19 @@ public final class FSModel implements ITreeNodeModel { * Get the file system model of the peer model. If it does not * exist yet, create a new instance and store it. * - * @param peerModel The peer model + * @param peerNode The peer model * @return The file system model connected this peer model. */ - public static FSModel getFSModel(final IPeerModel peerModel) { + public static FSModel getFSModel(final IPeerNode peerNode) { final AtomicReference model = new AtomicReference(); Runnable runnable = new Runnable() { @Override public void run() { - if (peerModel != null) { - model.set((FSModel) peerModel.getProperty(FSMODEL_KEY)); + if (peerNode != null) { + model.set((FSModel) peerNode.getProperty(FSMODEL_KEY)); if (model.get() == null) { - model.set(new FSModel(peerModel)); - peerModel.setProperty(FSMODEL_KEY, model.get()); + model.set(new FSModel(peerNode)); + peerNode.setProperty(FSMODEL_KEY, model.get()); } } } @@ -52,11 +52,11 @@ public final class FSModel implements ITreeNodeModel { // The root node of the peer model private FSTreeNode root; - private IPeerModel peerNode; + private IPeerNode peerNode; /** * Create a File System Model. */ - /* default */ FSModel(IPeerModel peerNode) { + /* default */ FSModel(IPeerNode peerNode) { this.peerNode = peerNode; } @@ -100,7 +100,7 @@ public final class FSModel implements ITreeNodeModel { * @param peerNode The peer. * @return The root file system node. */ - public static FSTreeNode createRootNode(IPeerModel peerNode) { + public static FSTreeNode createRootNode(IPeerNode peerNode) { FSTreeNode node = new FSTreeNode(); node.type = "FSRootNode"; //$NON-NLS-1$ node.peerNode = peerNode; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml index a621432cc..ca4084052 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml @@ -27,7 +27,7 @@ priority="normal"> + value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"> - + - + @@ -1878,7 +1878,7 @@ visibleInUI="true"> - + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSNavigatorContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSNavigatorContentProvider.java index dabcbf046..01f7f9f22 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSNavigatorContentProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSNavigatorContentProvider.java @@ -1,86 +1,86 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.filesystem.ui.controls; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel; -import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.core.model.ITreeNodeModel; -import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - - -/** - * File system content provider for the common navigator of Target Explorer. - */ -public class FSNavigatorContentProvider extends NavigatorContentProvider { - - /* - * (non-Javadoc) - * @see org.eclipse.tcf.te.ui.trees.TreeContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - @Override - public void inputChanged(final Viewer viewer, Object oldInput, Object newInput) { - super.inputChanged(viewer, oldInput, newInput); - UIPlugin.getClipboard().addPropertyChangeListener(commonViewerListener); - UIPlugin plugin = UIPlugin.getDefault(); - IPreferenceStore preferenceStore = plugin.getPreferenceStore(); - preferenceStore.addPropertyChangeListener(commonViewerListener); - } - - /* - * (non-Javadoc) - * @see org.eclipse.tcf.te.ui.trees.TreeContentProvider#dispose() - */ - @Override - public void dispose() { - UIPlugin.getClipboard().removePropertyChangeListener(commonViewerListener); - UIPlugin plugin = UIPlugin.getDefault(); - IPreferenceStore preferenceStore = plugin.getPreferenceStore(); - preferenceStore.removePropertyChangeListener(commonViewerListener); - super.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ - @Override - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof FSTreeNode) { - FSTreeNode node = (FSTreeNode)parentElement; - if (node.isFile()) return NO_ELEMENTS; - } - return super.getChildren(parentElement); - } - - /* - * (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.filesystem.ui.controls.NavigatorContentProvider#doGetModel(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) - */ - @Override - protected ITreeNodeModel doGetModel(IPeerModel peerNode) { - return FSModel.getFSModel(peerNode); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) - */ - @Override - public boolean hasChildren(final Object element) { - if (element instanceof FSTreeNode) { - FSTreeNode node = (FSTreeNode)element; - if(node.isFile()) { - return false; - } - } - return super.hasChildren(element); - } -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.ui.controls; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.core.model.ITreeNodeModel; +import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + + +/** + * File system content provider for the common navigator of Target Explorer. + */ +public class FSNavigatorContentProvider extends NavigatorContentProvider { + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.trees.TreeContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + @Override + public void inputChanged(final Viewer viewer, Object oldInput, Object newInput) { + super.inputChanged(viewer, oldInput, newInput); + UIPlugin.getClipboard().addPropertyChangeListener(commonViewerListener); + UIPlugin plugin = UIPlugin.getDefault(); + IPreferenceStore preferenceStore = plugin.getPreferenceStore(); + preferenceStore.addPropertyChangeListener(commonViewerListener); + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.trees.TreeContentProvider#dispose() + */ + @Override + public void dispose() { + UIPlugin.getClipboard().removePropertyChangeListener(commonViewerListener); + UIPlugin plugin = UIPlugin.getDefault(); + IPreferenceStore preferenceStore = plugin.getPreferenceStore(); + preferenceStore.removePropertyChangeListener(commonViewerListener); + super.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ + @Override + public Object[] getChildren(Object parentElement) { + if (parentElement instanceof FSTreeNode) { + FSTreeNode node = (FSTreeNode)parentElement; + if (node.isFile()) return NO_ELEMENTS; + } + return super.getChildren(parentElement); + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.filesystem.ui.controls.NavigatorContentProvider#doGetModel(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) + */ + @Override + protected ITreeNodeModel doGetModel(IPeerNode peerNode) { + return FSModel.getFSModel(peerNode); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + @Override + public boolean hasChildren(final Object element) { + if (element instanceof FSTreeNode) { + FSTreeNode node = (FSTreeNode)element; + if(node.isFile()) { + return false; + } + } + return super.hasChildren(element); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java index d6bb7a3fa..2d6f04816 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java @@ -18,7 +18,7 @@ import org.eclipse.jface.viewers.TreeExpansionEvent; import org.eclipse.jface.viewers.Viewer; import org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode; import org.eclipse.tcf.te.tcf.filesystem.core.model.ITreeNodeModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** @@ -96,8 +96,8 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl public Object[] getChildren(Object parentElement) { super.getChildren(parentElement); - if (parentElement instanceof IPeerModel) { - final IPeerModel peerNode = (IPeerModel)parentElement; + if (parentElement instanceof IPeerNode) { + final IPeerNode peerNode = (IPeerNode)parentElement; ITreeNodeModel model = doGetModel(peerNode); if (isRootNodeVisible()) { AbstractTreeNode root = model.getRoot(); @@ -128,7 +128,7 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl * @param peerNode The peer node from where to get the model. * @return The tree node model. */ - protected abstract ITreeNodeModel doGetModel(IPeerModel peerNode); + protected abstract ITreeNodeModel doGetModel(IPeerNode peerNode); /* (non-Javadoc) * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) @@ -148,9 +148,9 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl hasChildren = !node.childrenQueried || super.hasChildren(element); } } - else if (element instanceof IPeerModel) { - IPeerModel peerModel = (IPeerModel) element; - ITreeNodeModel model = doGetModel(peerModel); + else if (element instanceof IPeerNode) { + IPeerNode peerNode = (IPeerNode) element; + ITreeNodeModel model = doGetModel(peerNode); AbstractTreeNode root = model.getRoot(); hasChildren = root != null ? hasChildren(root) : true; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSOpenFileDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSOpenFileDialog.java index 23ed94811..c2e51d531 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSOpenFileDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSOpenFileDialog.java @@ -33,7 +33,7 @@ import org.eclipse.tcf.te.tcf.filesystem.ui.controls.FSTreeViewerSorter; import org.eclipse.tcf.te.tcf.filesystem.ui.interfaces.IFSConstants; import org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementLabelProvider; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.trees.FilterDescriptor; import org.eclipse.tcf.te.ui.trees.Pending; import org.eclipse.tcf.te.ui.trees.ViewerStateManager; @@ -117,9 +117,9 @@ public class FSOpenFileDialog extends ElementTreeSelectionDialog { if (filterPath != null && !"".equals(filterPath.trim())) { //$NON-NLS-1$ IPath path = new Path(filterPath); - if (viewer.getInput() instanceof IPeerModel) { + if (viewer.getInput() instanceof IPeerNode) { Object element = null; - FSModel model = FSModel.getFSModel((IPeerModel)viewer.getInput()); + FSModel model = FSModel.getFSModel((IPeerNode)viewer.getInput()); if (model != null) { FSTreeNode root = model.getRoot(); ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java index 5c9c6772e..647c2974c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java @@ -21,8 +21,8 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin; import org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementLabelProvider; import org.eclipse.tcf.te.tcf.filesystem.ui.internal.search.FSTreeNodeSearchable; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.ui.interfaces.ILazyLoader; import org.eclipse.tcf.te.ui.interfaces.ISearchable; import org.eclipse.ui.IActionFilter; @@ -36,13 +36,13 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory { // The fFilters map caching fFilters for FS nodes. private Map filters; - public static class FSTreeNodePeerModelProvider extends PlatformObject implements IPeerModelProvider { + public static class FSTreeNodePeerNodeProvider extends PlatformObject implements IPeerNodeProvider { private final FSTreeNode node; /** * Constructor */ - public FSTreeNodePeerModelProvider(FSTreeNode node) { + public FSTreeNodePeerNodeProvider(FSTreeNode node) { Assert.isNotNull(node); this.node = node; } @@ -57,10 +57,10 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory { } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider#getPeerModel() + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider#getPeerModel() */ @Override - public final IPeerModel getPeerModel() { + public final IPeerNode getPeerModel() { return node.peerNode; } } @@ -97,8 +97,8 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory { else if (adapterType == ILazyLoader.class) { return new FSTreeNodeLoader(node); } - else if (adapterType == IPeerModelProvider.class) { - return new FSTreeNodePeerModelProvider(node); + else if (adapterType == IPeerNodeProvider.class) { + return new FSTreeNodePeerNodeProvider(node); } else if (adapterType == ISearchable.class) { return new FSTreeNodeSearchable(node); @@ -113,6 +113,6 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory { */ @Override public Class[] getAdapterList() { - return new Class[] { IActionFilter.class, ILabelProvider.class, IPersistableElement.class, ILazyLoader.class, ISearchable.class, IPeerModelProvider.class }; + return new Class[] { IActionFilter.class, ILabelProvider.class, IPersistableElement.class, ILazyLoader.class, ISearchable.class, IPeerNodeProvider.class }; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeFactory.java index 41b2ff90d..28d3a43cd 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeFactory.java @@ -15,8 +15,8 @@ import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor; import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.NullOpExecutor; import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpParsePath; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.ui.IElementFactory; import org.eclipse.ui.IMemento; @@ -33,13 +33,13 @@ public class FSTreeNodeFactory implements IElementFactory { @Override public IAdaptable createElement(IMemento memento) { String peerId = memento.getString("peerId"); //$NON-NLS-1$ - IPeerModel peerModel = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId); - if(peerModel != null) { + IPeerNode peerNode = Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(peerId); + if(peerNode != null) { String path = memento.getString("path"); //$NON-NLS-1$ if(path == null) { - return FSModel.getFSModel(peerModel).getRoot(); + return FSModel.getFSModel(peerNode).getRoot(); } - OpParsePath op = new OpParsePath(peerModel, path); + OpParsePath op = new OpParsePath(peerNode, path); IOpExecutor executor = new NullOpExecutor(); IStatus status = executor.execute(op); if(status.isOK()) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PeerModelViewerInput.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PeerModelViewerInput.java deleted file mode 100644 index 9647c23c7..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PeerModelViewerInput.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters; - -import org.eclipse.tcf.te.core.interfaces.IViewerInput; -import org.eclipse.tcf.te.core.utils.PropertyChangeProvider; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * The viewer input of an IPeerModel instance. - */ -public class PeerModelViewerInput extends PropertyChangeProvider implements IViewerInput { - // The peer model. - private IPeerModel peerModel; - - /** - * Create an instance with a peer model. - * - * @param peerModel The peer model. - */ - public PeerModelViewerInput(IPeerModel peerModel) { - this.peerModel = peerModel; - } - - /* - * (non-Javadoc) - * @see org.eclipse.tcf.te.ui.interfaces.IViewerInput#getInputId() - */ - @Override - public String getInputId() { - return peerModel.getPeerId(); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PeerNodeViewerInput.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PeerNodeViewerInput.java new file mode 100644 index 000000000..119bd25d9 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PeerNodeViewerInput.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters; + +import org.eclipse.tcf.te.core.interfaces.IViewerInput; +import org.eclipse.tcf.te.core.utils.PropertyChangeProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * The viewer input of an IPeerNode instance. + */ +public class PeerNodeViewerInput extends PropertyChangeProvider implements IViewerInput { + // The peer model. + private IPeerNode peerNode; + + /** + * Create an instance with a peer model. + * + * @param peerNode The peer model. + */ + public PeerNodeViewerInput(IPeerNode peerNode) { + this.peerNode = peerNode; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.interfaces.IViewerInput#getInputId() + */ + @Override + public String getInputId() { + return peerNode.getPeerId(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/ViewerInputAdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/ViewerInputAdapterFactory.java index 9ea010e75..730b93328 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/ViewerInputAdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/ViewerInputAdapterFactory.java @@ -1,81 +1,81 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters; - -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider; -import org.eclipse.tcf.te.core.interfaces.IViewerInput; -import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * The adapter factory for IViewerInput. - */ -public class ViewerInputAdapterFactory implements IAdapterFactory { - // The key to store and access the the viewer input object. - private static final String VIEWER_INPUT_KEY = UIPlugin.getUniqueIdentifier()+".peer.viewerInput"; //$NON-NLS-1$ - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - @Override - public Object getAdapter(Object adaptableObject, Class adapterType) { - if(adaptableObject instanceof IPeerModel) { - if (IViewerInput.class.equals(adapterType) - || IPropertyChangeProvider.class.equals(adapterType)) { - IPeerModel peerModel = (IPeerModel) adaptableObject; - return getViewerInput(peerModel); - } - } - return null; - } - - /** - * Get a viewer input from the specified peer model. - * - * @param peerModel The peer model to get the viewer input from. - * @return The peer model's viewer input. - */ - PeerModelViewerInput getViewerInput(final IPeerModel peerModel) { - if (peerModel != null) { - if (Protocol.isDispatchThread()) { - PeerModelViewerInput model = (PeerModelViewerInput) peerModel.getProperty(VIEWER_INPUT_KEY); - if (model == null) { - model = new PeerModelViewerInput(peerModel); - peerModel.setProperty(VIEWER_INPUT_KEY, model); - } - return model; - } - final AtomicReference reference = new AtomicReference(); - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - reference.set(getViewerInput(peerModel)); - } - }); - return reference.get(); - } - return null; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - @Override - public Class[] getAdapterList() { - return new Class[] { IViewerInput.class, IPropertyChangeProvider.class }; - } - -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters; + +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider; +import org.eclipse.tcf.te.core.interfaces.IViewerInput; +import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * The adapter factory for IViewerInput. + */ +public class ViewerInputAdapterFactory implements IAdapterFactory { + // The key to store and access the the viewer input object. + private static final String VIEWER_INPUT_KEY = UIPlugin.getUniqueIdentifier()+".peer.viewerInput"; //$NON-NLS-1$ + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + if(adaptableObject instanceof IPeerNode) { + if (IViewerInput.class.equals(adapterType) + || IPropertyChangeProvider.class.equals(adapterType)) { + IPeerNode peerNode = (IPeerNode) adaptableObject; + return getViewerInput(peerNode); + } + } + return null; + } + + /** + * Get a viewer input from the specified peer model. + * + * @param peerNode The peer model to get the viewer input from. + * @return The peer model's viewer input. + */ + PeerNodeViewerInput getViewerInput(final IPeerNode peerNode) { + if (peerNode != null) { + if (Protocol.isDispatchThread()) { + PeerNodeViewerInput model = (PeerNodeViewerInput) peerNode.getProperty(VIEWER_INPUT_KEY); + if (model == null) { + model = new PeerNodeViewerInput(peerNode); + peerNode.setProperty(VIEWER_INPUT_KEY, model); + } + return model; + } + final AtomicReference reference = new AtomicReference(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + reference.set(getViewerInput(peerNode)); + } + }); + return reference.get(); + } + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + @Override + public Class[] getAdapterList() { + return new Class[] { IViewerInput.class, IPropertyChangeProvider.class }; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/MoveFilesHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/MoveFilesHandler.java index 8cf95664e..9f8b01d22 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/MoveFilesHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/MoveFilesHandler.java @@ -1,55 +1,55 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers; - -import java.util.List; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpMove; -import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSFolderSelectionDialog; -import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.ui.handlers.HandlerUtil; -/** - * The handler that moves the selected files or folders to a destination folder. - */ -public class MoveFilesHandler extends AbstractHandler { - - /* - * (non-Javadoc) - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Shell shell = HandlerUtil.getActiveShellChecked(event); - FSFolderSelectionDialog dialog = new FSFolderSelectionDialog(shell); - IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); - List nodes = selection.toList(); - IPeerModel peer = nodes.get(0).peerNode; - dialog.setInput(peer); - dialog.setMovedNodes(nodes); - if (dialog.open() == Window.OK) { - Object obj = dialog.getFirstResult(); - Assert.isTrue(obj instanceof FSTreeNode); - FSTreeNode dest = (FSTreeNode) obj; - IOpExecutor executor = new UiExecutor(); - executor.execute(new OpMove(nodes, dest, new MoveCopyCallback())); - } - return null; - } -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers; + +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpMove; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSFolderSelectionDialog; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.ui.handlers.HandlerUtil; +/** + * The handler that moves the selected files or folders to a destination folder. + */ +public class MoveFilesHandler extends AbstractHandler { + + /* + * (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Shell shell = HandlerUtil.getActiveShellChecked(event); + FSFolderSelectionDialog dialog = new FSFolderSelectionDialog(shell); + IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); + List nodes = selection.toList(); + IPeerNode peer = nodes.get(0).peerNode; + dialog.setInput(peer); + dialog.setMovedNodes(nodes); + if (dialog.open() == Window.OK) { + Object obj = dialog.getFirstResult(); + Assert.isTrue(obj instanceof FSTreeNode); + FSTreeNode dest = (FSTreeNode) obj; + IOpExecutor executor = new UiExecutor(); + executor.execute(new OpMove(nodes, dest, new MoveCopyCallback())); + } + return null; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/RefreshViewerHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/RefreshViewerHandler.java index b3ee59200..2cbd52133 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/RefreshViewerHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/RefreshViewerHandler.java @@ -1,46 +1,46 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.JobExecutor; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRefresh; -import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel; -import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.handlers.HandlerUtil; - -/** - * The action handler to refresh the whole file system tree. - */ -public class RefreshViewerHandler extends AbstractHandler { - - /* - * (non-Javadoc) - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorInput editorInput = HandlerUtil.getActiveEditorInputChecked(event); - IPeerModel peer = (IPeerModel) editorInput.getAdapter(IPeerModel.class); - if (peer != null) { - FSTreeNode root = FSModel.getFSModel(peer).getRoot(); - if (root != null) { - IOpExecutor executor = new JobExecutor(); - executor.execute(new OpRefresh(root)); - } - } - return null; - } -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.JobExecutor; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRefresh; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * The action handler to refresh the whole file system tree. + */ +public class RefreshViewerHandler extends AbstractHandler { + + /* + * (non-Javadoc) + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + IEditorInput editorInput = HandlerUtil.getActiveEditorInputChecked(event); + IPeerNode peer = (IPeerNode) editorInput.getAdapter(IPeerNode.class); + if (peer != null) { + FSTreeNode root = FSModel.getFSModel(peer).getRoot(); + if (root != null) { + IOpExecutor executor = new JobExecutor(); + executor.execute(new OpRefresh(root)); + } + } + return null; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/pages/FSExplorerEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/pages/FSExplorerEditorPage.java index c23c01bbd..81cb41916 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/pages/FSExplorerEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/pages/FSExplorerEditorPage.java @@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.pages; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.views.editor.pages.TreeViewerExplorerEditorPage; /** * The editor page for the file system explorer. @@ -62,10 +62,10 @@ public class FSExplorerEditorPage extends TreeViewerExplorerEditorPage { @Override protected Object getViewerInput() { Object element = getEditorInputNode(); - IPeerModel peerModel = element instanceof IPeerModel ? (IPeerModel)element : null; - if (peerModel == null && element instanceof IAdaptable) { - peerModel = (IPeerModel)((IAdaptable)element).getAdapter(IPeerModel.class); + IPeerNode peerNode = element instanceof IPeerNode ? (IPeerNode)element : null; + if (peerNode == null && element instanceof IAdaptable) { + peerNode = (IPeerNode)((IAdaptable)element).getAdapter(IPeerNode.class); } - return peerModel != null ? FSModel.getFSModel(peerModel).getRoot() : null; + return peerNode != null ? FSModel.getFSModel(peerNode).getRoot() : null; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java index 1376ff9be..9336a1e0c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java @@ -18,9 +18,9 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerModelProvider; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerNodeProvider; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; @@ -63,9 +63,9 @@ public class BasicFolderSection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { - Assert.isTrue(input instanceof FSTreeNodePeerModelProvider); - this.node = ((FSTreeNodePeerModelProvider)input).getFSTreeNode(); + protected void updateInput(IPeerNodeProvider input) { + Assert.isTrue(input instanceof FSTreeNodePeerNodeProvider); + this.node = ((FSTreeNodePeerNodeProvider)input).getFSTreeNode(); this.clone = (FSTreeNode) node.clone(); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java index 519ecfaa7..f95012413 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java @@ -18,9 +18,9 @@ import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerModelProvider; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerNodeProvider; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; @@ -109,9 +109,9 @@ public class LinuxPermissionsSection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { - Assert.isTrue(input instanceof FSTreeNodePeerModelProvider); - this.node = ((FSTreeNodePeerModelProvider)input).getFSTreeNode(); + protected void updateInput(IPeerNodeProvider input) { + Assert.isTrue(input instanceof FSTreeNodePeerNodeProvider); + this.node = ((FSTreeNodePeerNodeProvider)input).getFSTreeNode(); this.clone = (FSTreeNode) node.clone(); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java index 2a555f1bb..852bda7d4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java @@ -17,9 +17,9 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IWindowsFileAttributes; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerModelProvider; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerNodeProvider; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; @@ -66,9 +66,9 @@ public class WindowsAttributesCESection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { - Assert.isTrue(input instanceof FSTreeNodePeerModelProvider); - this.node = ((FSTreeNodePeerModelProvider)input).getFSTreeNode(); + protected void updateInput(IPeerNodeProvider input) { + Assert.isTrue(input instanceof FSTreeNodePeerNodeProvider); + this.node = ((FSTreeNodePeerNodeProvider)input).getFSTreeNode(); } /* diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java index 02298c6d9..cda8af8b4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java @@ -16,9 +16,9 @@ import org.eclipse.swt.layout.FormData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerModelProvider; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerNodeProvider; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; @@ -65,9 +65,9 @@ public class WindowsAttributesSection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { - Assert.isTrue(input instanceof FSTreeNodePeerModelProvider); - this.node = ((FSTreeNodePeerModelProvider)input).getFSTreeNode(); + protected void updateInput(IPeerNodeProvider input) { + Assert.isTrue(input instanceof FSTreeNodePeerNodeProvider); + this.node = ((FSTreeNodePeerNodeProvider)input).getFSTreeNode(); this.clone = (FSTreeNode) node.clone(); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java index a3e421b0e..0ed1f1b0a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java @@ -17,9 +17,9 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IWindowsFileAttributes; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerModelProvider; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerNodeProvider; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; @@ -86,9 +86,9 @@ public class WindowsFolderAISection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { - Assert.isTrue(input instanceof FSTreeNodePeerModelProvider); - this.node = ((FSTreeNodePeerModelProvider)input).getFSTreeNode(); + protected void updateInput(IPeerNodeProvider input) { + Assert.isTrue(input instanceof FSTreeNodePeerNodeProvider); + this.node = ((FSTreeNodePeerNodeProvider)input).getFSTreeNode(); } /* diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizard.java index 6d9d1031b..68a106cd9 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizard.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizard.java @@ -20,8 +20,8 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreate; import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.ui.views.editor.pages.TreeViewerExplorerEditorPage; import org.eclipse.tcf.te.ui.wizards.AbstractWizard; import org.eclipse.ui.INewWizard; @@ -40,7 +40,7 @@ public abstract class NewNodeWizard extends AbstractWizard implements INewWizard // The folder in which the new node is created. private FSTreeNode folder; // The target peer where the new node is created. - private IPeerModel peer; + private IPeerNode peer; // The wizard page used to create the new node. private NewNodeWizardPage newPage; @@ -70,9 +70,9 @@ public abstract class NewNodeWizard extends AbstractWizard implements INewWizard } peer = folder.peerNode; } - else if (element instanceof IPeerModel) { - if(hasFileSystem((IPeerModel) element)) { - peer = (IPeerModel) element; + else if (element instanceof IPeerNode) { + if(hasFileSystem((IPeerNode) element)) { + peer = (IPeerNode) element; } } } @@ -84,10 +84,10 @@ public abstract class NewNodeWizard extends AbstractWizard implements INewWizard * @param peer The target peer. * @return true if it has a file system service. */ - public boolean hasFileSystem(final IPeerModel peer) { + public boolean hasFileSystem(final IPeerNode peer) { if(Protocol.isDispatchThread()) { String services = null; - services = peer.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES); + services = peer.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES); if (services != null) { // Lookup each service individually for (String service : services.split(",")) { //$NON-NLS-1$ @@ -225,7 +225,7 @@ public abstract class NewNodeWizard extends AbstractWizard implements INewWizard * * @return The target peer selected. */ - public IPeerModel getPeer(){ + public IPeerNode getPeer(){ return peer; } @@ -234,7 +234,7 @@ public abstract class NewNodeWizard extends AbstractWizard implements INewWizard * * @param peer The newly selected target peer. */ - public void setPeer(IPeerModel peer) { + public void setPeer(IPeerNode peer) { this.peer = peer; newPage.setPeer(peer); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java index 139f6b07a..7eb07a21a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java @@ -35,7 +35,7 @@ import org.eclipse.tcf.te.tcf.filesystem.ui.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.filesystem.ui.interfaces.IFSConstants; import org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementLabelProvider; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl; import org.eclipse.tcf.te.ui.forms.FormLayoutFactory; import org.eclipse.tcf.te.ui.trees.FilterDescriptor; @@ -172,7 +172,7 @@ public abstract class NewNodeWizardPage extends AbstractValidatingWizardPage { treeViewer.setLabelProvider(createDecoratingLabelProvider(new FSTreeElementLabelProvider())); treeViewer.setComparator(new FSTreeViewerSorter()); treeViewer.addFilter(new DirectoryFilter()); - IPeerModel peer = wizard.getPeer(); + IPeerNode peer = wizard.getPeer(); if (peer != null) { setInput(peer); } @@ -276,7 +276,7 @@ public abstract class NewNodeWizardPage extends AbstractValidatingWizardPage { * * @param peer The new target peer. */ - public void setPeer(IPeerModel peer) { + public void setPeer(IPeerNode peer) { if (peer != null) { setInput(peer); } @@ -345,7 +345,7 @@ public abstract class NewNodeWizardPage extends AbstractValidatingWizardPage { */ public FSTreeNode getInputDir() { NewNodeWizard wizard = getWizard(); - IPeerModel peer = wizard.getPeer(); + IPeerNode peer = wizard.getPeer(); if (peer == null) return null; final String text = folderControl.getEditFieldControlText(); if (text != null) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java index 148d55b61..be97de72f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java @@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.wizards; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; import org.eclipse.ui.dialogs.PatternFilter; @@ -37,7 +37,7 @@ public class TargetPatternFilter extends PatternFilter { */ @Override public boolean isElementSelectable(Object element) { - return element instanceof IPeerModel; + return element instanceof IPeerNode; } /* @@ -46,7 +46,7 @@ public class TargetPatternFilter extends PatternFilter { */ @Override protected boolean isLeafMatch(Viewer viewer, Object element) { - if ( element instanceof IPeerModel) { + if ( element instanceof IPeerNode) { String text = targetLabelProvider.getText(element); if (wordMatches(text)) { return true; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java index 1bb6c1056..49b36bc30 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java @@ -36,9 +36,9 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.navigator.ContentProvider; import org.eclipse.tcf.te.ui.activator.UIPlugin; @@ -99,12 +99,12 @@ public class TargetSelectionPage extends AbstractValidatingWizardPage { */ private void initialize() { // Refresh the information of remote services. - ILocatorModel model = Model.getModel(); + IPeerModel model = Model.getModel(); Assert.isNotNull(model); - IPeerModel[] peers = model.getPeers(); + IPeerNode[] peers = model.getPeers(); if (peers != null) { - ILocatorModelPeerNodeQueryService service = model.getService(ILocatorModelPeerNodeQueryService.class); - for (IPeerModel peer : peers) { + IPeerModelQueryService service = model.getService(IPeerModelQueryService.class); + for (IPeerNode peer : peers) { service.queryRemoteServices(peer); } } @@ -178,8 +178,8 @@ public class TargetSelectionPage extends AbstractValidatingWizardPage { ViewerFilter fsPeerFilter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof IPeerModel) { - IPeerModel peer = (IPeerModel) element; + if (element instanceof IPeerNode) { + IPeerNode peer = (IPeerNode) element; @@ -204,7 +204,7 @@ public class TargetSelectionPage extends AbstractValidatingWizardPage { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); // The tree is single selection, so look for the first element only. Object element = selection.getFirstElement(); - if (element instanceof IPeerModel) { + if (element instanceof IPeerNode) { // Double-click on a connection type is triggering the sub wizard getWizard().getContainer().showPage(getNextPage()); } @@ -220,7 +220,7 @@ public class TargetSelectionPage extends AbstractValidatingWizardPage { treeViewer.setInput(Model.getModel()); NewNodeWizard wizard = getWizard(); - IPeerModel peer = wizard.getPeer(); + IPeerNode peer = wizard.getPeer(); if (wizard.getPeer() != null) { treeViewer.setSelection(new StructuredSelection(peer), true); } @@ -267,8 +267,8 @@ public class TargetSelectionPage extends AbstractValidatingWizardPage { IStructuredSelection filteredTreeSelection = (IStructuredSelection) filteredTree .getViewer().getSelection(); NewNodeWizard wizard = getWizard(); - if (filteredTreeSelection.getFirstElement() instanceof IPeerModel) { - wizard.setPeer((IPeerModel) filteredTreeSelection.getFirstElement()); + if (filteredTreeSelection.getFirstElement() instanceof IPeerNode) { + wizard.setPeer((IPeerNode) filteredTreeSelection.getFirstElement()); } else { wizard.setPeer(null); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml index b83757d2d..3fbe5db4f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml @@ -1,231 +1,231 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/Launch.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/Launch.java index d48ec0682..e69a77847 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/Launch.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/Launch.java @@ -32,7 +32,7 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapGeneratorService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Default tcf launch implementation. @@ -70,7 +70,7 @@ public final class Launch extends TCFLaunch { * * @param node The peer model node. Must not be null. */ - public void attachDebugger(IPeerModel node) { + public void attachDebugger(IPeerNode node) { Assert.isNotNull(node); final String name = node.getPeer().getName(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java index e8c6849ba..3db3549ff 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AdapterFactory.java @@ -23,8 +23,8 @@ import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.interfaces.IDisposable; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; /** @@ -97,12 +97,12 @@ public class AdapterFactory implements IAdapterFactory { return adapter; } } - else if (adaptableObject instanceof IPeerModel) { + else if (adaptableObject instanceof IPeerNode) { if (ILaunchConfiguration.class.equals(adapterType)) { - return attachLaunchConfigAdapter.getAttachLaunchConfig((IPeerModel)adaptableObject); + return attachLaunchConfigAdapter.getAttachLaunchConfig((IPeerNode)adaptableObject); } if (ILaunchConfigurationWorkingCopy.class.equals(adapterType)) { - ILaunchConfiguration launchConfig = attachLaunchConfigAdapter.getAttachLaunchConfig((IPeerModel)adaptableObject); + ILaunchConfiguration launchConfig = attachLaunchConfigAdapter.getAttachLaunchConfig((IPeerNode)adaptableObject); try { return launchConfig.getWorkingCopy(); } @@ -112,21 +112,21 @@ public class AdapterFactory implements IAdapterFactory { } } else if (adaptableObject instanceof IPeer) { - final ILocatorModelLookupService service = Model.getModel().getService(ILocatorModelLookupService.class); - final AtomicReference peerModel = new AtomicReference(); + final IPeerModelLookupService service = Model.getModel().getService(IPeerModelLookupService.class); + final AtomicReference peerNode = new AtomicReference(); if (service != null) { Runnable runnable = new Runnable() { @Override public void run() { - peerModel.set(service.lkupPeerModelById(((IPeer)adaptableObject).getID())); + peerNode.set(service.lkupPeerModelById(((IPeer)adaptableObject).getID())); } }; if (Protocol.isDispatchThread()) runnable.run(); else Protocol.invokeAndWait(runnable); } - if (peerModel.get() != null) return getAdapter(peerModel.get(), adapterType); + if (peerNode.get() != null) return getAdapter(peerNode.get(), adapterType); } return null; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AttachLaunchConfigAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AttachLaunchConfigAdapter.java index cdf6b882c..a6dd5ae42 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AttachLaunchConfigAdapter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/AttachLaunchConfigAdapter.java @@ -21,14 +21,14 @@ import org.eclipse.tcf.te.launch.core.selection.LaunchSelection; import org.eclipse.tcf.te.launch.core.selection.RemoteSelectionContext; import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection; import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * AttachLaunchConfigAdapter */ public class AttachLaunchConfigAdapter { - public ILaunchConfiguration getAttachLaunchConfig(IPeerModel peer) { + public ILaunchConfiguration getAttachLaunchConfig(IPeerNode peer) { ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(ILaunchTypes.ATTACH); ILaunchSelection launchSelection = new LaunchSelection(ILaunchManager.DEBUG_MODE, new RemoteSelectionContext(peer, true)); ILaunchManagerDelegate delegate = LaunchManager.getInstance().getLaunchManagerDelegate(launchConfigType, ILaunchManager.DEBUG_MODE); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java index ea67e28fa..6cd0d6476 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java @@ -23,7 +23,7 @@ import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate; import org.eclipse.tcf.te.runtime.persistence.services.URIPersistenceService; import org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService; import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Persistence service implementation for import/export. @@ -46,8 +46,8 @@ public class ExportPersistenceService extends URIPersistenceService implements I throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$ } - if (context instanceof IPeerModel) { - final IPeerModel node = (IPeerModel)context; + if (context instanceof IPeerNode) { + final IPeerNode node = (IPeerNode)context; ILaunchConfiguration launchConfig = (ILaunchConfiguration)Platform.getAdapterManager().getAdapter(node, ILaunchConfiguration.class); if (launchConfig != null) { IPersistenceDelegate launchDelegate = PersistenceManager.getInstance().getDelegate(launchConfig, String.class); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java index 353ff01ed..c79c4bf52 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java @@ -41,8 +41,8 @@ import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapGeneratorService; import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService; import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; /** * Path map service implementation. @@ -307,8 +307,8 @@ public class PathMapService extends AbstractService implements IPathMapService { Assert.isNotNull(callback); IPeer peer = context instanceof IPeer ? (IPeer)context : null; - if (peer == null && context instanceof IPeerModel) peer = ((IPeerModel)context).getPeer(); - if (peer == null && context instanceof IPeerModelProvider && ((IPeerModelProvider)context).getPeerModel() != null) peer = ((IPeerModelProvider)context).getPeerModel().getPeer(); + if (peer == null && context instanceof IPeerNode) peer = ((IPeerNode)context).getPeer(); + if (peer == null && context instanceof IPeerNodeProvider && ((IPeerNodeProvider)context).getPeerModel() != null) peer = ((IPeerNodeProvider)context).getPeerModel().getPeer(); if (peer != null) { final IChannel channel = Tcf.getChannelManager().getChannel(peer); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java index 9b5b73147..0dfa6691b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java @@ -15,7 +15,7 @@ import org.eclipse.tcf.te.launch.core.steps.AbstractLaunchStep; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Abstract TCF launch step implementation. @@ -30,16 +30,16 @@ public abstract class AbstractTcfLaunchStep extends AbstractLaunchStep { * @param fullQualifiedId The full qualfied id for this step. Must not be null. * @return The active peer model context. */ - protected IPeerModel getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) { + protected IPeerNode getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) { Object activeContext = getActiveContext(context, data, fullQualifiedId); - IPeerModel peerModel = null; - if (activeContext instanceof IPeerModel) - return (IPeerModel)activeContext; + IPeerNode peerNode = null; + if (activeContext instanceof IPeerNode) + return (IPeerNode)activeContext; if (activeContext instanceof IAdaptable) - peerModel = (IPeerModel)((IAdaptable)activeContext).getAdapter(IPeerModel.class); - if (peerModel == null) - peerModel = (IPeerModel)Platform.getAdapterManager().getAdapter(activeContext, IPeerModel.class); + peerNode = (IPeerNode)((IAdaptable)activeContext).getAdapter(IPeerNode.class); + if (peerNode == null) + peerNode = (IPeerNode)Platform.getAdapterManager().getAdapter(activeContext, IPeerNode.class); - return peerModel; + return peerNode; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/iterators/AbstractTcfLaunchStepGroupIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/iterators/AbstractTcfLaunchStepGroupIterator.java index 6f0a8b272..10bc9d76e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/iterators/AbstractTcfLaunchStepGroupIterator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/iterators/AbstractTcfLaunchStepGroupIterator.java @@ -16,7 +16,7 @@ import org.eclipse.tcf.te.launch.core.steps.iterators.AbstractLaunchStepGroupIte import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Abstract TCF launch step group iterator. @@ -31,16 +31,16 @@ public abstract class AbstractTcfLaunchStepGroupIterator extends AbstractLaunchS * @param fullQualifiedId The full qualfied id for this step. Must not be null. * @return The active peer model context. */ - protected IPeerModel getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) { + protected IPeerNode getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) { Object activeContext = getActiveContext(context, data, fullQualifiedId); - IPeerModel peerModel = null; - if (activeContext instanceof IPeerModel) - return (IPeerModel)activeContext; + IPeerNode peerNode = null; + if (activeContext instanceof IPeerNode) + return (IPeerNode)activeContext; if (activeContext instanceof IAdaptable) - peerModel = (IPeerModel)((IAdaptable)activeContext).getAdapter(IPeerModel.class); - if (peerModel == null) - peerModel = (IPeerModel)Platform.getAdapterManager().getAdapter(activeContext, IPeerModel.class); + peerNode = (IPeerNode)((IAdaptable)activeContext).getAdapter(IPeerNode.class); + if (peerNode == null) + peerNode = (IPeerNode)Platform.getAdapterManager().getAdapter(activeContext, IPeerNode.class); - return peerModel; + return peerNode; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml index 3a15b2b39..1a2c49a1e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml @@ -11,7 +11,7 @@ bundleId="org.eclipse.tcf.te.runtime.services" class="org.eclipse.tcf.te.runtime.services.interfaces.IDebugService"/> - + @@ -117,7 +117,7 @@ insertAfter="last"> - + @@ -129,7 +129,7 @@ insertBefore="org.eclipse.tcf.te.launch.ui.LaunchEditorPage"> - + @@ -141,7 +141,7 @@ insertBefore="org.eclipse.tcf.te.launch.ui.SourceLookupEditorPage,org.eclipse.tcf.te.launch.ui.LaunchEditorPage"> - + @@ -153,7 +153,7 @@ insertBefore="org.eclipse.tcf.te.tcf.launch.ui.PathMapEditorPage,org.eclipse.tcf.te.launch.ui.SourceLookupEditorPage,org.eclipse.tcf.te.launch.ui.LaunchEditorPage"> - + @@ -183,7 +183,7 @@ labelProvider="org.eclipse.tcf.te.launch.ui.viewer.LaunchTreeLabelProvider" priority="lowest"> - + @@ -218,7 +218,7 @@ - + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java index de8dee592..f8cc02c90 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/AbstractTcfLaunchTabContainerEditorPage.java @@ -23,7 +23,7 @@ import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService; import org.eclipse.tcf.te.tcf.launch.ui.activator.UIPlugin; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * TCF launch configuration tab container page implementation. @@ -41,8 +41,8 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa * @param input The editor input. * @return The peer model. */ - public IPeerModel getPeerModel(Object input) { - return (IPeerModel) ((IAdaptable) input).getAdapter(IPeerModel.class); + public IPeerNode getPeerModel(Object input) { + return (IPeerNode) ((IAdaptable) input).getAdapter(IPeerNode.class); } /* (non-Javadoc) @@ -61,24 +61,24 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa /** * Get the launch configuration from the peer model. * - * @param peerModel The peer model. + * @param peerNode The peer model. * @return The launch configuration. */ - public static ILaunchConfigurationWorkingCopy getLaunchConfig(final IPeerModel peerModel) { + public static ILaunchConfigurationWorkingCopy getLaunchConfig(final IPeerNode peerNode) { ILaunchConfigurationWorkingCopy wc = null; - if (peerModel != null) { - IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); + if (peerNode != null) { + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerNode, IPropertiesAccessService.class); Assert.isNotNull(service); - if (service.getProperty(peerModel, PROP_LAUNCH_CONFIG_WC) instanceof ILaunchConfigurationWorkingCopy) { - wc = (ILaunchConfigurationWorkingCopy) service.getProperty(peerModel, PROP_LAUNCH_CONFIG_WC); + if (service.getProperty(peerNode, PROP_LAUNCH_CONFIG_WC) instanceof ILaunchConfigurationWorkingCopy) { + wc = (ILaunchConfigurationWorkingCopy) service.getProperty(peerNode, PROP_LAUNCH_CONFIG_WC); } else { - wc = (ILaunchConfigurationWorkingCopy) Platform.getAdapterManager().getAdapter(peerModel, ILaunchConfigurationWorkingCopy.class); + wc = (ILaunchConfigurationWorkingCopy) Platform.getAdapterManager().getAdapter(peerNode, ILaunchConfigurationWorkingCopy.class); if (wc == null) { - wc = (ILaunchConfigurationWorkingCopy) Platform.getAdapterManager().loadAdapter(peerModel, "org.eclipse.debug.core.ILaunchConfigurationWorkingCopy"); //$NON-NLS-1$ + wc = (ILaunchConfigurationWorkingCopy) Platform.getAdapterManager().loadAdapter(peerNode, "org.eclipse.debug.core.ILaunchConfigurationWorkingCopy"); //$NON-NLS-1$ } Assert.isNotNull(wc); - service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, wc); + service.setProperty(peerNode, PROP_LAUNCH_CONFIG_WC, wc); IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(wc, String.class); String launchConfigAttributes = null; try { @@ -87,7 +87,7 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa catch (Exception e) { /* ignored on purpose */ } - service.setProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, launchConfigAttributes); + service.setProperty(peerNode, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, launchConfigAttributes); } } return wc; @@ -119,10 +119,10 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa if (wc != null && checkLaunchConfigDirty()) { getLaunchConfigurationTab().performApply(wc); try { - IPeerModel peerModel = getPeerModel(getEditorInput()); - IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); + IPeerNode peerNode = getPeerModel(getEditorInput()); + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerNode, IPropertiesAccessService.class); Assert.isNotNull(service); - service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, null); + service.setProperty(peerNode, PROP_LAUNCH_CONFIG_WC, null); wc.doSave(); onPostSave(wc); checkLaunchConfigDirty(); @@ -141,13 +141,13 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa */ public boolean checkLaunchConfigDirty() { boolean dirty = false; - IPeerModel peerModel = getPeerModel(getEditorInput()); - IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); - String oldLaunchConfigAttributes = (String) service.getProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES); - IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(getLaunchConfig(peerModel), String.class); + IPeerNode peerNode = getPeerModel(getEditorInput()); + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerNode, IPropertiesAccessService.class); + String oldLaunchConfigAttributes = (String) service.getProperty(peerNode, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES); + IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(getLaunchConfig(peerNode), String.class); String launchConfigAttributes = null; try { - launchConfigAttributes = (String) delegate.write(getLaunchConfig(peerModel), String.class); + launchConfigAttributes = (String) delegate.write(getLaunchConfig(peerNode), String.class); dirty = !launchConfigAttributes.equals(oldLaunchConfigAttributes); } catch (Exception e) { @@ -164,9 +164,9 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa if (isAutoSave()) { final ILaunchConfigurationWorkingCopy wc = getLaunchConfig(getPeerModel(getEditorInput())); if (wc != null && dirty) { - IPeerModel peerModel = getPeerModel(getEditorInput()); - IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); - service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, null); + IPeerNode peerNode = getPeerModel(getEditorInput()); + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerNode, IPropertiesAccessService.class); + service.setProperty(peerNode, PROP_LAUNCH_CONFIG_WC, null); try { wc.doSave(); onPostSave(wc); @@ -213,10 +213,10 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa @Override public void dispose() { super.dispose(); - IPeerModel peerModel = getPeerModel(getEditorInput()); - IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); - service.setProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, null); - service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, null); + IPeerNode peerNode = getPeerModel(getEditorInput()); + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerNode, IPropertiesAccessService.class); + service.setProperty(peerNode, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, null); + service.setProperty(peerNode, PROP_LAUNCH_CONFIG_WC, null); DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(this); launchConfigListener = null; } @@ -241,12 +241,12 @@ public abstract class AbstractTcfLaunchTabContainerEditorPage extends AbstractLa @Override public void launchConfigurationChanged(ILaunchConfiguration configuration) { if (!(configuration instanceof ILaunchConfigurationWorkingCopy)) { - IPeerModel peerModel = getPeerModel(getEditorInput()); - IPropertiesAccessService service = ServiceManager.getInstance().getService(peerModel, IPropertiesAccessService.class); - ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) service.getProperty(peerModel, PROP_LAUNCH_CONFIG_WC); + IPeerNode peerNode = getPeerModel(getEditorInput()); + IPropertiesAccessService service = ServiceManager.getInstance().getService(peerNode, IPropertiesAccessService.class); + ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) service.getProperty(peerNode, PROP_LAUNCH_CONFIG_WC); if (wc != null && configuration.getName().equals(wc.getName())) { - service.setProperty(peerModel, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, null); - service.setProperty(peerModel, PROP_LAUNCH_CONFIG_WC, null); + service.setProperty(peerNode, PROP_ORIGINAL_LAUNCH_CONFIG_ATTRIBUTES, null); + service.setProperty(peerNode, PROP_LAUNCH_CONFIG_WC, null); ExecutorsUtil.executeInUI(new Runnable() { @Override public void run() { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java index e44294b28..4835b086f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/PathMapEditorPage.java @@ -27,7 +27,7 @@ import org.eclipse.tcf.te.tcf.launch.ui.activator.UIPlugin; import org.eclipse.tcf.te.tcf.launch.ui.editor.tabs.PathMapTab; import org.eclipse.tcf.te.tcf.launch.ui.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * TCF path map launch configuration tab container page implementation. @@ -49,18 +49,18 @@ public class PathMapEditorPage extends AbstractTcfLaunchTabContainerEditorPage { protected void onPostSave(ILaunchConfiguration config) { Assert.isNotNull(config); - final IPeerModel peerModel = getPeerModel(getEditorInput()); - if (peerModel != null && peerModel.getPeer() != null) { - IPathMapService service = ServiceManager.getInstance().getService(peerModel.getPeer(), IPathMapService.class); + final IPeerNode peerNode = getPeerModel(getEditorInput()); + if (peerNode != null && peerNode.getPeer() != null) { + IPathMapService service = ServiceManager.getInstance().getService(peerNode.getPeer(), IPathMapService.class); if (service != null) { - service.applyPathMap(peerModel.getPeer(), new Callback() { + service.applyPathMap(peerNode.getPeer(), new Callback() { @Override protected void internalDone(Object caller, IStatus status) { if (status != null && status.getSeverity() == IStatus.ERROR) { IStatus status2 = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), - NLS.bind(Messages.PathMapEditorPage_error_apply, peerModel.getName(), status.getMessage()), + NLS.bind(Messages.PathMapEditorPage_error_apply, peerNode.getName(), status.getMessage()), status.getException()); - IStatusHandler[] handlers = StatusHandlerManager.getInstance().getHandler(peerModel); + IStatusHandler[] handlers = StatusHandlerManager.getInstance().getHandler(peerNode); if (handlers.length > 0) { IPropertiesContainer data = new PropertiesContainer(); data.setProperty(IStatusHandlerConstants.PROPERTY_TITLE, Messages.PathMapEditorPage_error_title); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java index 679cd1c42..d7f0bda3a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java @@ -20,7 +20,7 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapGeneratorService; import org.eclipse.tcf.te.tcf.launch.ui.editor.AbstractTcfLaunchTabContainerEditorPage; import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Customized TCF path map launch configuration tab implementation to work better @@ -92,11 +92,11 @@ public class PathMapTab extends TCFPathMapTab { super.initializePathMap(map, config); IModelNode context = LaunchContextsPersistenceDelegate.getFirstLaunchContext(config); - if (context instanceof IPeerModel) { - IPeerModel peerModel = (IPeerModel)context; - IPathMapGeneratorService service = ServiceManager.getInstance().getService(peerModel, IPathMapGeneratorService.class); + if (context instanceof IPeerNode) { + IPeerNode peerNode = (IPeerNode)context; + IPathMapGeneratorService service = ServiceManager.getInstance().getService(peerNode, IPathMapGeneratorService.class); if (service != null) { - IPathMap.PathMapRule[] rules = service.getPathMap(peerModel); + IPathMap.PathMapRule[] rules = service.getPathMap(peerNode); if (rules != null && rules.length > 0) { for (IPathMap.PathMapRule rule : rules) { rule.getProperties().put(PROP_GENERATED, Boolean.TRUE); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/handler/AbstractDiagnosticsCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/handler/AbstractDiagnosticsCommandHandler.java index 323554aac..0bbec8e6c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/handler/AbstractDiagnosticsCommandHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/handler/AbstractDiagnosticsCommandHandler.java @@ -47,8 +47,8 @@ import org.eclipse.tcf.services.IMemoryMap; import org.eclipse.tcf.services.IPathMap; import org.eclipse.tcf.te.tcf.launch.ui.editor.AbstractTcfLaunchTabContainerEditorPage; import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; import org.eclipse.ui.handlers.HandlerUtil; /** @@ -71,11 +71,11 @@ public abstract class AbstractDiagnosticsCommandHandler extends AbstractHandler while (iterator.hasNext()) { Object element = iterator.next(); - // The selected element must be of type IPeerModel - if (element instanceof IPeerModel) { - final IPeerModel node = (IPeerModel)element; + // The selected element must be of type IPeerNode + if (element instanceof IPeerNode) { + final IPeerNode node = (IPeerNode)element; - ILocatorModelPeerNodeQueryService service = node.getModel().getService(ILocatorModelPeerNodeQueryService.class); + IPeerModelQueryService service = node.getModel().getService(IPeerModelQueryService.class); String remoteServices = service != null ? service.queryRemoteServices(node) : null; if (remoteServices != null && remoteServices.contains(IDiagnostics.NAME)) { @@ -101,7 +101,7 @@ public abstract class AbstractDiagnosticsCommandHandler extends AbstractHandler * @param peer The peer. Must not be null. * @param parentShell The parent shell. Must not be null. */ - /* default */ void runDiagnostics(IPeerModel node, Shell parentShell) { + /* default */ void runDiagnostics(IPeerNode node, Shell parentShell) { Assert.isNotNull(node); Assert.isNotNull(parentShell); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/AbstractLaunchContextMainTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/AbstractLaunchContextMainTab.java index 0de7224f1..020e38bbe 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/AbstractLaunchContextMainTab.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/AbstractLaunchContextMainTab.java @@ -28,7 +28,7 @@ import org.eclipse.tcf.te.launch.core.selection.RemoteSelectionContext; import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart; import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab; import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.ui.controls.ContextSelectorSectionControl; import org.eclipse.tcf.te.tcf.ui.sections.AbstractContextSelectorSection; import org.eclipse.tcf.te.ui.views.controls.AbstractContextSelectorControl; @@ -51,7 +51,7 @@ public abstract class AbstractLaunchContextMainTab extends AbstractContextSelect */ @Override public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof IPeerModel) { + if (element instanceof IPeerNode) { String typeId = null; if (configuration != null) { try { @@ -63,7 +63,7 @@ public abstract class AbstractLaunchContextMainTab extends AbstractContextSelect String mode = getLaunchConfigurationDialog().getMode(); if (typeId != null && mode != null) { - return LaunchConfigTypeBindingsManager.getInstance().isValidLaunchConfigType(typeId, mode, new RemoteSelectionContext((IPeerModel)element, true)); + return LaunchConfigTypeBindingsManager.getInstance().isValidLaunchConfigType(typeId, mode, new RemoteSelectionContext((IPeerNode)element, true)); } } return true; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF index 837d3df41..deffea96f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF @@ -29,7 +29,6 @@ Export-Package: org.eclipse.tcf.te.tcf.locator, org.eclipse.tcf.te.tcf.locator.interfaces.services, org.eclipse.tcf.te.tcf.locator.internal;x-internal:=true, org.eclipse.tcf.te.tcf.locator.internal.adapters;x-internal:=true, - org.eclipse.tcf.te.tcf.locator.internal.nodes;x-internal:=true, org.eclipse.tcf.te.tcf.locator.internal.preferences, org.eclipse.tcf.te.tcf.locator.internal.services;x-internal:=true, org.eclipse.tcf.te.tcf.locator.iterators, diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml index c4582a6d0..71ce90d21 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml @@ -13,23 +13,23 @@ - + - + - + @@ -43,22 +43,22 @@ - + + type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"> + type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"> @@ -104,8 +104,8 @@ - - + + @@ -127,7 +127,10 @@ bundleId="org.eclipse.tcf.te.runtime.services" class="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/> - + + + + - + @@ -267,7 +270,7 @@ is adaptable to IPeerModel and has a simulator service --> - + - + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java index 24f488c10..a0adeaa52 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java @@ -29,9 +29,9 @@ import org.eclipse.tcf.te.tcf.core.async.CallbackInvocationDelegate; import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner; import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.model.Model; @@ -40,7 +40,7 @@ import org.eclipse.tcf.te.tcf.locator.model.Model; */ public class Scanner extends Job implements IScanner { // Reference to the parent model instance. - private final ILocatorModel parentModel; + private final IPeerModel parentModel; // Reference to the scanner configuration private final Map configuration = new HashMap(); @@ -53,7 +53,7 @@ public class Scanner extends Job implements IScanner { * * @param parentModel The parent model instance. Must not be null. */ - public Scanner(ILocatorModel parentModel) { + public Scanner(IPeerModel parentModel) { super(Scanner.class.getName()); Assert.isNotNull(parentModel); this.parentModel = parentModel; @@ -68,7 +68,7 @@ public class Scanner extends Job implements IScanner { * * @return The parent model instance. */ - protected ILocatorModel getParentModel() { + protected IPeerModel getParentModel() { return parentModel; } @@ -98,7 +98,7 @@ public class Scanner extends Job implements IScanner { if (monitor == null) monitor = new NullProgressMonitor(); // Get the current list of peers known to the parent model - IPeerModel[] peers = getParentModel().getPeers(); + IPeerNode[] peers = getParentModel().getPeers(); // Do we have something to scan at all if (peers.length > 0) { try { @@ -131,7 +131,7 @@ public class Scanner extends Job implements IScanner { }, new CallbackInvocationDelegate()); // Loop the nodes and try to get an channel - for (IPeerModel peer : peers) { + for (IPeerNode peer : peers) { // Check for the progress monitor getting canceled if (monitor.isCanceled() || isTerminated()) break; // Scan the peer @@ -155,7 +155,7 @@ public class Scanner extends Job implements IScanner { * @param collector The callback collector. Must not be null. * @param monitor The progress monitor. Must not be null. */ - /* default */ void doScan(final IPeerModel peer, final AsyncCallbackCollector collector, final IProgressMonitor monitor) { + /* default */ void doScan(final IPeerNode peer, final AsyncCallbackCollector collector, final IProgressMonitor monitor) { Assert.isNotNull(peer); Assert.isNotNull(collector); Assert.isNotNull(monitor); @@ -174,7 +174,7 @@ public class Scanner extends Job implements IScanner { @Override public void run() { - isExcluded.set(peer.getBooleanProperty(IPeerModelProperties.PROP_SCANNER_EXCLUDE)); + isExcluded.set(peer.getBooleanProperty(IPeerNodeProperties.PROP_SCANNER_EXCLUDE)); } }; @@ -191,9 +191,9 @@ public class Scanner extends Job implements IScanner { if (!monitor.isCanceled() && !isTerminated()) { // Get the children of the scanned peer model and make sure // they are scanned too if not excluded - List candidates = Model.getModel().getChildren(peer.getPeerId()); + List candidates = Model.getModel().getChildren(peer.getPeerId()); if (candidates != null && candidates.size() > 0) { - for (IPeerModel candidate : candidates) { + for (IPeerNode candidate : candidates) { doScan(candidate, collector, monitor); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java index 51fd51b7c..926d67494 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java @@ -37,12 +37,12 @@ import org.eclipse.tcf.te.tcf.core.peers.Peer; import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner; import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; -import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; @@ -55,7 +55,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { // Reference to the parent model scanner private final IScanner parentScanner; // Reference to the peer model node to update - /* default */ final IPeerModel peerNode; + /* default */ final IPeerNode peerNode; // Reference to the channel /* default */ IChannel channel = null; // Mark if the used channel is a shared channel instance @@ -70,7 +70,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { * @param scanner The parent model scanner or null if the runnable is constructed from outside a scanner. * @param peerNode The peer model instance. Must not be null. */ - public ScannerRunnable(IScanner scanner, IPeerModel peerNode) { + public ScannerRunnable(IScanner scanner, IPeerNode peerNode) { this(scanner, peerNode, null); } @@ -81,7 +81,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { * @param peerNode The peer model instance. Must not be null. * @param callback The callback to invoke once the scan has been completed or null. */ - public ScannerRunnable(IScanner scanner, IPeerModel peerNode, ICallback callback) { + public ScannerRunnable(IScanner scanner, IPeerNode peerNode, ICallback callback) { super(); parentScanner = scanner; @@ -193,19 +193,19 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { final boolean changed = peerNode.setChangeEventsEnabled(false); // Set the peer state property - int counter = peerNode.getIntProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER); - if (!peerNode.isProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_WAITING_FOR_READY)) { - peerNode.setProperty(IPeerModelProperties.PROP_STATE, counter > 0 ? IPeerModelProperties.STATE_CONNECTED : IPeerModelProperties.STATE_REACHABLE); - peerNode.setProperty(IPeerModelProperties.PROP_LAST_SCANNER_ERROR, null); + int counter = peerNode.getIntProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER); + if (!peerNode.isProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_WAITING_FOR_READY)) { + peerNode.setProperty(IPeerNodeProperties.PROP_STATE, counter > 0 ? IPeerNodeProperties.STATE_CONNECTED : IPeerNodeProperties.STATE_REACHABLE); + peerNode.setProperty(IPeerNodeProperties.PROP_LAST_SCANNER_ERROR, null); } // Get the parent model from the model mode - final ILocatorModel model = (ILocatorModel)peerNode.getAdapter(ILocatorModel.class); + final IPeerModel model = (IPeerModel)peerNode.getAdapter(IPeerModel.class); if (channel != null && channel.getState() == IChannel.STATE_OPEN) { // Update the services lists - ILocatorModelUpdateService updateService = model != null ? model.getService(ILocatorModelUpdateService.class) : null; + IPeerModelUpdateService updateService = model != null ? model.getService(IPeerModelUpdateService.class) : null; if (updateService != null) { Collection localServices = channel.getLocalServices(); Collection remoteServices = channel.getRemoteServices(); @@ -294,7 +294,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { // Update the peer attributes Map attrs = new HashMap(channel.getRemotePeer().getAttributes()); attrs.put(IPeer.ATTR_AGENT_ID, agentID); - peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, new Peer(attrs)); + peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, new Peer(attrs)); } if (isGetPeersAllowed(channel)) { @@ -367,7 +367,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { * @param callback The callback. Must not be null. */ @SuppressWarnings("unused") - protected void getPeers(final IChannel channel, final ILocatorModel model, final String ip, final ICallback callback) { + protected void getPeers(final IChannel channel, final IPeerModel model, final String ip, final ICallback callback) { Assert.isNotNull(channel); Assert.isNotNull(model); Assert.isNotNull(callback); @@ -404,7 +404,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { // Get the parent peer IPeer parentPeer = channel.getRemotePeer(); // Get the old child list - List oldChildren = new ArrayList(model.getChildren(parentPeer.getID())); + List oldChildren = new ArrayList(model.getChildren(parentPeer.getID())); // "getPeers" returns a collection of peer attribute maps @SuppressWarnings("unchecked") @@ -428,37 +428,27 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { // Create a peer instance IPeer peer = new PeerRedirector(parentPeer, attributes); // Try to find an existing peer node first - IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(parentPeer.getID(), peerId); + IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(parentPeer.getID(), peerId); if (peerNode == null) { // Not yet known -> add it - peerNode = new PeerModel(model, peer); + peerNode = new PeerNode(model, peer); peerNode.setParent(ScannerRunnable.this.peerNode); - peerNode.setProperty(IPeerModelProperties.PROP_SCANNER_EXCLUDE, true); + peerNode.setProperty(IPeerNodeProperties.PROP_SCANNER_EXCLUDE, true); // Validate the peer node before adding peerNode = model.validateChildPeerNodeForAdd(peerNode); if (peerNode != null) { // Add the child peer node to model - model.getService(ILocatorModelUpdateService.class).addChild(peerNode); + model.getService(IPeerModelUpdateService.class).addChild(peerNode); } } else { // The parent node should be set and match - Assert.isTrue(peerNode.getParent(IPeerModel.class) != null && peerNode.getParent(IPeerModel.class).equals(ScannerRunnable.this.peerNode)); + Assert.isTrue(peerNode.getParent(IPeerNode.class) != null && peerNode.getParent(IPeerNode.class).equals(ScannerRunnable.this.peerNode)); // Peer node found, update the peer instance - peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer); + peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer); // And remove it from the old child list oldChildren.remove(peerNode); } } - - // Everything left in the old child list is not longer known to the remote peer - // However, the child list may include manual redirected static peers. Do not - // remove them here. - for (IPeerModel child : oldChildren) { - if (!child.isStatic()) { - // Remove the child peer node from the model - model.getService(ILocatorModelUpdateService.class).removeChild(child); - } - } } // Once everything is processed, close the channel @@ -500,17 +490,17 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { // Turn off change notifications temporarily boolean changed = peerNode.setChangeEventsEnabled(false); - peerNode.setProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER, null); - if (!peerNode.isProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_WAITING_FOR_READY)) { + peerNode.setProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER, null); + if (!peerNode.isProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_WAITING_FOR_READY)) { boolean timeout = error instanceof SocketTimeoutException || (error instanceof ConnectException && error.getMessage() != null && error.getMessage().startsWith("Connection timed out:")); //$NON-NLS-1$ - peerNode.setProperty(IPeerModelProperties.PROP_STATE, timeout ? IPeerModelProperties.STATE_NOT_REACHABLE : IPeerModelProperties.STATE_ERROR); - peerNode.setProperty(IPeerModelProperties.PROP_LAST_SCANNER_ERROR, error instanceof SocketTimeoutException ? null : error); + peerNode.setProperty(IPeerNodeProperties.PROP_STATE, timeout ? IPeerNodeProperties.STATE_NOT_REACHABLE : IPeerNodeProperties.STATE_ERROR); + peerNode.setProperty(IPeerNodeProperties.PROP_LAST_SCANNER_ERROR, error instanceof SocketTimeoutException ? null : error); } // Clear out previously determined services - ILocatorModel model = (ILocatorModel)peerNode.getAdapter(ILocatorModel.class); + IPeerModel model = (IPeerModel)peerNode.getAdapter(IPeerModel.class); if (model != null) { - ILocatorModelUpdateService updateService = model.getService(ILocatorModelUpdateService.class); + IPeerModelUpdateService updateService = model.getService(IPeerModelUpdateService.class); updateService.updatePeerServices(peerNode, null, null); // Clean out possible child nodes @@ -534,7 +524,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { * @param node The peer model node. Must not be null. * @param changed True if the change events shall be enabled, false otherwise. */ - protected void onDone(IPeerModel node, boolean changed) { + protected void onDone(IPeerNode node, boolean changed) { Assert.isNotNull(node); // Reset the scanner runnable marker diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java index 9b25bd98b..5584d8615 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java @@ -13,7 +13,7 @@ import org.eclipse.core.runtime.Plugin; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences; import org.eclipse.tcf.te.runtime.tracing.TraceHandler; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.osgi.framework.BundleContext; @@ -87,7 +87,7 @@ public class CoreBundleActivator extends Plugin { plugin = null; // Dispose the locator model - final ILocatorModel model = Model.getModel(true); + final IPeerModel model = Model.getModel(true); if (model != null) { Runnable runnable = new Runnable() { @Override diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java index c592f5362..18fea6a2d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java @@ -9,8 +9,8 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.locator.interfaces; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Interface for clients to implement that wishes to listen to changes to the locator model. @@ -21,15 +21,15 @@ public interface IModelListener { * Invoked if a peer is added or removed to/from the locator model. * * @param model The changed locator model. - * @param peerModel The added/removed peer model node. + * @param peerNode The added/removed peer model node. * @param added True if the peer model node got added, false if it got removed. */ - public void locatorModelChanged(ILocatorModel model, IPeerModel peerModel, boolean added); + public void locatorModelChanged(IPeerModel model, IPeerNode peerNode, boolean added); /** * Invoked if the locator model is disposed. * * @param model The disposed locator model. */ - public void locatorModelDisposed(ILocatorModel model); + public void locatorModelDisposed(IPeerModel model); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java index b131fbb3b..b8475fb93 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java @@ -18,7 +18,7 @@ public interface ITracing { /** * If enabled, prints information about locator model method invocations. */ - public static String ID_TRACE_LOCATOR_MODEL = "trace/locatorModel"; //$NON-NLS-1$ + public static String ID_TRACE_LOCATOR_MODEL = "trace/peerModel"; //$NON-NLS-1$ /** * If enabled, prints information about locator listener method invocations. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/ILocatorModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/ILocatorModel.java deleted file mode 100644 index 7c89b9d54..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/ILocatorModel.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.interfaces.nodes; - -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.services.ILocator; -import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelService; - - -/** - * The locator model is an extension to the TCF locator service. The - * model allows to store additional properties for each peer, keep - * track of peers from different origins. - *

- * Note: Updates to the locator model, and the locator model - * children needs to be performed in the TCF dispatch thread. The - * locator model and all child model nodes do assert this core - * assumption. To maintain consistency, and to avoid any performance - * overhead for thread synchronization, the model read access must - * happen in the TCF dispatch thread as well. - * - * @see ILocator - */ -public interface ILocatorModel extends IAdaptable { - - /** - * Adds the specified listener to the list of model listener. - * If the same listener has been added before, the listener will - * not be added again. - * - * @param listener The listener. Must not be null. - */ - public void addListener(IModelListener listener); - - /** - * Removes the specified listener from the list of model listener. - * - * @param listener The listener. Must not be null. - */ - public void removeListener(IModelListener listener); - - /** - * Returns the list of registered model listeners. - * - * @return The list of registered model listeners or an empty list. - */ - public IModelListener[] getListener(); - - /** - * Dispose the locator model instance. - */ - public void dispose(); - - /** - * Returns if or if not the locator model instance is disposed. - * - * @return True if the locator model instance is disposed, false/code> otherwise. - */ - public boolean isDisposed(); - - /** - * Returns the list of known peers. - * - * @return The list of known peers or an empty list. - */ - public IPeerModel[] getPeers(); - - /** - * Returns an unmodifiable list of known children for the given parent peer. - * - * @param parentPeerID The parent peer id. Must not be null. - * @return The child list. - */ - public List getChildren(String parentPeerID); - - /** - * Sets the list of known children for the given parent peer. - * - * @param parentPeerID The parent peer id. Must not be null. - * @param children The list of children or null to remove the parent peer. - */ - public void setChildren(String parentPeerID, List children); - - /** - * Returns the scanner instance being associated with the - * locator model. - * - * @return The scanner instance. - */ - public IScanner getScanner(); - - /** - * Starts the scanner. - * - * @param delay The delay in millisecond before the scanning starts. - * @param schedule The time in millisecond between the scanner runs. - */ - public void startScanner(long delay, long schedule); - - /** - * Stops the scanner. - */ - public void stopScanner(); - - /** - * Returns the locator model service, implementing at least the specified - * service interface. - * - * @param serviceInterface The service interface class. Must not be null. - * @return The service instance implementing the specified service interface, or null. - */ - public V getService(Class serviceInterface); - - /** - * Validate the given peer. - *

- * If the peer is for local host, than only the peer using the loopback address is valid. - * - * @param peer The peer. Must not be null. - * @return The peer if the peer is valid, or null if not. - */ - public IPeer validatePeer(IPeer peer); - - /** - * Validate the given peer model if or if not it can be added to the locator model as new peer - * node. - * - * @param node The peer model. Must not be null. - * @return The peer node if it allowed add it to the model, or null if not. - */ - public IPeerModel validatePeerNodeForAdd(IPeerModel node); - - /** - * Validate the given child peer model node if or if not it can be added to the locator model - * as new child peer node for the associated parent peer model node. - *

- * Note: The parent peer node is determined by calling {@link IPeerModel#getParentNode()}. - * The call has to return a non-null value, otherwise {@link #validateChildPeerNodeForAdd(IPeerModel)} - * will do nothing. - * - * @param node The peer model. Must not be null. - * @return The peer node if it allowed add it to the model, or null if not. - */ - public IPeerModel validateChildPeerNodeForAdd(IPeerModel node); - -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java index 310dd1b5d..832f225e7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java @@ -9,80 +9,150 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.locator.interfaces.nodes; +import java.util.List; + +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.te.core.interfaces.IDecoratable; -import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode; +import org.eclipse.tcf.services.ILocator; +import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; +import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelService; + /** - * The peer model is an extension to the TCF peer representation, implementing the {@link IPeer} - * interface. The peer model provides an offline cache for a peers known list of local and remote - * services and is the merge point of peer attributes from custom data storages. + * The locator model is an extension to the TCF locator service. The + * model allows to store additional properties for each peer, keep + * track of peers from different origins. *

- * Note: Read and write access to the peer model must happen within the TCF dispatch thread. + * Note: Updates to the locator model, and the locator model + * children needs to be performed in the TCF dispatch thread. The + * locator model and all child model nodes do assert this core + * assumption. To maintain consistency, and to avoid any performance + * overhead for thread synchronization, the model read access must + * happen in the TCF dispatch thread as well. + * + * @see ILocator */ -public interface IPeerModel extends IContainerModelNode, IDecoratable { +public interface IPeerModel extends IAdaptable { /** - * Returns the parent locator model instance. - *

- * This method may be called from any thread. + * Adds the specified listener to the list of model listener. + * If the same listener has been added before, the listener will + * not be added again. * - * @return The parent locator model instance. + * @param listener The listener. Must not be null. */ - public ILocatorModel getModel(); + public void addListener(IModelListener listener); /** - * Returns the native {@link IPeer} object. - *

- * This method may be called from any thread. + * Removes the specified listener from the list of model listener. * - * @return The native {@link IPeer} instance. + * @param listener The listener. Must not be null. */ - public IPeer getPeer(); + public void removeListener(IModelListener listener); /** - * Returns the peer id. - *

- * This method may be called from any thread. + * Returns the list of registered model listeners. * - * @return The peer id. + * @return The list of registered model listeners or an empty list. */ - public String getPeerId(); + public IModelListener[] getListener(); /** - * Returns the peer id of the remote peer. - *

- * For dynamically discovered peers, {@link #getPeerId()} and {@link #getRemotePeerId()} are identical. - *

- * For static peers, {@link #getRemotePeerId()} will return null if the static peer is not - * associated with an agent. Otherwise it will return the id of the associated agent. + * Dispose the locator model instance. + */ + public void dispose(); + + /** + * Returns if or if not the locator model instance is disposed. + * + * @return True if the locator model instance is disposed, false/code> otherwise. + */ + public boolean isDisposed(); + + /** + * Returns the list of known peers. * - * @return The remote peer id or null. + * @return The list of known peers or an empty list. */ - public String getRemotePeerId(); + public IPeerNode[] getPeers(); /** - * Returns if or if not the peer attributes are complete to open a channel to it. + * Returns an unmodifiable list of known children for the given parent peer. * - * @return True if the peer attributes are complete, false otherwise. + * @param parentPeerID The parent peer id. Must not be null. + * @return The child list. */ - public boolean isComplete(); + public List getChildren(String parentPeerID); /** - * Returns if or if not the peer model node represents a static peer. + * Sets the list of known children for the given parent peer. + * + * @param parentPeerID The parent peer id. Must not be null. + * @param children The list of children or null to remove the parent peer. + */ + public void setChildren(String parentPeerID, List children); + + /** + * Returns the scanner instance being associated with the + * locator model. + * + * @return The scanner instance. + */ + public IScanner getScanner(); + + /** + * Starts the scanner. + * + * @param delay The delay in millisecond before the scanning starts. + * @param schedule The time in millisecond between the scanner runs. + */ + public void startScanner(long delay, long schedule); + + /** + * Stops the scanner. + */ + public void stopScanner(); + + /** + * Returns the locator model service, implementing at least the specified + * service interface. + * + * @param serviceInterface The service interface class. Must not be null. + * @return The service instance implementing the specified service interface, or null. + */ + public V getService(Class serviceInterface); + + /** + * Validate the given peer. *

- * Note: A peer model node can be both static and remote at the same time. + * If the peer is for local host, than only the peer using the loopback address is valid. * - * @return True if the node represents a static peer, false otherwise. + * @param peer The peer. Must not be null. + * @return The peer if the peer is valid, or null if not. */ - public boolean isStatic(); + public IPeer validatePeer(IPeer peer); /** - * Returns if or if not the peer model node represents a remote/discovered peer. + * Validate the given peer model if or if not it can be added to the locator model as new peer + * node. + * + * @param node The peer model. Must not be null. + * @return The peer node if it allowed add it to the model, or null if not. + */ + public IPeerNode validatePeerNodeForAdd(IPeerNode node); + + /** + * Validate the given child peer model node if or if not it can be added to the locator model + * as new child peer node for the associated parent peer model node. *

- * Note: A peer model node can be both static and remote at the same time. + * Note: The parent peer node is determined by calling {@link IPeerNode#getParentNode()}. + * The call has to return a non-null value, otherwise {@link #validateChildPeerNodeForAdd(IPeerNode)} + * will do nothing. * - * @return True if the node represents a remote peer, false otherwise. + * @param node The peer model. Must not be null. + * @return The peer node if it allowed add it to the model, or null if not. */ - public boolean isRemote(); + public IPeerNode validateChildPeerNodeForAdd(IPeerNode node); + } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java deleted file mode 100644 index d20d9ce0e..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.interfaces.nodes; - -import org.eclipse.tcf.protocol.IPeer; - -/** - * Default set of custom peer properties. - */ -public interface IPeerModelProperties { - - /** - * Property: The peer instance. Object stored here must be - * castable to {@link IPeer}. - */ - public static final String PROP_INSTANCE = "instance"; //$NON-NLS-1$ - - /** - * Property: The list of known local service names. - */ - public static final String PROP_LOCAL_SERVICES = "services.local"; //$NON-NLS-1$ - - /** - * Property: The list of known remote service names. - */ - public static final String PROP_REMOTE_SERVICES = "services.remote"; //$NON-NLS-1$ - - /** - * Property: The redirection proxy peer id. - */ - public static final String PROP_REDIRECT_PROXY = "redirect.proxy"; //$NON-NLS-1$ - - /** - * Property: The peer state. - */ - public static final String PROP_STATE = "state"; //$NON-NLS-1$ - - /** - * Peer state: Not determined yet (unknown). - */ - public static final int STATE_UNKNOWN = -1; - - /** - * Peer state: Peer is reachable, no active communication channel is open. - */ - public static final int STATE_REACHABLE = 0; - - /** - * Peer state: Peer is reachable and an active communication channel is opened. - */ - public static final int STATE_CONNECTED = 1; - - /** - * Peer state: Peer is not reachable. Connection attempt timed out. - */ - public static final int STATE_NOT_REACHABLE = 2; - - /** - * Peer state: Peer is not reachable. Connection attempt terminated with error. - */ - public static final int STATE_ERROR = 3; - - /** - * Peer state: Peer is waiting to become ready. - */ - public static final int STATE_WAITING_FOR_READY = 4; - - /** - * Property: The peer type. - */ - public static final String PROP_TYPE = "Type"; //$NON-NLS-1$ - - /** - * Property: List of TCF services the peer would have when it goes online (comma separated list). - */ - public static final String PROP_OFFLINE_SERVICES = "OfflineServices"; //$NON-NLS-1$ - - /** - * Property: The peer visible state. - */ - public static final String PROP_VISIBLE = "Visible"; //$NON-NLS-1$ - - /** - * Property: Reference counter tracking the active channels for this peer. - */ - public static String PROP_CHANNEL_REF_COUNTER = "channelRefCounter.silent"; //$NON-NLS-1$ - - /** - * Property: The last error the scanner encounter trying to open a channel to this peer. - */ - public static String PROP_LAST_SCANNER_ERROR = "lastScannerError"; //$NON-NLS-1$ - - /** - * Property: Launch simulator - */ - public static final String PROP_SIM_ENABLED = "SimulatorEnabled"; //$NON-NLS-1$ - - /** - * Property: Simulator properties - */ - public static final String PROP_SIM_PROPERTIES = "SimulatorProperties"; //$NON-NLS-1$ - - /** - * Property: Last selected simulator type - */ - public static final String PROP_SIM_TYPE = "SimulatorType"; //$NON-NLS-1$ - - /** - * Property: Discovered target for a static peer - */ - public static final String PROP_TARGET = "Target"; //$NON-NLS-1$ - - /** - * Property: Auto-start the debugger after the agent launch. - */ - public static final String PROP_AUTO_START_DEBUGGER = "autoStartDebugger"; //$NON-NLS-1$ - - /** - * Property: Connect after the configuration has been created. - */ - public static final String PROP_AUTO_CONNECT = "autoConnect"; //$NON-NLS-1$ - - /** - * Property: Exclude from scanner process. If set to true, the node will not be scanned - * by the scanner. - */ - public static String PROP_SCANNER_EXCLUDE = "scanner.exclude.silent"; //$NON-NLS-1$ -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProvider.java deleted file mode 100644 index f2174b990..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProvider.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.interfaces.nodes; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * Interface to be implemented by nodes providing access to an peer - * model object instance without being a peer model object itself. - */ -public interface IPeerModelProvider extends IAdaptable { - - /** - * Returns the associated peer model object. - * - * @return The peer model object instance or null. - */ - public IPeerModel getPeerModel(); -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java new file mode 100644 index 000000000..7b8f877a4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.interfaces.nodes; + +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.core.interfaces.IConnectable; +import org.eclipse.tcf.te.core.interfaces.IDecoratable; +import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode; + +/** + * The peer model is an extension to the TCF peer representation, implementing the {@link IPeer} + * interface. The peer model provides an offline cache for a peers known list of local and remote + * services and is the merge point of peer attributes from custom data storages. + *

+ * Note: Read and write access to the peer model must happen within the TCF dispatch thread. + */ +public interface IPeerNode extends IContainerModelNode, IDecoratable, IConnectable { + + /** + * Returns the parent locator model instance. + *

+ * This method may be called from any thread. + * + * @return The parent locator model instance. + */ + public IPeerModel getModel(); + + /** + * Returns the native {@link IPeer} object. + *

+ * This method may be called from any thread. + * + * @return The native {@link IPeer} instance. + */ + public IPeer getPeer(); + + /** + * Returns the peer id. + *

+ * This method may be called from any thread. + * + * @return The peer id. + */ + public String getPeerId(); + + /** + * Returns if or if not the peer attributes are complete to open a channel to it. + * + * @return True if the peer attributes are complete, false otherwise. + */ + public boolean isComplete(); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java new file mode 100644 index 000000000..3e5491003 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.interfaces.nodes; + +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; + +/** + * Default set of peer node properties. + */ +public interface IPeerNodeProperties { + + /** + * Property: The peer node connect state. + */ + public static final String PROP_CONNECT_STATE = "connectState"; //$NON-NLS-1$ + + /** + * Property: The peer instance. Object stored here must be + * castable to {@link IPeer}. + */ + public static final String PROP_INSTANCE = "instance"; //$NON-NLS-1$ + + /** + * Property: The list of known local service names. + */ + public static final String PROP_LOCAL_SERVICES = "services.local"; //$NON-NLS-1$ + + /** + * Property: The list of known remote service names. + */ + public static final String PROP_REMOTE_SERVICES = "services.remote"; //$NON-NLS-1$ + + /** + * Property: The redirection proxy peer id. + */ + public static final String PROP_REDIRECT_PROXY = "redirect.proxy"; //$NON-NLS-1$ + + /** + * Property: The peer state. + */ + public static final String PROP_STATE = "state"; //$NON-NLS-1$ + + /** + * Peer state: Not determined yet (unknown). + */ + public static final int STATE_UNKNOWN = -1; + + /** + * Peer state: Peer is reachable, no active communication channel is open. + */ + public static final int STATE_REACHABLE = 0; + + /** + * Peer state: Peer is reachable and an active communication channel is opened. + */ + public static final int STATE_CONNECTED = 1; + + /** + * Peer state: Peer is not reachable. Connection attempt timed out. + */ + public static final int STATE_NOT_REACHABLE = 2; + + /** + * Peer state: Peer is not reachable. Connection attempt terminated with error. + */ + public static final int STATE_ERROR = 3; + + /** + * Peer state: Peer is waiting to become ready. + */ + public static final int STATE_WAITING_FOR_READY = 4; + + /** + * Property: Reference counter tracking the active channels for this peer. + */ + public static String PROP_CHANNEL_REF_COUNTER = "channelRefCounter.silent"; //$NON-NLS-1$ + + /** + * Property: Discovered target for a static peer + */ + public static final String PROP_TARGET = "Target"; //$NON-NLS-1$ + + /** + * Property: Exclude from scanner process. If set to true, the node will not be scanned + * by the scanner. + */ + public static String PROP_SCANNER_EXCLUDE = "scanner.exclude.silent"; //$NON-NLS-1$ + + /** + * Property: The last error the scanner encounter trying to open a channel to this peer. + */ + public static String PROP_LAST_SCANNER_ERROR = "lastScannerError"; //$NON-NLS-1$ + + /** + * Property: The peer type. + */ + public static final String PROP_TYPE = "Type" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$ + + /** + * Property: List of TCF services the peer would have when it goes online (comma separated list). + */ + public static final String PROP_OFFLINE_SERVICES = "OfflineServices" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$ + + /** + * Property: The peer visible state. + */ + public static final String PROP_VISIBLE = "Visible" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$ + + /** + * Property: Launch simulator + */ + public static final String PROP_SIM_ENABLED = "SimulatorEnabled" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$ + + /** + * Property: Simulator properties + */ + public static final String PROP_SIM_PROPERTIES = "SimulatorProperties" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$ + + /** + * Property: Last selected simulator type + */ + public static final String PROP_SIM_TYPE = "SimulatorType" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$ + + /** + * Property: Auto-start the debugger after the agent launch. + */ + public static final String PROP_AUTO_START_DEBUGGER = "autoStartDebugger" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$ + + /** + * Property: Connect after the configuration has been created. + */ + public static final String PROP_AUTO_CONNECT = "autoConnect"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProvider.java new file mode 100644 index 000000000..82838e8d5 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProvider.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.interfaces.nodes; + +import org.eclipse.core.runtime.IAdaptable; + +/** + * Interface to be implemented by nodes providing access to an peer + * model object instance without being a peer model object itself. + */ +public interface IPeerNodeProvider extends IAdaptable { + + /** + * Returns the associated peer model object. + * + * @return The peer model object instance or null. + */ + public IPeerNode getPeerModel(); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java index 4c9b33b4e..939490c63 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java @@ -10,12 +10,12 @@ package org.eclipse.tcf.te.tcf.locator.interfaces.services; import org.eclipse.tcf.te.runtime.services.interfaces.IService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Interface to implement by services providing a default context for others. *

- * The context type of the service is {@link IPeerModel}. + * The context type of the service is {@link IPeerNode}. */ public interface IDefaultContextService extends IService { @@ -32,17 +32,17 @@ public interface IDefaultContextService extends IService { * If the filter is matched, the peer model node is added to the list * of possible contexts. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @return true if the given peer model node is a possible candidate. */ - public boolean select(IPeerModel peerModel); + public boolean select(IPeerNode peerNode); } /** * Return a list of possible candidates matching the given filter. *

* If a selection is given and the filter applies, the selection will be added first to the - * resulting array of candidates. Otherwise, if a default selection was set using {@link #setDefaultContext(IPeerModel)}, + * resulting array of candidates. Otherwise, if a default selection was set using {@link #setDefaultContext(IPeerNode)}, * and the filter applies, the default selection will added first to the resulting array of * candidates. *

@@ -54,16 +54,16 @@ public interface IDefaultContextService extends IService { * * @return An array of peer model nodes or an empty array. */ - public IPeerModel[] getCandidates(Object selection, IContextFilter filter); + public IPeerNode[] getCandidates(Object selection, IContextFilter filter); /** * Sets the given peer model node as new default context. *

* If the given peer model node is null, the default context is reseted. * - * @param peerModel The peer model node or null. + * @param peerNode The peer model node or null. */ - public void setDefaultContext(IPeerModel peerModel); + public void setDefaultContext(IPeerNode peerNode); /** * Returns the default context matching the given context filter. @@ -71,5 +71,5 @@ public interface IDefaultContextService extends IService { * @param filter The context filter or null * @return The default context if set and the filter applies, null otherwise. */ - public IPeerModel getDefaultContext(IContextFilter filter); + public IPeerNode getDefaultContext(IContextFilter filter); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelLookupService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelLookupService.java deleted file mode 100644 index 97e425baa..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelLookupService.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.interfaces.services; - -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * The service to lookup/search in the parent locator model. - */ -public interface ILocatorModelLookupService extends ILocatorModelService { - - /** - * Lookup the peer model for the given peer id. - * - * @param id The peer id. Must not be null. - * @return The peer model instance, or null if the peer model cannot be found. - */ - public IPeerModel lkupPeerModelById(String id); - - /** - * Lookup the peer model for the given peer id from the peers child list of - * the peer identified by the given parent id. - * - * @param parentId The parent peer id. Must not be null. - * @param id The peer id. Must not be null. - * @return The peer model instance, or null if the peer model cannot be found. - */ - public IPeerModel lkupPeerModelById(String parentId, String id); - - /** - * Lookup the matching peer model instances for the given agent id. - * - * @param agentId The agent id. Must not be null. - * @return The peer model instances, or an empty list if the given agent id could not be matched. - */ - public IPeerModel[] lkupPeerModelByAgentId(String agentId); - - /** - * Lookup the matching peer model instances for the given agent id. - * - * @param parentId The parent peer id. Must not be null. - * @param agentId The agent id. Must not be null. - * @return The peer model instances, or an empty list if the given agent id could not be matched. - */ - public IPeerModel[] lkupPeerModelByAgentId(String parentId, String agentId); - - /** - * Lookup matching peer model instances for the given name. - * - * @param name The name. Must not be null. - * @return The peer model instances, or an empty list if the given name could not be matched. - */ - public IPeerModel[] lkupPeerModelByName(String name); - - /** - * Lookup matching peer model instances which supports the listed local and remote services. - *

- * Note: This method must be called outside the TCF dispatch thread. - * - * @param expectedLocalServices The list of local service names to be supported, or null. - * @param expectedRemoteServices The list of remote service names to be supported, or null. - * - * @return The peer model instances, or an empty list if the listed services are not supported by any of the peers. - */ - public IPeerModel[] lkupPeerModelBySupportedServices(String[] expectedLocalServices, String[] expectedRemoteServices); - - /** - * Lookup the matching static peer model instances for the given peer model node. - * - * @param peerNode The peer model node. Must not be null. - * @return The matching peer model instances or an empty list. - */ - public IPeerModel[] lkupMatchingStaticPeerModels(IPeerModel peerNode); - - /** - * Lookup the matching static peer model instances for the given peer. - * - * @param peer The peer or null. - * @return The matching peer model instances or an empty list. - */ - public IPeerModel[] lkupMatchingStaticPeerModels(IPeer peer); -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelPeerNodeQueryService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelPeerNodeQueryService.java deleted file mode 100644 index 75a5982e3..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelPeerNodeQueryService.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.interfaces.services; - -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * The service to query asynchronous properties of peers. - */ -public interface ILocatorModelPeerNodeQueryService extends ILocatorModelService { - - /** - * Query the list of available local services for the given peer. - *

- * Note: The result of the query is cached within the given peer model - * node and subsequent calls will return immediately with the cached value. - *

- * Note: This method must be called outside the TCF dispatch thread. - * - * @param node The peer node. Must not be null. - * @param done The client callback. Must not be null. - */ - public String queryLocalServices(IPeerModel node); - - /** - * Query the list of available remote services for the given peer. - *

- * Note: The result of the query is cached within the given peer model - * node and subsequent calls will return immediately with the cached value. - *

- * Note: This method must be called outside the TCF dispatch thread. - * - * @param node The peer node. Must not be null. - * @param done The client callback. Must not be null. - */ - public String queryRemoteServices(IPeerModel node); - - /** - * Client call back interface for queryServicesAsync(...). - */ - public interface DoneQueryServices { - /** - * Called when the services query completed. - * - * @param error The error description if operation failed, null if succeeded. - */ - void doneQueryServices(Throwable error); - } - - /** - * Asynchronously query the services for the given peer model node. - *

- * Note: This method must be called from within the TCF dispatch thread. - * - * @param node The peer node. Must not be null. - * @param done The client callback. Must not be null. - */ - public void queryServicesAsync(IPeerModel node, DoneQueryServices done); - -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelRefreshService.java deleted file mode 100644 index 85e655f97..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelRefreshService.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.interfaces.services; - -import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * The service to refresh the parent locator model from remote. - */ -public interface ILocatorModelRefreshService extends ILocatorModelService { - - /** - * Refreshes the list of known peers from the local locator service - * and update the locator model. - * - * @param callback The callback to invoke once the refresh operation finished, or null. - */ - public void refresh(ICallback callback); - - /** - * Refreshes the list of static peers only and merge them with the peers - * already known to the locator model via the dynamic discovery. - */ - public void refreshStaticPeers(); - - /** - * Refresh the agent ID's of the given or all reachable static peers. - * - * @param nodes The list of nodes to refresh or null to refresh all. - * @param callback The callback to invoke once the refresh operation finished, or null. - */ - public void refreshAgentIDs(IPeerModel[] nodes, ICallback callback); -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelService.java deleted file mode 100644 index 2cb869948..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelService.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.interfaces.services; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; - - -/** - * Common parent interface for locator model services. - */ -public interface ILocatorModelService extends IAdaptable { - - /** - * Returns the parent locator model. - * - * @return The parent locator model. - */ - public ILocatorModel getLocatorModel(); -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelUpdateService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelUpdateService.java deleted file mode 100644 index 7b564ce90..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelUpdateService.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.interfaces.services; - -import java.util.Collection; - -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - - -/** - * The service to update the properties of given locator model nodes. - */ -public interface ILocatorModelUpdateService extends ILocatorModelService { - - /** - * Adds the given peer to the list of know peers. - *

- * A previous mapping to a peer model with the same id as the given peer model is overwritten. - * - * @param peer The peer model object. Must not be null. - */ - public void add(IPeerModel peer); - - /** - * Removes the given peer from the list of known peers. - * - * @param peer The peer model object. Must not be nullnull. - * @param localServices The list of local service names or null. - * @param remoteServices The list of remote service names or null. - */ - public void updatePeerServices(IPeerModel peerNode, Collection localServices, Collection remoteServices); - - /** - * Adds the given child peer to the parent peer. - *

- * Note: The parent peer node is determined by calling {@link IPeerModel#getParentNode()}. - * The call has to return a non-null value, otherwise {@link #addChild(IPeerModel)} - * will do nothing. - * - * @param parent The parent peer model node. Must not be null. - * @param child The child peer model object. Must not be null. - */ - public void addChild(IPeerModel child); - - /** - * Removes the given child peer from the parent peer. - *

- * Note: The parent peer node is determined by calling {@link IPeerModel#getParentNode()}. - * The call has to return a non-null value, otherwise {@link #removeChild(IPeerModel)} - * will do nothing. - * - * @param parent The parent peer model node. Must not be null. - * @param child The child peer model object. Must not be null. - */ - public void removeChild(IPeerModel child); - - /** - * Merge user defined peer attributes from the given peer into the given peer node. - * - * @param node The peer node. Must not be null. - * @param peer The peer. Must not be null. - * @param force If true, the peer attributes are merged even if the peer id's don't match. - */ - public void mergeUserDefinedAttributes(IPeerModel node, IPeer peer, boolean force); -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelLookupService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelLookupService.java new file mode 100644 index 000000000..63121f94d --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelLookupService.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.interfaces.services; + +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * The service to lookup/search in the parent locator model. + */ +public interface IPeerModelLookupService extends IPeerModelService { + + /** + * Lookup the peer model for the given peer id. + * + * @param id The peer id. Must not be null. + * @return The peer model instance, or null if the peer model cannot be found. + */ + public IPeerNode lkupPeerModelById(String id); + + /** + * Lookup the peer model for the given peer id from the peers child list of + * the peer identified by the given parent id. + * + * @param parentId The parent peer id. Must not be null. + * @param id The peer id. Must not be null. + * @return The peer model instance, or null if the peer model cannot be found. + */ + public IPeerNode lkupPeerModelById(String parentId, String id); + + /** + * Lookup the matching peer model instances for the given agent id. + * + * @param agentId The agent id. Must not be null. + * @return The peer model instances, or an empty list if the given agent id could not be matched. + */ + public IPeerNode[] lkupPeerModelByAgentId(String agentId); + + /** + * Lookup the matching peer model instances for the given agent id. + * + * @param parentId The parent peer id. Must not be null. + * @param agentId The agent id. Must not be null. + * @return The peer model instances, or an empty list if the given agent id could not be matched. + */ + public IPeerNode[] lkupPeerModelByAgentId(String parentId, String agentId); + + /** + * Lookup matching peer model instances for the given name. + * + * @param name The name. Must not be null. + * @return The peer model instances, or an empty list if the given name could not be matched. + */ + public IPeerNode[] lkupPeerModelByName(String name); + + /** + * Lookup matching peer model instances which supports the listed local and remote services. + *

+ * Note: This method must be called outside the TCF dispatch thread. + * + * @param expectedLocalServices The list of local service names to be supported, or null. + * @param expectedRemoteServices The list of remote service names to be supported, or null. + * + * @return The peer model instances, or an empty list if the listed services are not supported by any of the peers. + */ + public IPeerNode[] lkupPeerModelBySupportedServices(String[] expectedLocalServices, String[] expectedRemoteServices); + + /** + * Lookup the matching static peer model instances for the given peer model node. + * + * @param peerNode The peer model node. Must not be null. + * @return The matching peer model instances or an empty list. + */ + public IPeerNode[] lkupMatchingStaticPeerModels(IPeerNode peerNode); + + /** + * Lookup the matching static peer model instances for the given peer. + * + * @param peer The peer or null. + * @return The matching peer model instances or an empty list. + */ + public IPeerNode[] lkupMatchingStaticPeerModels(IPeer peer); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelQueryService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelQueryService.java new file mode 100644 index 000000000..70c937814 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelQueryService.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.interfaces.services; + +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * The service to query asynchronous properties of peers. + */ +public interface IPeerModelQueryService extends IPeerModelService { + + /** + * Query the list of available local services for the given peer. + *

+ * Note: The result of the query is cached within the given peer model + * node and subsequent calls will return immediately with the cached value. + *

+ * Note: This method must be called outside the TCF dispatch thread. + * + * @param node The peer node. Must not be null. + * @param done The client callback. Must not be null. + */ + public String queryLocalServices(IPeerNode node); + + /** + * Query the list of available remote services for the given peer. + *

+ * Note: The result of the query is cached within the given peer model + * node and subsequent calls will return immediately with the cached value. + *

+ * Note: This method must be called outside the TCF dispatch thread. + * + * @param node The peer node. Must not be null. + * @param done The client callback. Must not be null. + */ + public String queryRemoteServices(IPeerNode node); + + /** + * Client call back interface for queryServicesAsync(...). + */ + public interface DoneQueryServices { + /** + * Called when the services query completed. + * + * @param error The error description if operation failed, null if succeeded. + */ + void doneQueryServices(Throwable error); + } + + /** + * Asynchronously query the services for the given peer model node. + *

+ * Note: This method must be called from within the TCF dispatch thread. + * + * @param node The peer node. Must not be null. + * @param done The client callback. Must not be null. + */ + public void queryServicesAsync(IPeerNode node, DoneQueryServices done); + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelRefreshService.java new file mode 100644 index 000000000..dc683ea76 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelRefreshService.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.interfaces.services; + +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * The service to refresh the parent locator model from remote. + */ +public interface IPeerModelRefreshService extends IPeerModelService { + + /** + * Refreshes the list of known peers from the local locator service + * and update the locator model. + * + * @param callback The callback to invoke once the refresh operation finished, or null. + */ + public void refresh(ICallback callback); + + /** + * Refreshes the list of static peers only and merge them with the peers + * already known to the locator model via the dynamic discovery. + */ + public void refreshStaticPeers(); + + /** + * Refresh the agent ID's of the given or all reachable static peers. + * + * @param nodes The list of nodes to refresh or null to refresh all. + * @param callback The callback to invoke once the refresh operation finished, or null. + */ + public void refreshAgentIDs(IPeerNode[] nodes, ICallback callback); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelService.java new file mode 100644 index 000000000..553c7f986 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelService.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.interfaces.services; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; + +/** + * Common parent interface for peer model services. + */ +public interface IPeerModelService extends IAdaptable { + + /** + * Returns the parent peer model. + * + * @return The parent peer model. + */ + public IPeerModel getPeerModel(); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelUpdateService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelUpdateService.java new file mode 100644 index 000000000..ca2734a98 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelUpdateService.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.interfaces.services; + +import java.util.Collection; + +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + + +/** + * The service to update the properties of given locator model nodes. + */ +public interface IPeerModelUpdateService extends IPeerModelService { + + /** + * Adds the given peer to the list of know peers. + *

+ * A previous mapping to a peer model with the same id as the given peer model is overwritten. + * + * @param peer The peer model object. Must not be null. + */ + public void add(IPeerNode peer); + + /** + * Removes the given peer from the list of known peers. + * + * @param peer The peer model object. Must not be nullnull. + * @param localServices The list of local service names or null. + * @param remoteServices The list of remote service names or null. + */ + public void updatePeerServices(IPeerNode peerNode, Collection localServices, Collection remoteServices); + + /** + * Adds the given child peer to the parent peer. + *

+ * Note: The parent peer node is determined by calling {@link IPeerNode#getParentNode()}. + * The call has to return a non-null value, otherwise {@link #addChild(IPeerNode)} + * will do nothing. + * + * @param parent The parent peer model node. Must not be null. + * @param child The child peer model object. Must not be null. + */ + public void addChild(IPeerNode child); + + /** + * Removes the given child peer from the parent peer. + *

+ * Note: The parent peer node is determined by calling {@link IPeerNode#getParentNode()}. + * The call has to return a non-null value, otherwise {@link #removeChild(IPeerNode)} + * will do nothing. + * + * @param parent The parent peer model node. Must not be null. + * @param child The child peer model object. Must not be null. + */ + public void removeChild(IPeerNode child); + + /** + * Merge user defined peer attributes from the given peer into the given peer node. + * + * @param node The peer node. Must not be null. + * @param peer The peer. Must not be null. + * @param force If true, the peer attributes are merged even if the peer id's don't match. + */ + public void mergeUserDefinedAttributes(IPeerNode node, IPeer peer, boolean force); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/LocatorModelPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/LocatorModelPropertyTester.java deleted file mode 100644 index 2ea867dfa..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/LocatorModelPropertyTester.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.internal; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.Platform; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; -import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; -import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; - -/** - * Locator model property tester. - */ -public class LocatorModelPropertyTester extends PropertyTester { - - /* (non-Javadoc) - * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) - */ - @Override - public boolean test(Object receiver, final String property, final Object[] args, final Object expectedValue) { - if (receiver instanceof IPeer) { - receiver = Platform.getAdapterManager().getAdapter(receiver, IPeerModel.class); - } - // The receiver is expected to be a peer model node or a peer - if (receiver instanceof IPeerModel) { - final IPeerModel peerModel = (IPeerModel)receiver; - final AtomicBoolean result = new AtomicBoolean(); - - // If we have to test for local or remote services, we have to handle it special - if ("hasLocalService".equals(property) || "hasRemoteService".equals(property)) { //$NON-NLS-1$ //$NON-NLS-2$ - // This tests must happen outside the TCF dispatch thread's - if (!Protocol.isDispatchThread()) { - result.set(testServices(peerModel, property, args, expectedValue)); - } - } - else { - Runnable runnable = new Runnable() { - @Override - public void run() { - result.set(testPeerModel(peerModel, property, args, expectedValue)); - } - }; - - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } - } - - return result.get(); - } - return false; - } - - /** - * Test the specific peer model node properties. - * - * @param node The model node. Must not be null. - * @param property The property to test. - * @param args The property arguments. - * @param expectedValue The expected value. - * - * @return True if the property to test has the expected value, false - * otherwise. - */ - protected boolean testPeerModel(IPeerModel peerModel, String property, Object[] args, Object expectedValue) { - Assert.isNotNull(peerModel); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - IPeer peer = peerModel.getPeer(); - - if ("name".equals(property)) { //$NON-NLS-1$ - if (peer.getName() != null && peer.getName().equals(expectedValue)) { - return true; - } - } - - if ("nameRegex".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$ - if (peer.getName() != null && peer.getName().matches((String)expectedValue)) { - return true; - } - } - - if ("osName".equals(property)) { //$NON-NLS-1$ - if (peer.getOSName() != null && peer.getOSName().equals(expectedValue)) { - return true; - } - } - - if ("osNameRegex".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$ - if (peer.getOSName() != null && peer.getOSName().matches((String)expectedValue)) { - return true; - } - } - - if ("isStaticPeer".equals(property)) { //$NON-NLS-1$ - String value = peer.getAttributes().get("static.transient"); //$NON-NLS-1$ - boolean isStaticPeer = value != null && Boolean.parseBoolean(value.trim()); - if (expectedValue instanceof Boolean) { - return ((Boolean) expectedValue).booleanValue() == isStaticPeer; - } - } - - if ("isRedirected".equals(property)) { //$NON-NLS-1$ - boolean isRedirected = peer instanceof PeerRedirector; - if (expectedValue instanceof Boolean) { - return ((Boolean) expectedValue).booleanValue() == isRedirected; - } - } - - if ("isProxy".equals(property)) { //$NON-NLS-1$ - boolean isProxy = peer.getAttributes().containsKey("Proxy"); //$NON-NLS-1$ - if (expectedValue instanceof Boolean) { - return ((Boolean) expectedValue).booleanValue() == isProxy; - } - } - - if ("isValueAdd".equals(property)) { //$NON-NLS-1$ - String value = peer.getAttributes().get("ValueAdd"); //$NON-NLS-1$ - boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$ - if (expectedValue instanceof Boolean) { - return ((Boolean) expectedValue).booleanValue() == isValueAdd; - } - } - - if ("isOfType".equals(property)) { //$NON-NLS-1$ - String value = peer.getAttributes().get(IPeerModelProperties.PROP_TYPE); - if (expectedValue instanceof String) { - return value != null ? ((String)expectedValue).equals(value) : ((String)expectedValue).equalsIgnoreCase("null"); //$NON-NLS-1$ - } - } - - if ("hasAttribute".equals(property)) { //$NON-NLS-1$ - String name = args != null && args.length > 0 ? (String)args[0] : null; - boolean hasAttribute = name != null && !"".equals(name) ? peer.getAttributes().containsKey(name) : false; //$NON-NLS-1$ - if (expectedValue instanceof Boolean) { - return ((Boolean) expectedValue).booleanValue() == hasAttribute; - } - } - - if ("isAttribute".equals(property)) { //$NON-NLS-1$ - String name = args != null && args.length > 0 ? (String)args[0] : null; - String value = name != null && !"".equals(name) ? peer.getAttributes().get(name) : null; //$NON-NLS-1$ - if (expectedValue != null) { - return expectedValue.toString().equals(value); - } - } - - if ("hasOfflineService".equals(property)) { //$NON-NLS-1$ - String offlineServices = peer.getAttributes().get(IPeerModelProperties.PROP_OFFLINE_SERVICES); - String remoteServices = peerModel.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES); - List offline = offlineServices != null ? Arrays.asList(offlineServices.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$ - List remote = remoteServices != null ? Arrays.asList(remoteServices.split(",\\s*")) : null; //$NON-NLS-1$ - boolean hasOfflineService = (remote == null) ? offline.contains(expectedValue) : remote.contains(expectedValue); - if (expectedValue instanceof Boolean) { - return ((Boolean) expectedValue).booleanValue() == hasOfflineService; - } - return hasOfflineService; - } - - return false; - } - - /** - * Test for the peer model node local or remote services. - *

- * Node: This method cannot be called from within the TCF Dispatch Thread. - * - * @param node The model node. Must not be null. - * @param property The property to test. - * @param args The property arguments. - * @param expectedValue The expected value. - * - * @return True if the property to test has the expected value, false - * otherwise. - */ - protected boolean testServices(final IPeerModel node, final String property, final Object[] args, final Object expectedValue) { - Assert.isNotNull(node); - Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - String services = null; - - ILocatorModel model = node.getModel(); - ILocatorModelPeerNodeQueryService queryService = model.getService(ILocatorModelPeerNodeQueryService.class); - if ("hasLocalService".equals(property)) { //$NON-NLS-1$ - services = queryService.queryLocalServices(node); - } else { - services = queryService.queryRemoteServices(node); - } - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(ITracing.ID_TRACE_PROPERTY_TESTER)) { - CoreBundleActivator.getTraceHandler().trace("testServices: property = " + property + ", expectedValue = " + expectedValue + ", services = " + services, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - ITracing.ID_TRACE_PROPERTY_TESTER, LocatorModelPropertyTester.this); - } - - if (services != null) { - // Lookup each service individually to avoid "accidental" matching - for (String service : services.split(",")) { //$NON-NLS-1$ - if (service != null && service.trim().equals(expectedValue)) { - return true; - } - } - } - - return false; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java index cfc145c60..142c4efed 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java @@ -1,68 +1,61 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.internal; - -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.runtime.model.factory.AbstractFactoryDelegate2; -import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.internal.nodes.InvalidPeerModel; -import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel; - -/** - * Locator model node factory delegate implementation. - */ -public class ModelNodeFactoryDelegate extends AbstractFactoryDelegate2 { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate#newInstance(java.lang.Class) - */ - @SuppressWarnings("unchecked") - @Override - public V newInstance(Class nodeInterface) { - if (IPeerModel.class.equals(nodeInterface)) { - return (V) new InvalidPeerModel(); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate2#newInstance(java.lang.Class, java.lang.Object[]) - */ - @SuppressWarnings("unchecked") - @Override - public V newInstance(final Class nodeInterface, final Object[] args) { - if (args == null) return newInstance(nodeInterface); - - if (IPeerModel.class.equals(nodeInterface)) { - // Peer model constructor has 2 arguments, ILocatorModel and IPeer - if (args.length == 2 && args[0] instanceof ILocatorModel && args[1] instanceof IPeer) { - final AtomicReference node = new AtomicReference(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - node.set((V) new PeerModel((ILocatorModel)args[0], (IPeer)args[1])); - } - }; - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - - return node.get(); - } - } - - return null; - } -} +/******************************************************************************* + * Copyright (c) 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.internal; + +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.runtime.model.factory.AbstractFactoryDelegate2; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode; + +/** + * Locator model node factory delegate implementation. + */ +public class ModelNodeFactoryDelegate extends AbstractFactoryDelegate2 { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate#newInstance(java.lang.Class) + */ + @Override + public V newInstance(Class nodeInterface) { + return newInstance(nodeInterface, new Object[0]); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate2#newInstance(java.lang.Class, java.lang.Object[]) + */ + @SuppressWarnings("unchecked") + @Override + public V newInstance(final Class nodeInterface, final Object[] args) { + if (IPeerNode.class.equals(nodeInterface)) { + // Peer model constructor has 2 arguments, IPeerModel and IPeer + if (args != null && args.length == 2 && args[0] instanceof IPeerModel && args[1] instanceof IPeer) { + final AtomicReference node = new AtomicReference(); + + Runnable runnable = new Runnable() { + @Override + public void run() { + node.set((V) new PeerNode((IPeerModel)args[0], (IPeer)args[1])); + } + }; + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); + + return node.get(); + } + } + + return null; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java new file mode 100644 index 000000000..572fd793e --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java @@ -0,0 +1,228 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.internal; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.Platform; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; +import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; + +/** + * Locator model property tester. + */ +public class PeerModelPropertyTester extends PropertyTester { + + /* (non-Javadoc) + * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) + */ + @Override + public boolean test(Object receiver, final String property, final Object[] args, final Object expectedValue) { + if (receiver instanceof IPeer) { + receiver = Platform.getAdapterManager().getAdapter(receiver, IPeerNode.class); + } + // The receiver is expected to be a peer model node or a peer + if (receiver instanceof IPeerNode) { + final IPeerNode peerNode = (IPeerNode)receiver; + final AtomicBoolean result = new AtomicBoolean(); + + // If we have to test for local or remote services, we have to handle it special + if ("hasLocalService".equals(property) || "hasRemoteService".equals(property)) { //$NON-NLS-1$ //$NON-NLS-2$ + // This tests must happen outside the TCF dispatch thread's + if (!Protocol.isDispatchThread()) { + result.set(testServices(peerNode, property, args, expectedValue)); + } + } + else { + Runnable runnable = new Runnable() { + @Override + public void run() { + result.set(testPeerModel(peerNode, property, args, expectedValue)); + } + }; + + if (Protocol.isDispatchThread()) { + runnable.run(); + } + else { + Protocol.invokeAndWait(runnable); + } + } + + return result.get(); + } + return false; + } + + /** + * Test the specific peer model node properties. + * + * @param node The model node. Must not be null. + * @param property The property to test. + * @param args The property arguments. + * @param expectedValue The expected value. + * + * @return True if the property to test has the expected value, false + * otherwise. + */ + protected boolean testPeerModel(IPeerNode peerNode, String property, Object[] args, Object expectedValue) { + Assert.isNotNull(peerNode); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + IPeer peer = peerNode.getPeer(); + + if ("name".equals(property)) { //$NON-NLS-1$ + if (peer.getName() != null && peer.getName().equals(expectedValue)) { + return true; + } + } + + if ("nameRegex".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$ + if (peer.getName() != null && peer.getName().matches((String)expectedValue)) { + return true; + } + } + + if ("osName".equals(property)) { //$NON-NLS-1$ + if (peer.getOSName() != null && peer.getOSName().equals(expectedValue)) { + return true; + } + } + + if ("osNameRegex".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$ + if (peer.getOSName() != null && peer.getOSName().matches((String)expectedValue)) { + return true; + } + } + + if ("isStaticPeer".equals(property)) { //$NON-NLS-1$ + String value = peer.getAttributes().get("static.transient"); //$NON-NLS-1$ + boolean isStaticPeer = value != null && Boolean.parseBoolean(value.trim()); + if (expectedValue instanceof Boolean) { + return ((Boolean) expectedValue).booleanValue() == isStaticPeer; + } + } + + if ("isRedirected".equals(property)) { //$NON-NLS-1$ + boolean isRedirected = peer instanceof PeerRedirector; + if (expectedValue instanceof Boolean) { + return ((Boolean) expectedValue).booleanValue() == isRedirected; + } + } + + if ("isProxy".equals(property)) { //$NON-NLS-1$ + boolean isProxy = peer.getAttributes().containsKey("Proxy"); //$NON-NLS-1$ + if (expectedValue instanceof Boolean) { + return ((Boolean) expectedValue).booleanValue() == isProxy; + } + } + + if ("isValueAdd".equals(property)) { //$NON-NLS-1$ + String value = peer.getAttributes().get("ValueAdd"); //$NON-NLS-1$ + boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$ + if (expectedValue instanceof Boolean) { + return ((Boolean) expectedValue).booleanValue() == isValueAdd; + } + } + + if ("isOfType".equals(property)) { //$NON-NLS-1$ + String value = peer.getAttributes().get(IPeerNodeProperties.PROP_TYPE); + if (expectedValue instanceof String) { + return value != null ? ((String)expectedValue).equals(value) : ((String)expectedValue).equalsIgnoreCase("null"); //$NON-NLS-1$ + } + } + + if ("hasAttribute".equals(property)) { //$NON-NLS-1$ + String name = args != null && args.length > 0 ? (String)args[0] : null; + boolean hasAttribute = name != null && !"".equals(name) ? peer.getAttributes().containsKey(name) : false; //$NON-NLS-1$ + if (expectedValue instanceof Boolean) { + return ((Boolean) expectedValue).booleanValue() == hasAttribute; + } + } + + if ("isAttribute".equals(property)) { //$NON-NLS-1$ + String name = args != null && args.length > 0 ? (String)args[0] : null; + String value = name != null && !"".equals(name) ? peer.getAttributes().get(name) : null; //$NON-NLS-1$ + if (expectedValue != null) { + return expectedValue.toString().equals(value); + } + } + + if ("hasOfflineService".equals(property)) { //$NON-NLS-1$ + String offlineServices = peer.getAttributes().get(IPeerNodeProperties.PROP_OFFLINE_SERVICES); + String remoteServices = peerNode.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES); + List offline = offlineServices != null ? Arrays.asList(offlineServices.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$ + List remote = remoteServices != null ? Arrays.asList(remoteServices.split(",\\s*")) : null; //$NON-NLS-1$ + boolean hasOfflineService = (remote == null) ? offline.contains(expectedValue) : remote.contains(expectedValue); + if (expectedValue instanceof Boolean) { + return ((Boolean) expectedValue).booleanValue() == hasOfflineService; + } + return hasOfflineService; + } + + return false; + } + + /** + * Test for the peer model node local or remote services. + *

+ * Node: This method cannot be called from within the TCF Dispatch Thread. + * + * @param node The model node. Must not be null. + * @param property The property to test. + * @param args The property arguments. + * @param expectedValue The expected value. + * + * @return True if the property to test has the expected value, false + * otherwise. + */ + protected boolean testServices(final IPeerNode node, final String property, final Object[] args, final Object expectedValue) { + Assert.isNotNull(node); + Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + String services = null; + + IPeerModel model = node.getModel(); + IPeerModelQueryService queryService = model.getService(IPeerModelQueryService.class); + if ("hasLocalService".equals(property)) { //$NON-NLS-1$ + services = queryService.queryLocalServices(node); + } else { + services = queryService.queryRemoteServices(node); + } + + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(ITracing.ID_TRACE_PROPERTY_TESTER)) { + CoreBundleActivator.getTraceHandler().trace("testServices: property = " + property + ", expectedValue = " + expectedValue + ", services = " + services, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ITracing.ID_TRACE_PROPERTY_TESTER, PeerModelPropertyTester.this); + } + + if (services != null) { + // Lookup each service individually to avoid "accidental" matching + for (String service : services.split(",")) { //$NON-NLS-1$ + if (service != null && service.trim().equals(expectedValue)) { + return true; + } + } + } + + return false; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java index 75cfbfb82..55a11c9c0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java @@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.locator.internal; import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService.State; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils.Result; @@ -27,9 +27,9 @@ public class SimulatorPropertyTester extends org.eclipse.core.expressions.Proper */ @Override public boolean test(final Object receiver, String property, Object[] args, Object expectedValue) { - if (receiver instanceof IPeerModel) { - final IPeerModel peerModel = (IPeerModel) receiver; - Result result = SimulatorUtils.getSimulatorService(peerModel); + if (receiver instanceof IPeerNode) { + final IPeerNode peerNode = (IPeerNode) receiver; + Result result = SimulatorUtils.getSimulatorService(peerNode); if (result.service != null) { if ("isSimulatorState".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java index 5f698a49d..cdbede25b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java @@ -20,10 +20,10 @@ import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.runtime.model.factory.Factory; import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; /** @@ -34,7 +34,7 @@ public class AdapterFactory implements IAdapterFactory { private final IPersistableURIProvider peerModelPersistableURIProvider = new PeerPersistableURIProvider(); private static final Class[] CLASSES = new Class[] { - IPersistableURIProvider.class, IPeerModel.class, IConnectable.class, ILocatorModel.class + IPersistableURIProvider.class, IPeerNode.class, IConnectable.class, IPeerModel.class }; /* (non-Javadoc) @@ -52,30 +52,30 @@ public class AdapterFactory implements IAdapterFactory { return adaptableObject; } } - if (ILocatorModel.class.isAssignableFrom(adapterType)) { - if (adaptableObject instanceof IPeerModel) { - return ((IPeerModel)adaptableObject).getModel(); + if (IPeerModel.class.isAssignableFrom(adapterType)) { + if (adaptableObject instanceof IPeerNode) { + return ((IPeerNode)adaptableObject).getModel(); } } - if (adaptableObject instanceof IPeerModel || adaptableObject instanceof IPeer || adaptableObject instanceof IPeerModelProvider) { + if (adaptableObject instanceof IPeerNode || adaptableObject instanceof IPeer || adaptableObject instanceof IPeerNodeProvider) { if (IPersistableURIProvider.class.equals(adapterType)) { return peerModelPersistableURIProvider; } - if (IPeerModel.class.equals(adapterType)) { + if (IPeerNode.class.equals(adapterType)) { if (adaptableObject instanceof IPeer) { - final AtomicReference node = new AtomicReference(); + final AtomicReference node = new AtomicReference(); final IPeer peer = (IPeer)adaptableObject; Runnable runnable = new Runnable() { @Override public void run() { String id = peer.getID(); - ILocatorModel model = Model.getModel(); + IPeerModel model = Model.getModel(); Assert.isNotNull(model); - IPeerModel candidate = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(id); + IPeerNode candidate = model.getService(IPeerModelLookupService.class).lkupPeerModelById(id); if (candidate != null) node.set(candidate); else { - candidate = Factory.getInstance().newInstance(IPeerModel.class, new Object[] { model, peer }); + candidate = Factory.getInstance().newInstance(IPeerNode.class, new Object[] { model, peer }); if (candidate != null) node.set(candidate); } } @@ -86,12 +86,12 @@ public class AdapterFactory implements IAdapterFactory { return node.get(); } - else if (adaptableObject instanceof IPeerModel) { + else if (adaptableObject instanceof IPeerNode) { return adaptableObject; } - else if (adaptableObject instanceof IPeerModelProvider) { - final AtomicReference node = new AtomicReference(); - final IPeerModelProvider provider = (IPeerModelProvider)adaptableObject; + else if (adaptableObject instanceof IPeerNodeProvider) { + final AtomicReference node = new AtomicReference(); + final IPeerNodeProvider provider = (IPeerNodeProvider)adaptableObject; Runnable runnable = new Runnable() { @Override @@ -107,8 +107,8 @@ public class AdapterFactory implements IAdapterFactory { } } if (IStepContext.class.equals(adapterType)) { - if (adaptableObject instanceof IPeerModel) { - return new PeerModelStepContext((IPeerModel)adaptableObject); + if (adaptableObject instanceof IPeerNode) { + return new PeerNodeStepContext((IPeerNode)adaptableObject); } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelStepContext.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelStepContext.java deleted file mode 100644 index 440760606..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelStepContext.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.internal.adapters; - -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.te.runtime.stepper.context.AbstractStepContext; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * Peer model step context implementation. - */ -public class PeerModelStepContext extends AbstractStepContext { - - /** - * Constructor - */ - public PeerModelStepContext(IPeerModel peerModel) { - super(peerModel); - } - - /** - * Returns the peer model. - * @return The peer model. - */ - public IPeerModel getPeerModel() { - return (IPeerModel)getContextObject(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getId() - */ - @Override - public String getId() { - return getPeerModel().getPeerId(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getName() - */ - @Override - public String getName() { - return getPeerModel().getName(); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) - */ - @Override - public Object getAdapter(final Class adapter) { - if (IPeerModel.class.equals(adapter)) { - return getPeerModel(); - } - - if (IPeer.class.equals(adapter)) { - return getPeerModel().getPeer(); - } - - return super.getAdapter(adapter); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerNodeStepContext.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerNodeStepContext.java new file mode 100644 index 000000000..f73e853fd --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerNodeStepContext.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.internal.adapters; + +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.runtime.stepper.context.AbstractStepContext; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * Peer model step context implementation. + */ +public class PeerNodeStepContext extends AbstractStepContext { + + /** + * Constructor + */ + public PeerNodeStepContext(IPeerNode peerNode) { + super(peerNode); + } + + /** + * Returns the peer model. + * @return The peer model. + */ + public IPeerNode getPeerModel() { + return (IPeerNode)getContextObject(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getId() + */ + @Override + public String getId() { + return getPeerModel().getPeerId(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getName() + */ + @Override + public String getName() { + return getPeerModel().getName(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(final Class adapter) { + if (IPeerNode.class.equals(adapter)) { + return getPeerModel(); + } + + if (IPeer.class.equals(adapter)) { + return getPeerModel().getPeer(); + } + + return super.getAdapter(adapter); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java index eaad3b69a..2ecb42a3f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java @@ -1,109 +1,109 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.internal.adapters; - -import java.net.URI; -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IPath; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.core.adapters.ModelNodePersistableURIProvider; -import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; -import org.eclipse.tcf.te.tcf.locator.model.ModelLocationUtil; - -/** - * Persistable implementation handling peer attributes. - */ -public class PeerPersistableURIProvider extends ModelNodePersistableURIProvider { - - /** - * Determine the peer from the given context object. - * - * @param context The context object or null. - * @return The peer or null. - */ - private IPeer getPeer(Object context) { - IPeer peer = null; - - if (context instanceof IPeer) { - peer = (IPeer)context; - } - else if (context instanceof IPeerModel) { - peer = ((IPeerModel)context).getPeer(); - } - else if (context instanceof IPeerModelProvider) { - peer = ((IPeerModelProvider)context).getPeerModel().getPeer(); - } - - return peer; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#getURI(java.lang.Object) - */ - @Override - public URI getURI(final Object context) { - Assert.isNotNull(context); - - URI uri = null; - final IPeer peer = getPeer(context); - - if (peer != null) { - // Get the URI the peer model has been created from - final AtomicReference nodeURI = new AtomicReference(); - Runnable runnable = new Runnable() { - @Override - public void run() { - String value = peer.getAttributes().get(IPersistableNodeProperties.PROPERTY_URI); - if (value != null && !"".equals(value.trim())) { //$NON-NLS-1$ - nodeURI.set(URI.create(value.trim())); - } - } - }; - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } - - if (nodeURI.get() != null) { - uri = nodeURI.get(); - } - - if (uri == null) { - String name = peer.getName(); - if (name == null) { - name = peer.getID(); - } - name = makeValidFileSystemName(name); - // Get the URI from the name - uri = getRoot().append(name).toFile().toURI(); - - } - } - - return uri; - } - - /** - * Returns the root location of the peers storage. - * - * @return The root location or null if it cannot be determined. - */ - @Override - public IPath getRoot() { - return ModelLocationUtil.getStaticPeersRootLocation(); - } -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.internal.adapters; + +import java.net.URI; +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.adapters.ModelNodePersistableURIProvider; +import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; +import org.eclipse.tcf.te.tcf.locator.model.ModelLocationUtil; + +/** + * Persistable implementation handling peer attributes. + */ +public class PeerPersistableURIProvider extends ModelNodePersistableURIProvider { + + /** + * Determine the peer from the given context object. + * + * @param context The context object or null. + * @return The peer or null. + */ + private IPeer getPeer(Object context) { + IPeer peer = null; + + if (context instanceof IPeer) { + peer = (IPeer)context; + } + else if (context instanceof IPeerNode) { + peer = ((IPeerNode)context).getPeer(); + } + else if (context instanceof IPeerNodeProvider) { + peer = ((IPeerNodeProvider)context).getPeerModel().getPeer(); + } + + return peer; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#getURI(java.lang.Object) + */ + @Override + public URI getURI(final Object context) { + Assert.isNotNull(context); + + URI uri = null; + final IPeer peer = getPeer(context); + + if (peer != null) { + // Get the URI the peer model has been created from + final AtomicReference nodeURI = new AtomicReference(); + Runnable runnable = new Runnable() { + @Override + public void run() { + String value = peer.getAttributes().get(IPersistableNodeProperties.PROPERTY_URI); + if (value != null && !"".equals(value.trim())) { //$NON-NLS-1$ + nodeURI.set(URI.create(value.trim())); + } + } + }; + if (Protocol.isDispatchThread()) { + runnable.run(); + } + else { + Protocol.invokeAndWait(runnable); + } + + if (nodeURI.get() != null) { + uri = nodeURI.get(); + } + + if (uri == null) { + String name = peer.getName(); + if (name == null) { + name = peer.getID(); + } + name = makeValidFileSystemName(name); + // Get the URI from the name + uri = getRoot().append(name).toFile().toURI(); + + } + } + + return uri; + } + + /** + * Returns the root location of the peers storage. + * + * @return The root location or null if it cannot be determined. + */ + @Override + public IPath getRoot() { + return ModelLocationUtil.getStaticPeersRootLocation(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java deleted file mode 100644 index 431592035..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java +++ /dev/null @@ -1,538 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.internal.nodes; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode; -import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; -import org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.internal.ModelNodeFactoryDelegate; - -/** - * Invalid peer model node implementation. All methods does throw an {@link IllegalStateException}. - *

- * Objects of this class are returned by the {@link ModelNodeFactoryDelegate} if calling - * {@link IFactoryDelegate#newInstance(Class)}. All what objects of this class can be used for is - * loading adapters. - */ -public final class InvalidPeerModel implements IPeerModel { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#add(org.eclipse.tcf.te.runtime.model.interfaces.IModelNode) - */ - @Override - public boolean add(IModelNode child) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#remove(org.eclipse.tcf.te.runtime.model.interfaces.IModelNode, boolean) - */ - @Override - public boolean remove(IModelNode node, boolean recursive) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#clear() - */ - @Override - public boolean clear() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#removeAll(java.lang.Class) - */ - @Override - public boolean removeAll(Class nodeType) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#getChildren() - */ - @Override - public IModelNode[] getChildren() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#getChildren(java.lang.Class) - */ - @Override - public List getChildren(Class nodeType) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#hasChildren() - */ - @Override - public boolean hasChildren() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#size() - */ - @Override - public int size() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#contains(org.eclipse.tcf.te.runtime.model.interfaces.IModelNode) - */ - @Override - public boolean contains(IModelNode node) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getParent() - */ - @Override - public IContainerModelNode getParent() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getParent(java.lang.Class) - */ - @Override - public V getParent(Class nodeType) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#setParent(org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode) - */ - @Override - public void setParent(IContainerModelNode parent) throws IllegalStateException { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#move(org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode) - */ - @Override - public void move(IContainerModelNode newParent) throws IllegalStateException { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#isVisible() - */ - @Override - public boolean isVisible() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getName() - */ - @Override - public String getName() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getImageId() - */ - @Override - public String getImageId() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getError() - */ - @Override - public String getError() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getDescription() - */ - @Override - public String[] getDescription() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#setDirty(boolean) - */ - @Override - public void setDirty(boolean dirty) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#isDirty() - */ - @Override - public boolean isDirty() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#setPending(boolean) - */ - @Override - public void setPending(boolean pending) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#isPending() - */ - @Override - public boolean isPending() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#find(java.util.UUID) - */ - @Override - public IModelNode find(UUID uuid) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getUUID() - */ - @Override - public UUID getUUID() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setChangeEventsEnabled(boolean) - */ - @Override - public boolean setChangeEventsEnabled(boolean enabled) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#changeEventsEnabled() - */ - @Override - public boolean changeEventsEnabled() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#fireChangeEvent(java.lang.String, java.lang.Object, java.lang.Object) - */ - @Override - public void fireChangeEvent(String key, Object oldValue, Object newValue) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperties(java.util.Map) - */ - @Override - public void setProperties(Map properties) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, java.lang.Object) - */ - @Override - public boolean setProperty(String key, Object value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, long) - */ - @Override - public boolean setProperty(String key, long value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, int) - */ - @Override - public boolean setProperty(String key, int value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, boolean) - */ - @Override - public boolean setProperty(String key, boolean value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, float) - */ - @Override - public boolean setProperty(String key, float value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, double) - */ - @Override - public boolean setProperty(String key, double value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getProperties() - */ - @Override - public Map getProperties() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getProperty(java.lang.String) - */ - @Override - public Object getProperty(String key) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getStringProperty(java.lang.String) - */ - @Override - public String getStringProperty(String key) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getLongProperty(java.lang.String) - */ - @Override - public long getLongProperty(String key) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getIntProperty(java.lang.String) - */ - @Override - public int getIntProperty(String key) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getBooleanProperty(java.lang.String) - */ - @Override - public boolean getBooleanProperty(String key) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getFloatProperty(java.lang.String) - */ - @Override - public float getFloatProperty(String key) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getDoubleProperty(java.lang.String) - */ - @Override - public double getDoubleProperty(String key) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#clearProperties() - */ - @Override - public void clearProperties() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isEmpty() - */ - @Override - public boolean isEmpty() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isPropertyIgnoreCase(java.lang.String, java.lang.String) - */ - @Override - public boolean isPropertyIgnoreCase(String key, String value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, java.lang.Object) - */ - @Override - public boolean isProperty(String key, Object value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, long) - */ - @Override - public boolean isProperty(String key, long value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, int) - */ - @Override - public boolean isProperty(String key, int value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, boolean) - */ - @Override - public boolean isProperty(String key, boolean value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, float) - */ - @Override - public boolean isProperty(String key, float value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, double) - */ - @Override - public boolean isProperty(String key, double value) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - @Override - public Object getAdapter(Class adapter) { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule) - */ - @Override - public boolean contains(ISchedulingRule rule) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule) - */ - @Override - public boolean isConflicting(ISchedulingRule rule) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getModel() - */ - @Override - public ILocatorModel getModel() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getPeer() - */ - @Override - public IPeer getPeer() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getPeerId() - */ - @Override - public String getPeerId() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getRemotePeerId() - */ - @Override - public String getRemotePeerId() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isComplete() - */ - @Override - public boolean isComplete() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isStatic() - */ - @Override - public boolean isStatic() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isRemote() - */ - @Override - public boolean isRemote() { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#addProperties(java.util.Map) - */ - @Override - public void addProperties(Map properties) { - throw new IllegalStateException(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#containsKey(java.lang.String) - */ - @Override - public boolean containsKey(String key) { - throw new IllegalStateException(); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java index f7020a334..9af952156 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java @@ -16,7 +16,7 @@ import java.util.Map; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.services.interfaces.constants.IPropertiesAccessServiceConstants; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Peer model properties access service implementation. @@ -30,13 +30,22 @@ public class PropertiesAccessService extends org.eclipse.tcf.te.tcf.core.model.s public Map getTargetAddress(Object context) { final Map result = new HashMap(); - if (context instanceof IPeerModel) { - final IPeerModel peerModel = (IPeerModel) context; + final IPeer peer; + if (context instanceof IPeer) { + peer = (IPeer)context; + } + else if (context instanceof IPeerNode) { + peer = ((IPeerNode)context).getPeer(); + } + else { + peer = null; + } - Runnable runnable = new Runnable() { + if (peer != null) { + Protocol.invokeAndWait(new Runnable() { @Override public void run() { - Map attributes = peerModel.getPeer().getAttributes(); + Map attributes = peer.getAttributes(); String value = attributes.get(IPeer.ATTR_NAME); if (value != null && !"".equals(value.trim())) { //$NON-NLS-1$ @@ -52,10 +61,7 @@ public class PropertiesAccessService extends org.eclipse.tcf.te.tcf.core.model.s result.put(IPropertiesAccessServiceConstants.PROP_PORT, value); } } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); + }); } return !result.isEmpty() ? Collections.unmodifiableMap(result) : null; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerModelStepGroupIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerModelStepGroupIterator.java deleted file mode 100644 index 52e840308..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerModelStepGroupIterator.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ - -package org.eclipse.tcf.te.tcf.locator.iterators; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.core.iterators.AbstractPeerStepGroupIterator; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * Abstract launch stepgroup iterator. - */ -public abstract class AbstractPeerModelStepGroupIterator extends AbstractPeerStepGroupIterator { - - /** - * Returns the active peer model context that is currently used. - * - * @param context The step context. Must not be null. - * @param data The data giving object. Must not be null. - * @param fullQualifiedId The full qualfied id for this step. Must not be null. - * @return The active peer model context. - */ - protected IPeerModel getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) { - Object activeContext = getActiveContext(context, data, fullQualifiedId); - IPeerModel peerModel = null; - if (activeContext instanceof IPeerModel) - return (IPeerModel)activeContext; - if (activeContext instanceof IAdaptable) - peerModel = (IPeerModel)((IAdaptable)activeContext).getAdapter(IPeerModel.class); - if (peerModel == null) - peerModel = (IPeerModel)Platform.getAdapterManager().getAdapter(activeContext, IPeerModel.class); - - return peerModel; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerNodeStepGroupIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerNodeStepGroupIterator.java new file mode 100644 index 000000000..254e83209 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerNodeStepGroupIterator.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.tcf.locator.iterators; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.core.iterators.AbstractPeerStepGroupIterator; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * Abstract launch stepgroup iterator. + */ +public abstract class AbstractPeerNodeStepGroupIterator extends AbstractPeerStepGroupIterator { + + /** + * Returns the active peer model context that is currently used. + * + * @param context The step context. Must not be null. + * @param data The data giving object. Must not be null. + * @param fullQualifiedId The full qualfied id for this step. Must not be null. + * @return The active peer model context. + */ + protected IPeerNode getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) { + Object activeContext = getActiveContext(context, data, fullQualifiedId); + IPeerNode peerNode = null; + if (activeContext instanceof IPeerNode) + return (IPeerNode)activeContext; + if (activeContext instanceof IAdaptable) + peerNode = (IPeerNode)((IAdaptable)activeContext).getAdapter(IPeerNode.class); + if (peerNode == null) + peerNode = (IPeerNode)Platform.getAdapterManager().getAdapter(activeContext, IPeerNode.class); + + return peerNode; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java index 2d789a7ce..0acc3cacc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java @@ -20,13 +20,13 @@ import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.tcf.locator.interfaces.IStepAttributes; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; /** * Step group iterator for debugger attach. */ -public class StartDebuggerIterator extends AbstractPeerModelStepGroupIterator { +public class StartDebuggerIterator extends AbstractPeerNodeStepGroupIterator { /** * Constructor. @@ -44,11 +44,11 @@ public class StartDebuggerIterator extends AbstractPeerModelStepGroupIterator { final AtomicBoolean autoStartDbg = new AtomicBoolean(false); - final IPeerModel node = getActivePeerModelContext(context, data, fullQualifiedId); + final IPeerNode node = getActivePeerModelContext(context, data, fullQualifiedId); Runnable runnable = new Runnable() { @Override public void run() { - String value = node.getPeer().getAttributes().get(IPeerModelProperties.PROP_AUTO_START_DEBUGGER); + String value = node.getPeer().getAttributes().get(IPeerNodeProperties.PROP_AUTO_START_DEBUGGER); autoStartDbg.set(value != null ? Boolean.parseBoolean(value) : false); } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java index 19188f5bb..945c3de8d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java @@ -1,50 +1,50 @@ -/******************************************************************************* - * Copyright (c) 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ - -package org.eclipse.tcf.te.tcf.locator.iterators; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; - -/** - * Step group iterator for simulator start. - */ -public class StartSimulatorIterator extends AbstractPeerModelStepGroupIterator { - - /** - * Constructor. - */ - public StartSimulatorIterator() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#initialize(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public void initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { - super.initialize(context, data, fullQualifiedId, monitor); - - SimulatorUtils.Result result = SimulatorUtils.getSimulatorService(getActivePeerModelContext(context, data, fullQualifiedId)); - - setIterations(result != null ? 1 : 0); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public void internalNext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { - } -} +/******************************************************************************* + * Copyright (c) 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.tcf.locator.iterators; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; + +/** + * Step group iterator for simulator start. + */ +public class StartSimulatorIterator extends AbstractPeerNodeStepGroupIterator { + + /** + * Constructor. + */ + public StartSimulatorIterator() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#initialize(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + super.initialize(context, data, fullQualifiedId, monitor); + + SimulatorUtils.Result result = SimulatorUtils.getSimulatorService(getActivePeerModelContext(context, data, fullQualifiedId)); + + setIterations(result != null ? 1 : 0); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void internalNext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java index afc433394..6a06ca132 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java @@ -16,10 +16,10 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener; import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; /** @@ -27,14 +27,14 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupSer */ public class ChannelStateChangeListener implements IChannelStateChangeListener { // Reference to the parent model - private final ILocatorModel model; + private final IPeerModel model; /** * Constructor. * * @param model The parent locator model. Must not be null. */ - public ChannelStateChangeListener(ILocatorModel model) { + public ChannelStateChangeListener(IPeerModel model) { Assert.isNotNull(model); this.model = model; } @@ -57,14 +57,14 @@ public class ChannelStateChangeListener implements IChannelStateChangeListener { IPeer peer = channel.getRemotePeer(); if (peer != null && peer.getID() != null) { // Find the corresponding model node - IPeerModel node = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID()); + IPeerNode node = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID()); if (node != null) { // Increase the channel reference counter by 1 - int counter = node.getIntProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER); + int counter = node.getIntProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER); if (counter < 0) counter = 0; counter++; - node.setProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER, counter); - if (counter > 0) node.setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_CONNECTED); + node.setProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER, counter); + if (counter > 0) node.setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_CONNECTED); } } break; @@ -72,15 +72,15 @@ public class ChannelStateChangeListener implements IChannelStateChangeListener { peer = channel.getRemotePeer(); if (peer != null && peer.getID() != null) { // Find the corresponding model node - IPeerModel node = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID()); + IPeerNode node = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID()); if (node != null) { // Decrease the channel reference counter by 1 - int counter = node.getIntProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER); + int counter = node.getIntProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER); counter--; if (counter < 0) counter = 0; - node.setProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER, counter); - if (counter == 0 && node.isProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_CONNECTED)) { - node.setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_REACHABLE); + node.setProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER, counter); + if (counter == 0 && node.isProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_CONNECTED)) { + node.setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_REACHABLE); } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java index 42476448b..27ba6659f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java @@ -29,13 +29,13 @@ import org.eclipse.tcf.te.tcf.locator.ScannerRunnable; import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; -import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; @@ -44,14 +44,14 @@ import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; */ public final class LocatorListener implements ILocator.LocatorListener { // Reference to the parent model - /* default */ final ILocatorModel model; + /* default */ final IPeerModel model; /** * Constructor. * * @param model The parent locator model. Must not be null. */ - public LocatorListener(ILocatorModel model) { + public LocatorListener(IPeerModel model) { super(); Assert.isNotNull(model); @@ -96,28 +96,26 @@ public final class LocatorListener implements ILocator.LocatorListener { if (model != null && peer != null) { // find the corresponding model node to remove (expected to be null) - IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID()); + IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID()); if (peerNode == null) { // Double check with "ClientID" if set String clientID = peer.getAttributes().get("ClientID"); //$NON-NLS-1$ if (clientID != null) { - peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(clientID); + peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(clientID); } } // If not found, create a new peer node instance if (peerNode == null) { - peerNode = new PeerModel(model, peer); + peerNode = new PeerNode(model, peer); // Validate the peer node before adding peerNode = model.validatePeerNodeForAdd(peerNode); // Add the peer node to the model if (peerNode != null) { // If there are reachable static peers without an agent ID associated or // static peers with unknown link state, refresh the agent ID's first. - List nodes = new ArrayList(); + List nodes = new ArrayList(); - for (IPeerModel node : model.getPeers()) { - // Skip static nodes - if (!node.isStatic()) continue; + for (IPeerNode node : model.getPeers()) { // We expect the agent ID to be set if (node.getPeer().getAgentID() == null || "".equals(node.getPeer().getAgentID())) { //$NON-NLS-1$ nodes.add(node); @@ -125,31 +123,31 @@ public final class LocatorListener implements ILocator.LocatorListener { } // Create the runnable to execute after the agent ID refresh (if needed) - final IPeerModel finPeerNode = peerNode; + final IPeerNode finPeerNode = peerNode; final IPeer finPeer = peer; final Runnable runnable = new Runnable() { @Override public void run() { - IPeerModel[] matches = model.getService(ILocatorModelLookupService.class).lkupMatchingStaticPeerModels(finPeerNode); + IPeerNode[] matches = model.getService(IPeerModelLookupService.class).lkupMatchingStaticPeerModels(finPeerNode); if (matches.length == 0) { // If the peer node is still in the model, schedule for immediate status update - if (model.getService(ILocatorModelLookupService.class).lkupPeerModelById(finPeerNode.getPeerId()) != null) { + if (model.getService(IPeerModelLookupService.class).lkupPeerModelById(finPeerNode.getPeerId()) != null) { Runnable runnable2 = new ScannerRunnable(model.getScanner(), finPeerNode); Protocol.invokeLater(runnable2); } } else { // Remove the preliminary added node from the model again - model.getService(ILocatorModelUpdateService.class).remove(finPeerNode); + model.getService(IPeerModelUpdateService.class).remove(finPeerNode); - for (IPeerModel match : matches) { + for (IPeerNode match : matches) { IPeer myPeer = model.validatePeer(finPeer); if (myPeer != null) { // Update the matching static node boolean changed = match.setChangeEventsEnabled(false); // Merge user configured properties between the peers - model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(match, myPeer, true); + model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(match, myPeer, true); if (changed) match.setChangeEventsEnabled(true); - match.fireChangeEvent(IPeerModelProperties.PROP_INSTANCE, myPeer, match.getPeer()); + match.fireChangeEvent(IPeerNodeProperties.PROP_INSTANCE, myPeer, match.getPeer()); // And schedule for immediate status update Runnable runnable2 = new ScannerRunnable(model.getScanner(), match); Protocol.invokeLater(runnable2); @@ -161,11 +159,11 @@ public final class LocatorListener implements ILocator.LocatorListener { // Preliminary add the node to the model now. If we have to refresh the agent ID, // this is an asynchronous operation and other peerAdded events might be processed before. - model.getService(ILocatorModelUpdateService.class).add(peerNode); + model.getService(IPeerModelUpdateService.class).add(peerNode); if (nodes.size() > 0) { // Refresh the agent ID's first - model.getService(ILocatorModelRefreshService.class).refreshAgentIDs(nodes.toArray(new IPeerModel[nodes.size()]), new Callback() { + model.getService(IPeerModelRefreshService.class).refreshAgentIDs(nodes.toArray(new IPeerNode[nodes.size()]), new Callback() { @Override protected void internalDone(Object caller, IStatus status) { // Ignore errors @@ -179,26 +177,18 @@ public final class LocatorListener implements ILocator.LocatorListener { } } else { // Peer node found, update the peer instance - boolean isStatic = peerNode.isStatic(); - if (isStatic) { // Validate the peer node before updating IPeer myPeer = model.validatePeer(peer); if (myPeer != null) { boolean changed = peerNode.setChangeEventsEnabled(false); // Merge user configured properties between the peers - model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, myPeer, true); + model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, myPeer, true); if (changed) peerNode.setChangeEventsEnabled(true); - peerNode.fireChangeEvent(IPeerModelProperties.PROP_INSTANCE, myPeer, peerNode.getPeer()); + peerNode.fireChangeEvent(IPeerNodeProperties.PROP_INSTANCE, myPeer, peerNode.getPeer()); // And schedule for immediate status update Runnable runnable = new ScannerRunnable(model.getScanner(), peerNode); Protocol.invokeLater(runnable); } - } else { - peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer); - // And schedule for immediate status update - Runnable runnable = new ScannerRunnable(model.getScanner(), peerNode); - Protocol.invokeLater(runnable); - } } } } @@ -229,12 +219,12 @@ public final class LocatorListener implements ILocator.LocatorListener { if (model != null && peer != null) { // find the corresponding model node to remove - IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID()); + IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID()); if (peerNode == null) { // Double check with "ClientID" if set String clientID = peer.getAttributes().get("ClientID"); //$NON-NLS-1$ if (clientID != null) { - peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(clientID); + peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(clientID); } } // Update the peer instance @@ -245,7 +235,7 @@ public final class LocatorListener implements ILocator.LocatorListener { if (oldPeer != peer) { // Peers visible to the locator are replaced with the new instance if (oldPeer instanceof AbstractPeer) { - peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer); + peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer); } // Non-visible peers are updated else { @@ -254,15 +244,15 @@ public final class LocatorListener implements ILocator.LocatorListener { if (myPeer != null) { boolean changed = peerNode.setChangeEventsEnabled(false); // Merge user configured properties between the peers - model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, myPeer, true); + model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, myPeer, true); if (changed) peerNode.setChangeEventsEnabled(true); - peerNode.fireChangeEvent(IPeerModelProperties.PROP_INSTANCE, myPeer, peerNode.getPeer()); + peerNode.fireChangeEvent(IPeerNodeProperties.PROP_INSTANCE, myPeer, peerNode.getPeer()); } } } } // Refresh static peers and merge attributes if required - model.getService(ILocatorModelRefreshService.class).refreshStaticPeers(); + model.getService(IPeerModelRefreshService.class).refreshStaticPeers(); } // Clean up the guardians @@ -282,7 +272,7 @@ public final class LocatorListener implements ILocator.LocatorListener { if (model != null && id != null) { // find the corresponding model node to remove - IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(id); + IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(id); // If we cannot find a model node, it is probably because the remove is sent for the // non-loopback addresses of the localhost. We have to double check this. @@ -309,12 +299,11 @@ public final class LocatorListener implements ILocator.LocatorListener { newId.append(id.substring(endIndex + 1)); // Try the lookup again - peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(newId.toString()); + peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(newId.toString()); } // If the model node is found in the model, process the removal. if (peerNode != null) { - if (peerNode.isStatic()) { boolean changed = peerNode.setChangeEventsEnabled(false); IPeer peer = peerNode.getPeer(); @@ -349,8 +338,8 @@ public final class LocatorListener implements ILocator.LocatorListener { } // Remove the attributes stored at peer node level - peerNode.setProperty(IPeerModelProperties.PROP_LOCAL_SERVICES, null); - peerNode.setProperty(IPeerModelProperties.PROP_REMOTE_SERVICES, null); + peerNode.setProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES, null); + peerNode.setProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES, null); // Check if we have to remote the peer in the underlying locator service too if (remotePeerID != null) { @@ -363,11 +352,11 @@ public final class LocatorListener implements ILocator.LocatorListener { peerNode.getModel().setChildren(peerNode.getPeerId(), null); if (changed) peerNode.setChangeEventsEnabled(true); - peerNode.fireChangeEvent(IPeerModelProperties.PROP_INSTANCE, peer, peerNode.getPeer()); + peerNode.fireChangeEvent(IPeerNodeProperties.PROP_INSTANCE, peer, peerNode.getPeer()); final IModelListener[] listeners = model.getListener(); if (listeners.length > 0) { - final IPeerModel finPeerNode = peerNode; + final IPeerNode finPeerNode = peerNode; Protocol.invokeLater(new Runnable() { @Override public void run() { @@ -377,10 +366,6 @@ public final class LocatorListener implements ILocator.LocatorListener { } }); } - } else { - // Dynamic peer -> Remove peer model node from the model - model.getService(ILocatorModelUpdateService.class).remove(peerNode); - } } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java index 2da4ca45c..ecadefe17 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java @@ -10,8 +10,8 @@ package org.eclipse.tcf.te.tcf.locator.listener; import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Default model listener implementation. @@ -19,17 +19,17 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; public class ModelAdapter implements IModelListener { /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, boolean) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean) */ @Override - public void locatorModelChanged(ILocatorModel model, IPeerModel peerModel, boolean added) { + public void locatorModelChanged(IPeerModel model, IPeerNode peerNode, boolean added) { } /* (non-Javadoc) * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener#locatorModelDisposed(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel) */ @Override - public void locatorModelDisposed(ILocatorModel model) { + public void locatorModelDisposed(IPeerModel model) { } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java index cab63d2f2..2af3c5844 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java @@ -11,9 +11,9 @@ package org.eclipse.tcf.te.tcf.locator.model; import org.eclipse.core.runtime.Assert; import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.nodes.LocatorModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel; /** @@ -21,7 +21,7 @@ import org.eclipse.tcf.te.tcf.locator.nodes.LocatorModel; */ public final class Model { // Reference to the locator model - /* default */ static volatile ILocatorModel locatorModel; + /* default */ static volatile IPeerModel peerModel; /** * Returns the shared locator model instance. @@ -31,7 +31,7 @@ public final class Model { * * @return The shared locator model. */ - public static ILocatorModel getModel() { + public static IPeerModel getModel() { return getModel(false); } @@ -48,9 +48,9 @@ public final class Model { * * @return The shared locator model. */ - public static ILocatorModel getModel(boolean shutdown) { + public static IPeerModel getModel(boolean shutdown) { // Access to the locator model must happen in the TCF dispatch thread - if (locatorModel == null && !shutdown) { + if (peerModel == null && !shutdown) { if (Protocol.isDispatchThread()) { initialize(); } else { @@ -62,7 +62,7 @@ public final class Model { }); } } - return locatorModel; + return peerModel; } /** @@ -73,35 +73,35 @@ public final class Model { // If locator model is set in the mean while, initialize got // called twice. Return immediately in this case. - if (locatorModel != null) return; + if (peerModel != null) return; // Create the model instance - locatorModel = new LocatorModel(); + peerModel = new PeerModel(); // Refresh the model right away - locatorModel.getService(ILocatorModelRefreshService.class).refresh(null); + peerModel.getService(IPeerModelRefreshService.class).refresh(null); // Start the scanner - locatorModel.startScanner(5000, 120000); + peerModel.startScanner(5000, 120000); } /** * Dispose the root node. */ public static void dispose() { - if (locatorModel == null) return; + if (peerModel == null) return; // Access to the locator model must happen in the TCF dispatch thread if (Protocol.isDispatchThread()) { - locatorModel.dispose(); + peerModel.dispose(); } else { Protocol.invokeAndWait(new Runnable() { @Override public void run() { - locatorModel.dispose(); + peerModel.dispose(); } }); } - locatorModel = null; + peerModel = null; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java deleted file mode 100644 index 95b1e989d..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ - -package org.eclipse.tcf.te.tcf.locator.nodes; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.core.interfaces.IConnectable; -import org.eclipse.tcf.te.core.utils.ConnectStateHelper; -import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService; -import org.eclipse.tcf.te.runtime.stepper.utils.StepperHelper; -import org.eclipse.tcf.te.runtime.utils.StatusHelper; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; - -/** - * ConnectablePeerModel - */ -public class ConnectablePeerModel extends PeerModel implements IConnectable { - - public static final String PROPERTY_CONNECT_STATE = "connectState"; //$NON-NLS-1$ - - /** - * Constructor. - * @param model - * @param peer - */ - public ConnectablePeerModel(ILocatorModel model, IPeer peer) { - super(model, peer); - setConnectState(STATE_DISCONNECTED); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.core.interfaces.IConnectable#getConnectState() - */ - @Override - public int getConnectState() { - final AtomicInteger state = new AtomicInteger(STATE_UNKNOWN); - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - if (getProperty(PROPERTY_CONNECT_STATE) != null) { - state.set(getIntProperty(PROPERTY_CONNECT_STATE)); - } - } - }); - return state.get(); - } - - @Override - public boolean setConnectState(final int newState) { - final AtomicBoolean result = new AtomicBoolean(false); - if (isConnectStateChangeAllowed(newState)) { - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - result.set(setProperty(PROPERTY_CONNECT_STATE, newState)); - } - }); - } - return result.get(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.nodes.PeerModel#postSetProperty(java.lang.String, java.lang.Object, java.lang.Object) - */ - @Override - public void postSetProperty(String key, Object value, Object oldValue) { - if (getConnectState() == STATE_CONNECTED && IPeerModelProperties.PROP_STATE.equals(key)) { - int state = value instanceof Integer ? ((Integer)value).intValue() : IPeerModelProperties.STATE_UNKNOWN; - if (state != IPeerModelProperties.STATE_CONNECTED && state != IPeerModelProperties.STATE_REACHABLE) { - changeConnectState(STATE_DISCONNECTED, null, null); - } - } - - super.postSetProperty(key, value, oldValue); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.core.interfaces.IConnectable#changeConnectState(int, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) - */ - @Override - public void changeConnectState(final int action, ICallback callback, IProgressMonitor monitor) throws IllegalArgumentException { - final int oldState = getConnectState(); - if (!isConnectStateChangeActionAllowed(action)) { - IllegalArgumentException e = new IllegalArgumentException("Cannot change state from '" + ConnectStateHelper.getConnectState(oldState) + "' using action '" + ConnectStateHelper.getConnectState(action) + "'."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (callback != null) { - callback.done(this, StatusHelper.getStatus(e)); - } - else { - throw e; - } - } - - String operation = null; - int intermediateState = 0; - - switch (action) { - case ACTION_CONNECT: - operation = IStepperServiceOperations.CONNECT; - intermediateState = STATE_CONNECT_SCHEDULED; - break; - case ACTION_DISCONNECT: - operation = IStepperServiceOperations.DISCONNECT; - intermediateState = STATE_DISCONNECT_SCHEDULED; - break; - } - - IStepperOperationService service = StepperHelper.getService(this, operation); - if (service != null) { - setConnectState(intermediateState); - StepperHelper.scheduleStepperJob(this, operation, service, callback, monitor); - } - else if (callback != null) { - callback.done(this, StatusHelper.getStatus(new NullPointerException("Missing stepper operation service for " + getName() + "."))); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - @Override - public boolean isConnectStateChangeActionAllowed(int action) { - int state = getConnectState(); - switch (state) { - case STATE_CONNECTED: - case STATE_CONNECT_SCHEDULED: - case STATE_CONNECTING: - return isAllowedState(action, ACTION_DISCONNECT); - case STATE_DISCONNECTED: - return isAllowedState(action, ACTION_CONNECT); - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.core.interfaces.IConnectable#isConnectStateChangeAllowed(int) - */ - @Override - public boolean isConnectStateChangeAllowed(int newState) { - int state = getConnectState(); - switch (state) { - case STATE_CONNECTED: - return isAllowedState(newState, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING); - case STATE_CONNECT_SCHEDULED: - return isAllowedState(newState, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING); - case STATE_CONNECTING: - return isAllowedState(newState, STATE_CONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING, STATE_DISCONNECTED); - case STATE_DISCONNECTED: - return isAllowedState(newState, STATE_CONNECTED, STATE_CONNECT_SCHEDULED, STATE_CONNECTING); - case STATE_DISCONNECT_SCHEDULED: - return isAllowedState(newState, STATE_DISCONNECTING, STATE_DISCONNECTED); - case STATE_DISCONNECTING: - return isAllowedState(newState, STATE_DISCONNECTED); - case STATE_UNKNOWN: - return isAllowedState(newState, STATE_DISCONNECTED); - } - return false; - } - - private boolean isAllowedState(int state, int... allowedStates) { - for (int allowedState : allowedStates) { - if (state == allowedState) { - return true; - } - } - return false; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java deleted file mode 100644 index 45a47c802..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java +++ /dev/null @@ -1,785 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.nodes; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.services.ILocator; -import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil; -import org.eclipse.tcf.te.tcf.core.Tcf; -import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener; -import org.eclipse.tcf.te.tcf.locator.Scanner; -import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; -import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner; -import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; -import org.eclipse.tcf.te.tcf.locator.listener.ChannelStateChangeListener; -import org.eclipse.tcf.te.tcf.locator.listener.LocatorListener; -import org.eclipse.tcf.te.tcf.locator.services.LocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.services.LocatorModelPeerNodeQueryService; -import org.eclipse.tcf.te.tcf.locator.services.LocatorModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.services.LocatorModelUpdateService; - - -/** - * Default locator model implementation. - */ -public class LocatorModel extends PlatformObject implements ILocatorModel { - // The unique model id - private final UUID uniqueId = UUID.randomUUID(); - // Flag to mark the model disposed - private boolean disposed; - - // The list of known peers - /* default */ final Map peers = new HashMap(); - // The list of "proxied" peers per proxy peer id - /* default */ final Map> peerChildren = new HashMap>(); - - // Reference to the scanner - private IScanner scanner = null; - - // Reference to the model locator listener - private ILocator.LocatorListener locatorListener = null; - // Reference to the model channel state change listener - private IChannelStateChangeListener channelStateChangeListener = null; - - // The list of registered model listeners - private final List modelListener = new ArrayList(); - - // Reference to the refresh service - private final ILocatorModelRefreshService refreshService = new LocatorModelRefreshService(this); - // Reference to the lookup service - private final ILocatorModelLookupService lookupService = new LocatorModelLookupService(this); - // Reference to the update service - private final ILocatorModelUpdateService updateService = new LocatorModelUpdateService(this); - // Reference to the query service - private final ILocatorModelPeerNodeQueryService queryService = new LocatorModelPeerNodeQueryService(this); - - /** - * Constructor. - */ - public LocatorModel() { - super(); - disposed = false; - - channelStateChangeListener = new ChannelStateChangeListener(this); - Tcf.addChannelStateChangeListener(channelStateChangeListener); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#addListener(org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener) - */ - @Override - public void addListener(IModelListener listener) { - Assert.isNotNull(listener); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.addListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ - } - - if (!modelListener.contains(listener)) modelListener.add(listener); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#removeListener(org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener) - */ - @Override - public void removeListener(IModelListener listener) { - Assert.isNotNull(listener); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.removeListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ - } - - modelListener.remove(listener); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#getListener() - */ - @Override - public IModelListener[] getListener() { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - return modelListener.toArray(new IModelListener[modelListener.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#dispose() - */ - @Override - public void dispose() { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.dispose()", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ - } - - // If already disposed, we are done immediately - if (disposed) return; - - disposed = true; - - final IModelListener[] listeners = getListener(); - if (listeners.length > 0) { - Protocol.invokeLater(new Runnable() { - @Override - public void run() { - for (IModelListener listener : listeners) { - listener.locatorModelDisposed(LocatorModel.this); - } - } - }); - } - modelListener.clear(); - - if (locatorListener != null) { - Protocol.getLocator().removeListener(locatorListener); - locatorListener = null; - } - - if (channelStateChangeListener != null) { - Tcf.removeChannelStateChangeListener(channelStateChangeListener); - channelStateChangeListener = null; - } - - if (scanner != null) { - stopScanner(); - scanner = null; - } - - peers.clear(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#isDisposed() - */ - @Override - public boolean isDisposed() { - return disposed; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getPeers() - */ - @Override - public IPeerModel[] getPeers() { - final AtomicReference result = new AtomicReference(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - result.set(peers.values().toArray(new IPeerModel[peers.values().size()])); - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - - return result.get(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#getChildren(java.lang.String) - */ - @Override - public List getChildren(final String parentPeerID) { - Assert.isNotNull(parentPeerID); - - final AtomicReference> result = new AtomicReference>(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - List children = peerChildren.get(parentPeerID); - if (children == null) children = Collections.emptyList(); - result.set(children); - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - - return Collections.unmodifiableList(result.get()); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#setChildren(java.lang.String, java.util.List) - */ - @Override - public void setChildren(String parentPeerID, List children) { - Assert.isNotNull(parentPeerID); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (children == null || children.size() == 0) { - peerChildren.remove(parentPeerID); - } else { - peerChildren.put(parentPeerID, new ArrayList(children)); - } - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) - */ - @Override - public Object getAdapter(Class adapter) { - if (adapter.isAssignableFrom(ILocator.LocatorListener.class)) { - return locatorListener; - } - if (adapter.isAssignableFrom(IScanner.class)) { - return scanner; - } - if (adapter.isAssignableFrom(ILocatorModelRefreshService.class)) { - return refreshService; - } - if (adapter.isAssignableFrom(ILocatorModelLookupService.class)) { - return lookupService; - } - if (adapter.isAssignableFrom(ILocatorModelUpdateService.class)) { - return updateService; - } - if (adapter.isAssignableFrom(ILocatorModelPeerNodeQueryService.class)) { - return queryService; - } - if (adapter.isAssignableFrom(Map.class)) { - return peers; - } - - return super.getAdapter(adapter); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return uniqueId.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public final boolean equals(Object obj) { - if (obj instanceof LocatorModel) { - return uniqueId.equals(((LocatorModel)obj).uniqueId); - } - return super.equals(obj); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getService(java.lang.Class) - */ - @Override - @SuppressWarnings("unchecked") - public V getService(Class serviceInterface) { - Assert.isNotNull(serviceInterface); - return (V)getAdapter(serviceInterface); - } - - /** - * Check if the locator listener has been created and registered - * to the global locator service. - *

- * Note: This method is not intended to be call from clients. - */ - public void checkLocatorListener() { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(Protocol.getLocator()); - - if (locatorListener == null) { - locatorListener = doCreateLocatorListener(this); - Protocol.getLocator().addListener(locatorListener); - } - } - - /** - * Creates the locator listener instance. - * - * @param model The parent model. Must not be null. - * @return The locator listener instance. - */ - protected ILocator.LocatorListener doCreateLocatorListener(ILocatorModel model) { - Assert.isNotNull(model); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - return new LocatorListener(model); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getScanner() - */ - @Override - public IScanner getScanner() { - if (scanner == null) scanner = new Scanner(this); - return scanner; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#startScanner(long, long) - */ - @Override - public void startScanner(long delay, long schedule) { - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.startScanner( " + delay + ", " + schedule + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - IScanner scanner = getScanner(); - Assert.isNotNull(scanner); - - // Pass on the schedule parameter - Map config = new HashMap(scanner.getConfiguration()); - config.put(IScanner.PROP_SCHEDULE, Long.valueOf(schedule)); - scanner.setConfiguration(config); - - // The default scanner implementation is a job. - // -> schedule here if it is a job - if (scanner instanceof Job) { - Job job = (Job)scanner; - job.setSystem(true); - job.setPriority(Job.DECORATE); - job.schedule(delay); - } - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#stopScanner() - */ - @Override - public void stopScanner() { - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.stopScanner()", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ - } - - if (scanner != null) { - // Terminate the scanner - scanner.terminate(); - // Reset the scanner reference - scanner = null; - } - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#validatePeer(org.eclipse.tcf.protocol.IPeer) - */ - @Override - public IPeer validatePeer(IPeer peer) { - Assert.isNotNull(peer); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeer( " + peer.getID() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ - } - - IPeer result = peer; - - // Get the loopback address - String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress(); - // Get the peer IP - String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST); - - // If the peer node is for local host, we ignore all peers not being - // associated with the loopback address. - if (IPAddressUtil.getInstance().isLocalHost(peerIP) && !loopback.equals(peerIP)) { - // Not loopback address -> drop the peer - result = null; - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeer: local host peer but not loopback address -> peer node dropped" //$NON-NLS-1$ - , ITracing.ID_TRACE_LOCATOR_MODEL, this); - } - } - - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#validatePeerNodeForAdd(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel) - */ - @Override - public IPeerModel validatePeerNodeForAdd(IPeerModel node) { - Assert.isNotNull(node); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // Get the peer from the peer node - IPeer peer = node.getPeer(); - if (peer == null) return node; - - // Skip static peer IP address validation - boolean isStatic = node.isStatic(); - if (isStatic) return node; - - // Skip validation if the transport type is not TCP or SSL - String transport = peer.getTransportName(); - if (transport == null || !"TCP".equals(transport) && !"SSL".equals(transport)){ //$NON-NLS-1$ //$NON-NLS-2$ - return node; - } - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd( " + peer.getID() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ - } - - IPeerModel result = node; - - // Get the loopback address - String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress(); - // Get the peer IP - String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST); - - // If the peer node is for local host, we ignore all peers not being - // associated with the loopback address. - if (IPAddressUtil.getInstance().isLocalHost(peerIP) && !loopback.equals(peerIP)) { - boolean drop = true; - - // Simulator nodes appears on local host IP addresses too, but does not have - // a loopback peer available. We have to check the agent ID to determine if - // a specific node can be dropped - String agentID = peer.getAgentID(); - if (agentID != null) { - // Get all discovered peers - Map peers = Protocol.getLocator().getPeers(); - // Sort them by agent id - Map> byAgentID = new HashMap>(); - - for (IPeer candidate : peers.values()) { - if (candidate.getAgentID() == null) continue; - - List l = byAgentID.get(candidate.getAgentID()); - if (l == null) { - l = new ArrayList(); - byAgentID.put(candidate.getAgentID(), l); - } - Assert.isNotNull(l); - if (!l.contains(candidate)) l.add(candidate); - } - - // Check all peers found for the same agent ID as the current peer to validate - List candidates = byAgentID.get(agentID); - if (candidates != null && candidates.size() > 1) { - // Check if the found peers contains one with the loopback address - drop = false; - for (IPeer candidate : candidates) { - String ip = candidate.getAttributes().get(IPeer.ATTR_IP_HOST); - if (IPAddressUtil.getInstance().isLocalHost(ip) && loopback.equals(ip)) { - drop = true; - break; - } - } - } else { - // No other node for this agent ID -> do not drop the peer - drop = false; - } - } - - - if (drop) { - // Not loopback address -> drop the peer - result = null; - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: local host peer but not loopback address -> peer node dropped", //$NON-NLS-1$ - ITracing.ID_TRACE_LOCATOR_MODEL, this); - } - } - } - - // Continue filtering if the node is not yet dropped - if (result != null) { - List previousNodes = new ArrayList(); - - // Peers are filtered by agent id. Don't add the peer node if we have another peer - // node already having the same agent id - String agentId = peer.getAgentID(); - if (agentId != null) { - previousNodes.addAll(Arrays.asList(getService(ILocatorModelLookupService.class).lkupPeerModelByAgentId(agentId))); - } - - // Lookup for matching static peer nodes not found by the agent id lookup - IPeerModel[] candidates = getService(ILocatorModelLookupService.class).lkupMatchingStaticPeerModels(peer); - for (IPeerModel candidate : candidates) { - if (!previousNodes.contains(candidate)) previousNodes.add(candidate); - } - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: agentId=" + agentId + ", Matching peer nodes " //$NON-NLS-1$ //$NON-NLS-2$ - + (previousNodes.size() > 0 ? "found (" + previousNodes.size() +")" : "not found --> DONE") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - , ITracing.ID_TRACE_LOCATOR_MODEL, this); - } - - for (IPeerModel previousNode : previousNodes) { - // Get the peer for the previous node - IPeer previousPeer = previousNode.getPeer(); - if (previousPeer != null) { - // Get the IP address of the previous node - String previousPeerIP = previousPeer.getAttributes().get(IPeer.ATTR_IP_HOST); - if (IPAddressUtil.getInstance().isLocalHost(previousPeerIP) && !loopback.equals(previousPeerIP) && loopback.equals(peerIP)) { - // Remove the previous node from the model - getService(ILocatorModelUpdateService.class).remove(previousNode); - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: Previous peer removed and replaced by new peer representing the loopback address" //$NON-NLS-1$ - , ITracing.ID_TRACE_LOCATOR_MODEL, this); - } - - continue; - } - - // Get the ports - String peerPort = peer.getAttributes().get(IPeer.ATTR_IP_PORT); - String previousPeerPort = previousPeer.getAttributes().get(IPeer.ATTR_IP_PORT); - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: peerIP=" + peerIP //$NON-NLS-1$ - + ", peerPort=" + peerPort + ", previousPeerPort=" + previousPeerPort //$NON-NLS-1$ //$NON-NLS-2$ - , ITracing.ID_TRACE_LOCATOR_MODEL, this); - } - - // If the ports of the agent instances are identical, - // than try to find the best representation of the agent instance - if (peerPort != null && peerPort.equals(previousPeerPort)) { - // Drop the current node - result = null; - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: Previous peer node kept, new peer node dropped" //$NON-NLS-1$ - , ITracing.ID_TRACE_LOCATOR_MODEL, this); - } - - - // Break the loop if the ports matched - break; - } - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: Previous peer node kept, new peer node added (Port mismatch)" //$NON-NLS-1$ - , ITracing.ID_TRACE_LOCATOR_MODEL, this); - } - } - } - } - - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#validateChildPeerNodeForAdd(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) - */ - @Override - public IPeerModel validateChildPeerNodeForAdd(final IPeerModel node) { - Assert.isNotNull(node); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validateChildPeerNodeForAdd( " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // Determine the parent node. If null, the child node is invalid - // and cannot be added - final IPeerModel parent = node.getParent(IPeerModel.class); - if (parent == null) return null; - - return validateChildPeerNodeForAdd(parent, node); - } - - /** - * Validates the given child peer model node in relation to the given parent peer model node - * hierarchy. - *

- * The method is recursive. - * - * @param parent The parent model node. Must not be null. - * @param node The child model node. Must not be null. - * - * @return The validated child peer model node, or null. - */ - protected IPeerModel validateChildPeerNodeForAdd(IPeerModel parent, IPeerModel node) { - Assert.isNotNull(parent); - Assert.isNotNull(node); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.validateChildPeerNodeForAdd( " + parent.getPeerId() + ", " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - // Validate against the given parent - if (doValidateChildPeerNodeForAdd(parent, node) == null) { - return null; - } - - // If the parent node is child node by itself, validate the - // child node against the parent parent node. - if (parent.getParent(IPeerModel.class) != null) { - IPeerModel parentParentNode = parent.getParent(IPeerModel.class); - if (doValidateChildPeerNodeForAdd(parentParentNode, node) == null) { - return null; - } - - // And validate the child node against all child nodes of the parent parent. - List childrenList = getChildren(parentParentNode.getPeerId()); - IPeerModel[] children = childrenList.toArray(new IPeerModel[childrenList.size()]); - for (IPeerModel parentParentChild : children) { - if (node.equals(parentParentChild) || parent.equals(parentParentChild)) { - return null; - } - if (doValidateChildPeerNodeForAdd(parentParentChild, node) == null) { - return null; - } - } - } - - return node; - } - - /** - * Validates the given child peer model node in relation to the given parent peer model node. - *

- * The method is non-recursive. - * - * @param parent The parent model node. Must not be null. - * @param node The child model node. Must not be null. - * - * @return The validated child peer model node, or null. - */ - protected IPeerModel doValidateChildPeerNodeForAdd(IPeerModel parent, IPeerModel node) { - Assert.isNotNull(parent); - Assert.isNotNull(node); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { - CoreBundleActivator.getTraceHandler().trace("LocatorModel.doValidateChildPeerNodeForAdd( " + parent.getPeerId() + ", " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - // If the child node is already visible as root node, drop the child node - String id = node.getPeerId(); - if (isRootNode(id)) { - return null; - } - - int beginIndex = id.indexOf(':'); - int endIndex = id.lastIndexOf(':'); - String ip = beginIndex != -1 && endIndex != -1 ? id.substring(beginIndex+1, endIndex) : ""; //$NON-NLS-1$ - - // Get the loopback address - String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress(); - // Empty IP address means loopback - if ("".equals(ip)) ip = loopback; //$NON-NLS-1$ - - // If the IP is a localhost IP, try the loopback IP - if (IPAddressUtil.getInstance().isLocalHost(ip)) { - // Build up the new id to lookup - StringBuilder newId = new StringBuilder(); - newId.append(id.substring(0, beginIndex)); - newId.append(':'); - newId.append(loopback); - newId.append(':'); - newId.append(id.substring(endIndex + 1)); - - // Try the lookup again - if (isRootNode(newId.toString())) { - return null; - } - } - - // Get the peer from the peer node - IPeer peer = node.getPeer(); - - // If the child peer represents the same agent as the parent peer, - // drop the child peer - String parentAgentID = parent.getPeer().getAgentID(); - if (parentAgentID != null && parentAgentID.equals(peer.getAgentID())) { - return null; - } - // If the child peer represents the same agent as another child peer, - // drop the child peer - String agentID = node.getPeer().getAgentID(); - if (agentID != null) { - IPeerModel[] matches = getService(ILocatorModelLookupService.class).lkupPeerModelByAgentId(parent.getPeerId(), agentID); - for (IPeerModel match : matches) { - if (agentID.equals(match.getPeer().getAgentID())) { - // Try to keep the peer with the real IP, filter the "127.0.0.1" peer - if ("127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$ - && !"127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$ - // Keep the other child node - return null; - } - - if (!"127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$ - && "127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$ - // Keep the node - getService(ILocatorModelUpdateService.class).removeChild(match); - } - - // If both nodes have a IP different from "127.0.0.1", keep the first node - if (!"127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$ - && !"127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$ - // Keep the other child node - return null; - } - } - } - } - // If the child peer's IP address and port are the same as the parent's - // IP address and port, drop the child node - Map parentPeerAttributes = parent.getPeer().getAttributes(); - if (parentPeerAttributes.get(IPeer.ATTR_IP_HOST) != null && parentPeerAttributes.get(IPeer.ATTR_IP_HOST).equals(peer.getAttributes().get(IPeer.ATTR_IP_HOST))) { - String parentPort = parentPeerAttributes.get(IPeer.ATTR_IP_PORT); - String port = peer.getAttributes().get(IPeer.ATTR_IP_PORT); - - if (parentPort != null && parentPort.equals(port)) return null; - } - - return node; - } - - /** - * Checks if the given peer id belongs to an already known root node - * or to one of the discovered nodes. - * - * @param id The peer id. Must not be null. - * @return True if the given id belongs to a root node, false otherwise. - */ - private boolean isRootNode(String id) { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(id); - - boolean isRoot = false; - - if (getService(ILocatorModelLookupService.class).lkupPeerModelById(id) != null) { - isRoot = true; - } else { - Map peers = Protocol.getLocator().getPeers(); - if (peers.containsKey(id)) { - isRoot = true; - } - } - - return isRoot; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java index aae484eec..19d9e40af 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java @@ -9,344 +9,775 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.locator.nodes; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; +import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.runtime.model.ContainerModelNode; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; +import org.eclipse.tcf.services.ILocator; +import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener; +import org.eclipse.tcf.te.tcf.locator.Scanner; +import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; +import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; +import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner; +import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.listener.ChannelStateChangeListener; +import org.eclipse.tcf.te.tcf.locator.listener.LocatorListener; +import org.eclipse.tcf.te.tcf.locator.services.PeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.services.PeerModelQueryService; +import org.eclipse.tcf.te.tcf.locator.services.PeerModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.services.PeerModelUpdateService; /** - * Default peer model implementation. + * Default locator model implementation. */ -public class PeerModel extends ContainerModelNode implements IPeerModel { - // Reference to the parent locator model - private final ILocatorModel model; - // Reference to the peer id (cached for performance optimization) - private String peerId; +public class PeerModel extends PlatformObject implements IPeerModel { + // The unique model id + private final UUID uniqueId = UUID.randomUUID(); + // Flag to mark the model disposed + private boolean disposed; + + // The list of known peers + /* default */ final Map peers = new HashMap(); + // The list of "proxied" peers per proxy peer id + /* default */ final Map> peerChildren = new HashMap>(); + + // Reference to the scanner + private IScanner scanner = null; + + // Reference to the model locator listener + private ILocator.LocatorListener locatorListener = null; + // Reference to the model channel state change listener + private IChannelStateChangeListener channelStateChangeListener = null; + + // The list of registered model listeners + private final List modelListener = new ArrayList(); + + // Reference to the refresh service + private final IPeerModelRefreshService refreshService = new PeerModelRefreshService(this); + // Reference to the lookup service + private final IPeerModelLookupService lookupService = new PeerModelLookupService(this); + // Reference to the update service + private final IPeerModelUpdateService updateService = new PeerModelUpdateService(this); + // Reference to the query service + private final IPeerModelQueryService queryService = new PeerModelQueryService(this); /** * Constructor. - * - * @param model The parent locator model. Must not be null. - * @param peer The peer. Must not be null. */ - public PeerModel(ILocatorModel model, IPeer peer) { + public PeerModel() { super(); + disposed = false; - Assert.isNotNull(model); - this.model = model; - - Assert.isNotNull(peer); - - // Set the default properties before enabling the change events. - // The properties changed listeners should not be called from the - // constructor. - setProperty(IPeerModelProperties.PROP_INSTANCE, peer); - - // Initialize the peer id - peerId = peer.getID(); - Assert.isNotNull(peerId); - - // Peer model nodes can change the node parent at any time - allowSetParentOnNonNullParent = true; - // Peer model nodes does not have a parent by default - // -> allow change events with null parent - suppressEventsOnNullParent = false; - - // Enable change events - setChangeEventsEnabled(true); + channelStateChangeListener = new ChannelStateChangeListener(this); + Tcf.addChannelStateChangeListener(channelStateChangeListener); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#checkThreadAccess() + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#addListener(org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener) */ @Override - protected final boolean checkThreadAccess() { - return Protocol.isDispatchThread(); - } + public void addListener(IModelListener listener) { + Assert.isNotNull(listener); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getModel() - */ - @Override - public ILocatorModel getModel() { - return (ILocatorModel)getAdapter(ILocatorModel.class); - } + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.addListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ + } - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getPeer() - */ - @Override - public IPeer getPeer() { - return (IPeer)getAdapter(IPeer.class); + if (!modelListener.contains(listener)) modelListener.add(listener); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getPeerId() + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#removeListener(org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener) */ @Override - public String getPeerId() { - return peerId; + public void removeListener(IModelListener listener) { + Assert.isNotNull(listener); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.removeListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ + } + + modelListener.remove(listener); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.ModelNode#getName() + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getListener() */ @Override - public String getName() { - return getPeer().getName(); + public IModelListener[] getListener() { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + return modelListener.toArray(new IModelListener[modelListener.size()]); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getRemotePeerId() + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#dispose() */ @Override - public String getRemotePeerId() { - // If the peer is a remote peer by itself, than we return getPeerId() - if ("RemotePeer".equals(getPeer().getClass().getSimpleName())) { //$NON-NLS-1$ - return getPeerId(); + public void dispose() { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.dispose()", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ } - // Try to determine the remote peer ID - final AtomicReference remotePeerId = new AtomicReference(); - Runnable runnable = new Runnable() { - @Override - public void run() { - remotePeerId.set(getPeer().getAttributes().get("remote.id.transient")); //$NON-NLS-1$ - } - }; + // If already disposed, we are done immediately + if (disposed) return; + + disposed = true; + + final IModelListener[] listeners = getListener(); + if (listeners.length > 0) { + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + for (IModelListener listener : listeners) { + listener.locatorModelDisposed(PeerModel.this); + } + } + }); + } + modelListener.clear(); - if (Protocol.isDispatchThread()) { - runnable.run(); + if (locatorListener != null) { + Protocol.getLocator().removeListener(locatorListener); + locatorListener = null; } - else { - Protocol.invokeAndWait(runnable); + + if (channelStateChangeListener != null) { + Tcf.removeChannelStateChangeListener(channelStateChangeListener); + channelStateChangeListener = null; + } + + if (scanner != null) { + stopScanner(); + scanner = null; } - return remotePeerId.get(); + peers.clear(); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isComplete() + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#isDisposed() */ @Override - public boolean isComplete() { - Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ - - boolean complete = true; - - // Determine the transport method - String transport = getPeer().getTransportName(); - // If the transport is not set, the peer attributes are incomplete - if (transport == null) { - complete = false; - } else { - // For TCP or SSL transport, ATTR_IP_HOST must not be null. - String ip = getPeer().getAttributes().get(IPeer.ATTR_IP_HOST); - String port = getPeer().getAttributes().get(IPeer.ATTR_IP_PORT); - if (("TCP".equals(transport) || "SSL".equals(transport)) && (ip == null || port == null)) { //$NON-NLS-1$ //$NON-NLS-2$ - complete = false; - } - - // Pipe and Loop transport does not require additional attributes - } - - return complete; + public boolean isDisposed() { + return disposed; } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isStatic() + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getPeers() */ @Override - public boolean isStatic() { - final AtomicBoolean isStatic = new AtomicBoolean(); + public IPeerNode[] getPeers() { + final AtomicReference result = new AtomicReference(); Runnable runnable = new Runnable() { @Override public void run() { - String value = getPeer().getAttributes().get("static.transient"); //$NON-NLS-1$ - isStatic.set(value != null && Boolean.parseBoolean(value.trim())); + result.set(peers.values().toArray(new IPeerNode[peers.values().size()])); } }; if (Protocol.isDispatchThread()) runnable.run(); else Protocol.invokeAndWait(runnable); - return isStatic.get(); + return result.get(); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isRemote() + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getChildren(java.lang.String) */ @Override - public boolean isRemote() { - final AtomicBoolean isRemote = new AtomicBoolean(); + public List getChildren(final String parentPeerID) { + Assert.isNotNull(parentPeerID); + + final AtomicReference> result = new AtomicReference>(); Runnable runnable = new Runnable() { @Override public void run() { - // Determine the "remote" flag - String value = getPeer().getAttributes().get("remote.transient"); //$NON-NLS-1$ - boolean bValue = value != null && Boolean.parseBoolean(value.trim()); - - // The peer model node is considered to be remote if it is a remote peer - // or the "remote" flag is set. - isRemote.set("RemotePeer".equals(getPeer().getClass().getSimpleName()) || bValue); //$NON-NLS-1$ + List children = peerChildren.get(parentPeerID); + if (children == null) children = Collections.emptyList(); + result.set(children); } }; if (Protocol.isDispatchThread()) runnable.run(); else Protocol.invokeAndWait(runnable); - return isRemote.get(); + return Collections.unmodifiableList(result.get()); } /* (non-Javadoc) - * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#setChildren(java.lang.String, java.util.List) */ @Override - public Object getAdapter(final Class adapter) { - // NOTE: The getAdapter(...) method can be invoked from many place and - // many threads where we cannot control the calls. Therefore, this - // method is allowed be called from any thread. - final AtomicReference object = new AtomicReference(); - Runnable runnable = new Runnable() { - @Override - public void run() { - object.set(doGetAdapter(adapter)); - } - }; + public void setChildren(String parentPeerID, List children) { + Assert.isNotNull(parentPeerID); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - if (Protocol.isDispatchThread()) { - runnable.run(); + if (children == null || children.size() == 0) { + peerChildren.remove(parentPeerID); + } else { + peerChildren.put(parentPeerID, new ArrayList(children)); + } + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + if (adapter.isAssignableFrom(ILocator.LocatorListener.class)) { + return locatorListener; + } + if (adapter.isAssignableFrom(IScanner.class)) { + return scanner; + } + if (adapter.isAssignableFrom(IPeerModelRefreshService.class)) { + return refreshService; } - else { - Protocol.invokeAndWait(runnable); + if (adapter.isAssignableFrom(IPeerModelLookupService.class)) { + return lookupService; + } + if (adapter.isAssignableFrom(IPeerModelUpdateService.class)) { + return updateService; + } + if (adapter.isAssignableFrom(IPeerModelQueryService.class)) { + return queryService; + } + if (adapter.isAssignableFrom(Map.class)) { + return peers; } - return object.get() != null ? object.get() : super.getAdapter(adapter); + return super.getAdapter(adapter); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return uniqueId.hashCode(); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public final boolean equals(Object obj) { + if (obj instanceof PeerModel) { + return uniqueId.equals(((PeerModel)obj).uniqueId); + } + return super.equals(obj); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getService(java.lang.Class) + */ + @Override + @SuppressWarnings("unchecked") + public V getService(Class serviceInterface) { + Assert.isNotNull(serviceInterface); + return (V)getAdapter(serviceInterface); } /** - * Returns an object which is an instance of the given class associated with this object. - * Returns null if no such object can be found. + * Check if the locator listener has been created and registered + * to the global locator service. *

- * This method must be called within the TCF dispatch thread! - * - * @param adapter The adapter class to look up. - * @return The adapter or null. + * Note: This method is not intended to be call from clients. */ - protected Object doGetAdapter(Class adapter) { - Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ + public void checkLocatorListener() { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + Assert.isNotNull(Protocol.getLocator()); - if (ILocatorModel.class.isAssignableFrom(adapter)) { - return model; + if (locatorListener == null) { + locatorListener = doCreateLocatorListener(this); + Protocol.getLocator().addListener(locatorListener); } + } - Object peer = getProperty(IPeerModelProperties.PROP_INSTANCE); - // Check with adapter.isAssignableFrom(...) to return the peer instance - // correctly if adapter is IPeer.class. - if (peer != null && adapter.isAssignableFrom(peer.getClass())) { - return peer; - } + /** + * Creates the locator listener instance. + * + * @param model The parent model. Must not be null. + * @return The locator listener instance. + */ + protected ILocator.LocatorListener doCreateLocatorListener(IPeerModel model) { + Assert.isNotNull(model); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - return null; + return new LocatorListener(model); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#toString() + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getScanner() */ @Override - public String toString() { - final StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); + public IScanner getScanner() { + if (scanner == null) scanner = new Scanner(this); + return scanner; + } - Runnable runnable = new Runnable() { - @Override - public void run() { - IPeer peer = getPeer(); - buffer.append(": id=" + peer.getID()); //$NON-NLS-1$ - buffer.append(", name=" + peer.getName()); //$NON-NLS-1$ - } - }; + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#startScanner(long, long) + */ + @Override + public void startScanner(long delay, long schedule) { + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.startScanner( " + delay + ", " + schedule + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } - if (Protocol.isDispatchThread()) { - runnable.run(); + IScanner scanner = getScanner(); + Assert.isNotNull(scanner); + + // Pass on the schedule parameter + Map config = new HashMap(scanner.getConfiguration()); + config.put(IScanner.PROP_SCHEDULE, Long.valueOf(schedule)); + scanner.setConfiguration(config); + + // The default scanner implementation is a job. + // -> schedule here if it is a job + if (scanner instanceof Job) { + Job job = (Job)scanner; + job.setSystem(true); + job.setPriority(Job.DECORATE); + job.schedule(delay); } - else { - Protocol.invokeAndWait(runnable); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#stopScanner() + */ + @Override + public void stopScanner() { + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.stopScanner()", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ } - buffer.append(", " + super.toString()); //$NON-NLS-1$ - return buffer.toString(); + if (scanner != null) { + // Terminate the scanner + scanner.terminate(); + // Reset the scanner reference + scanner = null; + } } /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#equals(java.lang.Object) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#validatePeer(org.eclipse.tcf.protocol.IPeer) */ @Override - public boolean equals(Object obj) { - if (obj instanceof PeerModel) { - return getPeerId().equals(((PeerModel)obj).getPeerId()); + public IPeer validatePeer(IPeer peer) { + Assert.isNotNull(peer); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeer( " + peer.getID() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ } - return super.equals(obj); + + IPeer result = peer; + + // Get the loopback address + String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress(); + // Get the peer IP + String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST); + + // If the peer node is for local host, we ignore all peers not being + // associated with the loopback address. + if (IPAddressUtil.getInstance().isLocalHost(peerIP) && !loopback.equals(peerIP)) { + // Not loopback address -> drop the peer + result = null; + + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeer: local host peer but not loopback address -> peer node dropped" //$NON-NLS-1$ + , ITracing.ID_TRACE_LOCATOR_MODEL, this); + } + } + + return result; } /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#hashCode() + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#validatePeerNodeForAdd(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel) */ @Override - public int hashCode() { - return getPeerId().hashCode(); + public IPeerNode validatePeerNodeForAdd(IPeerNode node) { + Assert.isNotNull(node); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + // Get the peer from the peer node + IPeer peer = node.getPeer(); + if (peer == null) return node; + + // Skip static peer IP address validation + return node; + +// // Skip validation if the transport type is not TCP or SSL +// String transport = peer.getTransportName(); +// if (transport == null || !"TCP".equals(transport) && !"SSL".equals(transport)){ //$NON-NLS-1$ //$NON-NLS-2$ +// return node; +// } +// +// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { +// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd( " + peer.getID() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ +// } +// +// IPeerNode result = node; +// +// // Get the loopback address +// String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress(); +// // Get the peer IP +// String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST); +// +// // If the peer node is for local host, we ignore all peers not being +// // associated with the loopback address. +// if (IPAddressUtil.getInstance().isLocalHost(peerIP) && !loopback.equals(peerIP)) { +// boolean drop = true; +// +// // Simulator nodes appears on local host IP addresses too, but does not have +// // a loopback peer available. We have to check the agent ID to determine if +// // a specific node can be dropped +// String agentID = peer.getAgentID(); +// if (agentID != null) { +// // Get all discovered peers +// Map peers = Protocol.getLocator().getPeers(); +// // Sort them by agent id +// Map> byAgentID = new HashMap>(); +// +// for (IPeer candidate : peers.values()) { +// if (candidate.getAgentID() == null) continue; +// +// List l = byAgentID.get(candidate.getAgentID()); +// if (l == null) { +// l = new ArrayList(); +// byAgentID.put(candidate.getAgentID(), l); +// } +// Assert.isNotNull(l); +// if (!l.contains(candidate)) l.add(candidate); +// } +// +// // Check all peers found for the same agent ID as the current peer to validate +// List candidates = byAgentID.get(agentID); +// if (candidates != null && candidates.size() > 1) { +// // Check if the found peers contains one with the loopback address +// drop = false; +// for (IPeer candidate : candidates) { +// String ip = candidate.getAttributes().get(IPeer.ATTR_IP_HOST); +// if (IPAddressUtil.getInstance().isLocalHost(ip) && loopback.equals(ip)) { +// drop = true; +// break; +// } +// } +// } else { +// // No other node for this agent ID -> do not drop the peer +// drop = false; +// } +// } +// +// +// if (drop) { +// // Not loopback address -> drop the peer +// result = null; +// +// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { +// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: local host peer but not loopback address -> peer node dropped", //$NON-NLS-1$ +// ITracing.ID_TRACE_LOCATOR_MODEL, this); +// } +// } +// } +// +// // Continue filtering if the node is not yet dropped +// if (result != null) { +// List previousNodes = new ArrayList(); +// +// // Peers are filtered by agent id. Don't add the peer node if we have another peer +// // node already having the same agent id +// String agentId = peer.getAgentID(); +// if (agentId != null) { +// previousNodes.addAll(Arrays.asList(getService(IPeerModelLookupService.class).lkupPeerModelByAgentId(agentId))); +// } +// +// // Lookup for matching static peer nodes not found by the agent id lookup +// IPeerNode[] candidates = getService(IPeerModelLookupService.class).lkupMatchingStaticPeerModels(peer); +// for (IPeerNode candidate : candidates) { +// if (!previousNodes.contains(candidate)) previousNodes.add(candidate); +// } +// +// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { +// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: agentId=" + agentId + ", Matching peer nodes " //$NON-NLS-1$ //$NON-NLS-2$ +// + (previousNodes.size() > 0 ? "found (" + previousNodes.size() +")" : "not found --> DONE") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ +// , ITracing.ID_TRACE_LOCATOR_MODEL, this); +// } +// +// for (IPeerNode previousNode : previousNodes) { +// // Get the peer for the previous node +// IPeer previousPeer = previousNode.getPeer(); +// if (previousPeer != null) { +// // Get the IP address of the previous node +// String previousPeerIP = previousPeer.getAttributes().get(IPeer.ATTR_IP_HOST); +// if (IPAddressUtil.getInstance().isLocalHost(previousPeerIP) && !loopback.equals(previousPeerIP) && loopback.equals(peerIP)) { +// // Remove the previous node from the model +// getService(IPeerModelUpdateService.class).remove(previousNode); +// +// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { +// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: Previous peer removed and replaced by new peer representing the loopback address" //$NON-NLS-1$ +// , ITracing.ID_TRACE_LOCATOR_MODEL, this); +// } +// +// continue; +// } +// +// // Get the ports +// String peerPort = peer.getAttributes().get(IPeer.ATTR_IP_PORT); +// String previousPeerPort = previousPeer.getAttributes().get(IPeer.ATTR_IP_PORT); +// +// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { +// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: peerIP=" + peerIP //$NON-NLS-1$ +// + ", peerPort=" + peerPort + ", previousPeerPort=" + previousPeerPort //$NON-NLS-1$ //$NON-NLS-2$ +// , ITracing.ID_TRACE_LOCATOR_MODEL, this); +// } +// +// // If the ports of the agent instances are identical, +// // than try to find the best representation of the agent instance +// if (peerPort != null && peerPort.equals(previousPeerPort)) { +// // Drop the current node +// result = null; +// +// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { +// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: Previous peer node kept, new peer node dropped" //$NON-NLS-1$ +// , ITracing.ID_TRACE_LOCATOR_MODEL, this); +// } +// +// +// // Break the loop if the ports matched +// break; +// } +// +// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { +// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: Previous peer node kept, new peer node added (Port mismatch)" //$NON-NLS-1$ +// , ITracing.ID_TRACE_LOCATOR_MODEL, this); +// } +// } +// } +// } +// +// return result; } /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#postSetProperties(java.util.Map) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#validateChildPeerNodeForAdd(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) */ @Override - protected void postSetProperties(Map properties) { - Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(properties); - Assert.isNotNull(getPeer()); + public IPeerNode validateChildPeerNodeForAdd(final IPeerNode node) { + Assert.isNotNull(node); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.validateChildPeerNodeForAdd( " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ + } - // New properties applied. Update the element id - peerId = getPeer().getID(); - Assert.isNotNull(peerId); + // Determine the parent node. If null, the child node is invalid + // and cannot be added + final IPeerNode parent = node.getParent(IPeerNode.class); + if (parent == null) return null; - super.postSetProperties(properties); + return validateChildPeerNodeForAdd(parent, node); } - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#postSetProperty(java.lang.String, java.lang.Object, java.lang.Object) + /** + * Validates the given child peer model node in relation to the given parent peer model node + * hierarchy. + *

+ * The method is recursive. + * + * @param parent The parent model node. Must not be null. + * @param node The child model node. Must not be null. + * + * @return The validated child peer model node, or null. */ - @Override - public void postSetProperty(String key, Object value, Object oldValue) { - Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(key); - Assert.isNotNull(getPeer()); + protected IPeerNode validateChildPeerNodeForAdd(IPeerNode parent, IPeerNode node) { + Assert.isNotNull(parent); + Assert.isNotNull(node); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.validateChildPeerNodeForAdd( " + parent.getPeerId() + ", " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + // Validate against the given parent + if (doValidateChildPeerNodeForAdd(parent, node) == null) { + return null; + } - // If the peer instance changed, update the element id - if (IPeerModelProperties.PROP_INSTANCE.equals(key)) { - peerId = getPeer().getID(); - Assert.isNotNull(peerId); + // If the parent node is child node by itself, validate the + // child node against the parent parent node. + if (parent.getParent(IPeerNode.class) != null) { + IPeerNode parentParentNode = parent.getParent(IPeerNode.class); + if (doValidateChildPeerNodeForAdd(parentParentNode, node) == null) { + return null; + } + + // And validate the child node against all child nodes of the parent parent. + List childrenList = getChildren(parentParentNode.getPeerId()); + IPeerNode[] children = childrenList.toArray(new IPeerNode[childrenList.size()]); + for (IPeerNode parentParentChild : children) { + if (node.equals(parentParentChild) || parent.equals(parentParentChild)) { + return null; + } + if (doValidateChildPeerNodeForAdd(parentParentChild, node) == null) { + return null; + } + } } - super.postSetProperty(key, value, oldValue); + return node; } - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.model.ModelNode#isVisible() + /** + * Validates the given child peer model node in relation to the given parent peer model node. + *

+ * The method is non-recursive. + * + * @param parent The parent model node. Must not be null. + * @param node The child model node. Must not be null. + * + * @return The validated child peer model node, or null. */ - @Override - public boolean isVisible() { - IPeer peer = getPeer(); - return peer != null && peer.getAttributes().containsKey(IPeerModelProperties.PROP_VISIBLE) - ? Boolean.valueOf(peer.getAttributes().get(IPeerModelProperties.PROP_VISIBLE)).booleanValue() : true; + protected IPeerNode doValidateChildPeerNodeForAdd(IPeerNode parent, IPeerNode node) { + Assert.isNotNull(parent); + Assert.isNotNull(node); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) { + CoreBundleActivator.getTraceHandler().trace("PeerModel.doValidateChildPeerNodeForAdd( " + parent.getPeerId() + ", " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + // If the child node is already visible as root node, drop the child node + String id = node.getPeerId(); + if (isRootNode(id)) { + return null; + } + + int beginIndex = id.indexOf(':'); + int endIndex = id.lastIndexOf(':'); + String ip = beginIndex != -1 && endIndex != -1 ? id.substring(beginIndex+1, endIndex) : ""; //$NON-NLS-1$ + + // Get the loopback address + String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress(); + // Empty IP address means loopback + if ("".equals(ip)) ip = loopback; //$NON-NLS-1$ + + // If the IP is a localhost IP, try the loopback IP + if (IPAddressUtil.getInstance().isLocalHost(ip)) { + // Build up the new id to lookup + StringBuilder newId = new StringBuilder(); + newId.append(id.substring(0, beginIndex)); + newId.append(':'); + newId.append(loopback); + newId.append(':'); + newId.append(id.substring(endIndex + 1)); + + // Try the lookup again + if (isRootNode(newId.toString())) { + return null; + } + } + + // Get the peer from the peer node + IPeer peer = node.getPeer(); + + // If the child peer represents the same agent as the parent peer, + // drop the child peer + String parentAgentID = parent.getPeer().getAgentID(); + if (parentAgentID != null && parentAgentID.equals(peer.getAgentID())) { + return null; + } + // If the child peer represents the same agent as another child peer, + // drop the child peer + String agentID = node.getPeer().getAgentID(); + if (agentID != null) { + IPeerNode[] matches = getService(IPeerModelLookupService.class).lkupPeerModelByAgentId(parent.getPeerId(), agentID); + for (IPeerNode match : matches) { + if (agentID.equals(match.getPeer().getAgentID())) { + // Try to keep the peer with the real IP, filter the "127.0.0.1" peer + if ("127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$ + && !"127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$ + // Keep the other child node + return null; + } + + if (!"127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$ + && "127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$ + // Keep the node + getService(IPeerModelUpdateService.class).removeChild(match); + } + + // If both nodes have a IP different from "127.0.0.1", keep the first node + if (!"127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$ + && !"127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$ + // Keep the other child node + return null; + } + } + } + } + // If the child peer's IP address and port are the same as the parent's + // IP address and port, drop the child node + Map parentPeerAttributes = parent.getPeer().getAttributes(); + if (parentPeerAttributes.get(IPeer.ATTR_IP_HOST) != null && parentPeerAttributes.get(IPeer.ATTR_IP_HOST).equals(peer.getAttributes().get(IPeer.ATTR_IP_HOST))) { + String parentPort = parentPeerAttributes.get(IPeer.ATTR_IP_PORT); + String port = peer.getAttributes().get(IPeer.ATTR_IP_PORT); + + if (parentPort != null && parentPort.equals(port)) return null; + } + + return node; + } + + /** + * Checks if the given peer id belongs to an already known root node + * or to one of the discovered nodes. + * + * @param id The peer id. Must not be null. + * @return True if the given id belongs to a root node, false otherwise. + */ + private boolean isRootNode(String id) { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + Assert.isNotNull(id); + + boolean isRoot = false; + + if (getService(IPeerModelLookupService.class).lkupPeerModelById(id) != null) { + isRoot = true; + } else { + Map peers = Protocol.getLocator().getPeers(); + if (peers.containsKey(id)) { + isRoot = true; + } + } + + return isRoot; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java new file mode 100644 index 000000000..8888fa798 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java @@ -0,0 +1,405 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.nodes; + +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; +import org.eclipse.tcf.te.core.utils.ConnectStateHelper; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.model.ContainerModelNode; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService; +import org.eclipse.tcf.te.runtime.stepper.utils.StepperHelper; +import org.eclipse.tcf.te.runtime.utils.StatusHelper; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; + + +/** + * Default peer model implementation. + */ +public class PeerNode extends ContainerModelNode implements IPeerNode { + // Reference to the parent locator model + private final IPeerModel model; + // Reference to the peer id (cached for performance optimization) + private String peerId; + + /** + * Constructor. + * + * @param model The parent locator model. Must not be null. + * @param peer The peer. Must not be null. + */ + public PeerNode(IPeerModel model, IPeer peer) { + super(); + + Assert.isNotNull(model); + this.model = model; + + Assert.isNotNull(peer); + + // Set the default properties before enabling the change events. + // The properties changed listeners should not be called from the + // constructor. + setProperty(IPeerNodeProperties.PROP_INSTANCE, peer); + setProperty(IPeerNodeProperties.PROP_CONNECT_STATE, IConnectable.STATE_DISCONNECTED); + + // Initialize the peer id + peerId = peer.getID(); + Assert.isNotNull(peerId); + + // Peer model nodes can change the node parent at any time + allowSetParentOnNonNullParent = true; + // Peer model nodes does not have a parent by default + // -> allow change events with null parent + suppressEventsOnNullParent = false; + + // Enable change events + setChangeEventsEnabled(true); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#checkThreadAccess() + */ + @Override + protected final boolean checkThreadAccess() { + return Protocol.isDispatchThread(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode#getModel() + */ + @Override + public IPeerModel getModel() { + return (IPeerModel)getAdapter(IPeerModel.class); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode#getPeer() + */ + @Override + public IPeer getPeer() { + return (IPeer)getAdapter(IPeer.class); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode#getPeerId() + */ + @Override + public String getPeerId() { + return peerId; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.model.ModelNode#getName() + */ + @Override + public String getName() { + return getPeer().getName(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode#isComplete() + */ + @Override + public boolean isComplete() { + Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ + + boolean complete = true; + + // Determine the transport method + String transport = getPeer().getTransportName(); + // If the transport is not set, the peer attributes are incomplete + if (transport == null) { + complete = false; + } else { + // For TCP or SSL transport, ATTR_IP_HOST must not be null. + String ip = getPeer().getAttributes().get(IPeer.ATTR_IP_HOST); + String port = getPeer().getAttributes().get(IPeer.ATTR_IP_PORT); + if (("TCP".equals(transport) || "SSL".equals(transport)) && (ip == null || port == null)) { //$NON-NLS-1$ //$NON-NLS-2$ + complete = false; + } + + // Pipe and Loop transport does not require additional attributes + } + + return complete; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(final Class adapter) { + // NOTE: The getAdapter(...) method can be invoked from many place and + // many threads where we cannot control the calls. Therefore, this + // method is allowed be called from any thread. + final AtomicReference object = new AtomicReference(); + Runnable runnable = new Runnable() { + @Override + public void run() { + object.set(doGetAdapter(adapter)); + } + }; + + if (Protocol.isDispatchThread()) { + runnable.run(); + } + else { + Protocol.invokeAndWait(runnable); + } + + return object.get() != null ? object.get() : super.getAdapter(adapter); + } + + /** + * Returns an object which is an instance of the given class associated with this object. + * Returns null if no such object can be found. + *

+ * This method must be called within the TCF dispatch thread! + * + * @param adapter The adapter class to look up. + * @return The adapter or null. + */ + protected Object doGetAdapter(Class adapter) { + Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ + + if (IPeerModel.class.isAssignableFrom(adapter)) { + return model; + } + + Object peer = getProperty(IPeerNodeProperties.PROP_INSTANCE); + // Check with adapter.isAssignableFrom(...) to return the peer instance + // correctly if adapter is IPeer.class. + if (peer != null && adapter.isAssignableFrom(peer.getClass())) { + return peer; + } + + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#toString() + */ + @Override + public String toString() { + final StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); + + Runnable runnable = new Runnable() { + @Override + public void run() { + IPeer peer = getPeer(); + buffer.append(": id=" + peer.getID()); //$NON-NLS-1$ + buffer.append(", name=" + peer.getName()); //$NON-NLS-1$ + } + }; + + if (Protocol.isDispatchThread()) { + runnable.run(); + } + else { + Protocol.invokeAndWait(runnable); + } + + buffer.append(", " + super.toString()); //$NON-NLS-1$ + return buffer.toString(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof PeerNode) { + return getPeerId().equals(((PeerNode)obj).getPeerId()); + } + return super.equals(obj); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#hashCode() + */ + @Override + public int hashCode() { + return getPeerId().hashCode(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#postSetProperties(java.util.Map) + */ + @Override + protected void postSetProperties(Map properties) { + Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ + Assert.isNotNull(properties); + Assert.isNotNull(getPeer()); + + // New properties applied. Update the element id + peerId = getPeer().getID(); + Assert.isNotNull(peerId); + + super.postSetProperties(properties); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#postSetProperty(java.lang.String, java.lang.Object, java.lang.Object) + */ + @Override + public void postSetProperty(String key, Object value, Object oldValue) { + Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ + Assert.isNotNull(key); + Assert.isNotNull(getPeer()); + + // If the peer instance changed, update the element id + if (IPeerNodeProperties.PROP_INSTANCE.equals(key)) { + peerId = getPeer().getID(); + Assert.isNotNull(peerId); + } + + super.postSetProperty(key, value, oldValue); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.model.ModelNode#isVisible() + */ + @Override + public boolean isVisible() { + IPeer peer = getPeer(); + return peer != null && peer.getAttributes().containsKey(IPeerNodeProperties.PROP_VISIBLE) + ? Boolean.valueOf(peer.getAttributes().get(IPeerNodeProperties.PROP_VISIBLE)).booleanValue() : true; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.core.interfaces.IConnectable#getConnectState() + */ + @Override + public int getConnectState() { + final AtomicInteger state = new AtomicInteger(STATE_UNKNOWN); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + if (getProperty(IPeerNodeProperties.PROP_CONNECT_STATE) != null) { + state.set(getIntProperty(IPeerNodeProperties.PROP_CONNECT_STATE)); + } + } + }); + return state.get(); + } + + @Override + public boolean setConnectState(final int newState) { + final AtomicBoolean result = new AtomicBoolean(false); + if (isConnectStateChangeAllowed(newState)) { + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + result.set(setProperty(IPeerNodeProperties.PROP_CONNECT_STATE, newState)); + } + }); + } + return result.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.core.interfaces.IConnectable#changeConnectState(int, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void changeConnectState(final int action, ICallback callback, IProgressMonitor monitor) throws IllegalArgumentException { + final int oldState = getConnectState(); + if (!isConnectStateChangeActionAllowed(action)) { + IllegalArgumentException e = new IllegalArgumentException("Cannot change state from '" + ConnectStateHelper.getConnectState(oldState) + "' using action '" + ConnectStateHelper.getConnectState(action) + "'."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if (callback != null) { + callback.done(this, StatusHelper.getStatus(e)); + } + else { + throw e; + } + } + + String operation = null; + int intermediateState = 0; + + switch (action) { + case ACTION_CONNECT: + operation = IStepperServiceOperations.CONNECT; + intermediateState = STATE_CONNECT_SCHEDULED; + break; + case ACTION_DISCONNECT: + operation = IStepperServiceOperations.DISCONNECT; + intermediateState = STATE_DISCONNECT_SCHEDULED; + break; + } + + IStepperOperationService service = StepperHelper.getService(this, operation); + if (service != null) { + setConnectState(intermediateState); + StepperHelper.scheduleStepperJob(this, operation, service, callback, monitor); + } + else if (callback != null) { + callback.done(this, StatusHelper.getStatus(new NullPointerException("Missing stepper operation service for " + getName() + "."))); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + @Override + public boolean isConnectStateChangeActionAllowed(int action) { + int state = getConnectState(); + switch (state) { + case STATE_CONNECTED: + case STATE_CONNECT_SCHEDULED: + case STATE_CONNECTING: + return isAllowedState(action, ACTION_DISCONNECT); + case STATE_DISCONNECTED: + return isAllowedState(action, ACTION_CONNECT); + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.core.interfaces.IConnectable#isConnectStateChangeAllowed(int) + */ + @Override + public boolean isConnectStateChangeAllowed(int newState) { + int state = getConnectState(); + switch (state) { + case STATE_CONNECTED: + return isAllowedState(newState, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING); + case STATE_CONNECT_SCHEDULED: + return isAllowedState(newState, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING); + case STATE_CONNECTING: + return isAllowedState(newState, STATE_CONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING, STATE_DISCONNECTED); + case STATE_DISCONNECTED: + return isAllowedState(newState, STATE_CONNECTED, STATE_CONNECT_SCHEDULED, STATE_CONNECTING); + case STATE_DISCONNECT_SCHEDULED: + return isAllowedState(newState, STATE_DISCONNECTING, STATE_DISCONNECTED); + case STATE_DISCONNECTING: + return isAllowedState(newState, STATE_DISCONNECTED); + case STATE_UNKNOWN: + return isAllowedState(newState, STATE_DISCONNECTED); + } + return false; + } + + private boolean isAllowedState(int state, int... allowedStates) { + for (int allowedState : allowedStates) { + if (state == allowedState) { + return true; + } + } + return false; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java index ce3aad621..a274f8129 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java @@ -20,11 +20,11 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; import org.eclipse.tcf.te.runtime.persistence.delegates.GsonMapPersistenceDelegate; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; -import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode; /** * Peer to string persistence delegate implementation. @@ -75,8 +75,8 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate { if (context instanceof IPeer || IPeer.class.equals(context)) { return peer; } - else if (context instanceof Class && (((Class)context).isAssignableFrom(IPeerModel.class))) { - final AtomicReference model = new AtomicReference(); + else if (context instanceof Class && (((Class)context).isAssignableFrom(IPeerNode.class))) { + final AtomicReference model = new AtomicReference(); Runnable runnable = new Runnable() { @Override @@ -85,14 +85,14 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate { String id = peer.getID(); if (id != null) { // Lookup the id within the model - IPeerModel peerModel = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(id); - if (peerModel == null) { + IPeerNode peerNode = Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(id); + if (peerNode == null) { // Not found in the model -> create a ghost object - peerModel = new PeerModel(Model.getModel(), peer); - peerModel.setProperty(IModelNode.PROPERTY_IS_GHOST, true); + peerNode = new PeerNode(Model.getModel(), peer); + peerNode.setProperty(IModelNode.PROPERTY_IS_GHOST, true); } - model.set(peerModel); + model.set(peerNode); } } }; @@ -122,11 +122,11 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate { if (context instanceof IPeer) { peer = (IPeer)context; } - else if (context instanceof IPeerModel) { - peer = ((IPeerModel)context).getPeer(); + else if (context instanceof IPeerNode) { + peer = ((IPeerNode)context).getPeer(); } - else if (context instanceof IPeerModelProvider) { - peer = ((IPeerModelProvider)context).getPeerModel().getPeer(); + else if (context instanceof IPeerNodeProvider) { + peer = ((IPeerNodeProvider)context).getPeerModel().getPeer(); } return peer; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractLocatorModelService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractLocatorModelService.java deleted file mode 100644 index ea6df29b5..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractLocatorModelService.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.services; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelService; - - -/** - * Abstract locator model service base implementation. - */ -public abstract class AbstractLocatorModelService extends PlatformObject implements ILocatorModelService { - // Reference to the parent locator model - private final ILocatorModel locatorModel; - - /** - * Constructor. - * - * @param parentModel The parent locator model instance. Must not be null. - */ - public AbstractLocatorModelService(ILocatorModel parentModel) { - Assert.isNotNull(parentModel); - locatorModel = parentModel; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelService#getLocatorModel() - */ - @Override - public final ILocatorModel getLocatorModel() { - return locatorModel; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractPeerModelService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractPeerModelService.java new file mode 100644 index 000000000..5a3e37ea8 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractPeerModelService.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.services; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelService; + + +/** + * Abstract peer model service base implementation. + */ +public abstract class AbstractPeerModelService extends PlatformObject implements IPeerModelService { + // Reference to the parent locator model + private final IPeerModel peerModel; + + /** + * Constructor. + * + * @param parentModel The parent peer model instance. Must not be null. + */ + public AbstractPeerModelService(IPeerModel parentModel) { + Assert.isNotNull(parentModel); + peerModel = parentModel; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelService#getPeerModel() + */ + @Override + public final IPeerModel getPeerModel() { + return peerModel; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java index acffb7f09..9b7c3259f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java @@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.services.AbstractService; import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Abstract simulator service implementation. @@ -27,12 +27,12 @@ public abstract class AbstractSimulatorService extends AbstractService implement */ @Override public boolean isValidContext(final Object context, String config) { - if (context instanceof IPeerModel) { + if (context instanceof IPeerNode) { final AtomicBoolean complete = new AtomicBoolean(false); Runnable runnable = new Runnable() { @Override public void run() { - complete.set(((IPeerModel)context).isComplete()); + complete.set(((IPeerNode)context).isComplete()); } }; Protocol.invokeAndWait(runnable); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java deleted file mode 100644 index d8fb46c8f..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java +++ /dev/null @@ -1,250 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.services; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; - - -/** - * Default locator model lookup service implementation. - */ -public class LocatorModelLookupService extends AbstractLocatorModelService implements ILocatorModelLookupService { - - /** - * Constructor. - * - * @param parentModel The parent locator model instance. Must not be null. - */ - public LocatorModelLookupService(ILocatorModel parentModel) { - super(parentModel); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelLookupService#lkupPeerModelById(java.lang.String) - */ - @Override - public IPeerModel lkupPeerModelById(String id) { - Assert.isNotNull(id); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - IPeerModel node = null; - for (IPeerModel candidate : getLocatorModel().getPeers()) { - IPeer peer = candidate.getPeer(); - if (id.equals(peer.getID())) { - node = candidate; - break; - } else if (peer.getAttributes().get("remote.id.transient") != null //$NON-NLS-1$ - && peer.getAttributes().get("remote.id.transient").equals(id)) { //$NON-NLS-1$ - node = candidate; - break; - } - } - - return node; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelById(java.lang.String, java.lang.String) - */ - @Override - public IPeerModel lkupPeerModelById(String parentId, String id) { - Assert.isNotNull(parentId); - Assert.isNotNull(id); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - IPeerModel node = null; - for (IPeerModel candidate : getLocatorModel().getChildren(parentId)) { - IPeer peer = candidate.getPeer(); - if (id.equals(peer.getID())) { - node = candidate; - break; - } else if (peer.getAttributes().get("remote.id.transient") != null //$NON-NLS-1$ - && peer.getAttributes().get("remote.id.transient").equals(id)) { //$NON-NLS-1$ - node = candidate; - break; - } - } - - return node; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelByAgentId(java.lang.String) - */ - @Override - public IPeerModel[] lkupPeerModelByAgentId(String agentId) { - Assert.isNotNull(agentId); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - List nodes = new ArrayList(); - for (IPeerModel candidate : getLocatorModel().getPeers()) { - IPeer peer = candidate.getPeer(); - if (agentId.equals(peer.getAgentID())) { - nodes.add(candidate); - } - } - - return nodes.toArray(new IPeerModel[nodes.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelByAgentId(java.lang.String, java.lang.String) - */ - @Override - public IPeerModel[] lkupPeerModelByAgentId(String parentId, String agentId) { - Assert.isNotNull(parentId); - Assert.isNotNull(agentId); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - List nodes = new ArrayList(); - for (IPeerModel candidate : getLocatorModel().getChildren(parentId)) { - IPeer peer = candidate.getPeer(); - if (agentId.equals(peer.getAgentID())) { - nodes.add(candidate); - } - } - - return nodes.toArray(new IPeerModel[nodes.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelByName(java.lang.String) - */ - @Override - public IPeerModel[] lkupPeerModelByName(String name) { - Assert.isNotNull(name); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - List nodes = new ArrayList(); - for (IPeerModel candidate : getLocatorModel().getPeers()) { - IPeer peer = candidate.getPeer(); - if (name.equals(peer.getName())) { - nodes.add(candidate); - } - } - - return nodes.toArray(new IPeerModel[nodes.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelBySupportedServices(java.lang.String[], java.lang.String[]) - */ - @Override - public IPeerModel[] lkupPeerModelBySupportedServices(String[] expectedLocalServices, String[] expectedRemoteServices) { - Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - ILocatorModel model = getLocatorModel(); - ILocatorModelPeerNodeQueryService queryService = model.getService(ILocatorModelPeerNodeQueryService.class); - - List nodes = new ArrayList(); - for (IPeerModel candidate : model.getPeers()) { - String services = queryService.queryLocalServices(candidate); - - boolean matchesExpectations = true; - - // Ignore the local services if no expectations are set - if (expectedLocalServices != null && expectedLocalServices.length > 0) { - if (services != null) { - for (String service : expectedLocalServices) { - if (!services.contains(service)) { - matchesExpectations = false; - break; - } - } - } else { - matchesExpectations = false; - } - } - - if (!matchesExpectations) continue; - - services = queryService.queryRemoteServices(candidate); - - // Ignore the remote services if no expectations are set - if (expectedRemoteServices != null && expectedRemoteServices.length > 0) { - if (services != null) { - for (String service : expectedRemoteServices) { - if (!services.contains(service)) { - matchesExpectations = false; - break; - } - } - } else { - matchesExpectations = false; - } - } - - if (matchesExpectations) nodes.add(candidate); - } - - return nodes.toArray(new IPeerModel[nodes.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupMatchingStaticPeerModels(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) - */ - @Override - public IPeerModel[] lkupMatchingStaticPeerModels(IPeerModel peerNode) { - Assert.isNotNull(peerNode); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - return lkupMatchingStaticPeerModels(peerNode.getPeer()); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupMatchingStaticPeerModels(org.eclipse.tcf.protocol.IPeer) - */ - @Override - public IPeerModel[] lkupMatchingStaticPeerModels(IPeer peer) { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - List nodes = new ArrayList(); - - if (peer != null) { - for (IPeerModel candidate : getLocatorModel().getPeers()) { - // Look only at the static peers here - if (!candidate.isStatic()) continue; - - // If the agent id is available, match up the agent id first. - if (candidate.getPeer().getAgentID() != null && candidate.getPeer().getAgentID().equals(peer.getAgentID())) { - nodes.add(candidate); - continue; - } - - // Get the transport types. Transport type must match and must be either "TCP" or "SSL". - String t1 = peer.getTransportName(); - String t2 = candidate.getPeer().getTransportName(); - - if (t1 != null && t1.equals(t2) && ("TCP".equals(t1) || "SSL".equals(t1))) { //$NON-NLS-1$ //$NON-NLS-2$ - // Compare IP and Port. If they match, add the candidate to the result list - String i1 = peer.getAttributes().get(IPeer.ATTR_IP_HOST); - String i2 = candidate.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST); - if (i1 != null && i1.equals(i2)) { - String p1 = peer.getAttributes().get(IPeer.ATTR_IP_PORT); - String p2 = candidate.getPeer().getAttributes().get(IPeer.ATTR_IP_PORT); - if (p1 != null && p1.equals(p2)) { - nodes.add(candidate); - } - } - } - } - } - - return nodes.toArray(new IPeerModel[nodes.size()]); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java deleted file mode 100644 index 356f3536a..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.services; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.tcf.protocol.IChannel; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.runtime.interfaces.IConditionTester; -import org.eclipse.tcf.te.tcf.core.Tcf; -import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; - -/** - * Default locator model peer node query service implementation. - */ -public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelService implements ILocatorModelPeerNodeQueryService { - - /** - * Constructor. - * - * @param parentModel The parent locator model instance. Must not be null. - */ - public LocatorModelPeerNodeQueryService(ILocatorModel parentModel) { - super(parentModel); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService#queryLocalServices(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) - */ - @Override - public String queryLocalServices(final IPeerModel node) { - Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(node); - - // Check if the services has been cached before - final AtomicReference services = new AtomicReference(); - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - services.set(node.getStringProperty(IPeerModelProperties.PROP_LOCAL_SERVICES)); - } - }); - - if (services.get() != null && !"".equals(services.get())) { //$NON-NLS-1$ - // Services are cached -> return immediately - return services.get(); - } - - // Get the service asynchronously and block the caller thread until - // the callback returned - final AtomicBoolean completed = new AtomicBoolean(false); - Protocol.invokeLater(new Runnable() { - @Override - public void run() { - queryServicesAsync(node, new DoneQueryServices() { - @Override - public void doneQueryServices(Throwable error) { - if (error == null) { - services.set(node.getStringProperty(IPeerModelProperties.PROP_LOCAL_SERVICES)); - } - completed.set(true); - } - }); - } - }); - - final long startTime = System.currentTimeMillis(); - final IConditionTester tester = new IConditionTester() { - @Override - public boolean isConditionFulfilled() { - return completed.get(); - } - - @Override - public void cleanup() {} - }; - - while ((startTime + 1000) < System.currentTimeMillis() && !tester.isConditionFulfilled()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { /* ignored on purpose */ } - } - - return services.get(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService#queryRemoteServices(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) - */ - @Override - public String queryRemoteServices(final IPeerModel node) { - Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(node); - - // Check if the services has been cached before - final AtomicReference services = new AtomicReference(); - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - services.set(node.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES)); - } - }); - - if (services.get() != null && !"".equals(services.get())) { //$NON-NLS-1$ - // Services are cached -> return immediately - return services.get(); - } - - // Get the service asynchronously and block the caller thread until - // the callback returned - final AtomicBoolean completed = new AtomicBoolean(false); - Protocol.invokeLater(new Runnable() { - @Override - public void run() { - queryServicesAsync(node, new DoneQueryServices() { - @Override - public void doneQueryServices(Throwable error) { - if (error == null) { - services.set(node.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES)); - } - completed.set(true); - } - }); - } - }); - - final long startTime = System.currentTimeMillis(); - final IConditionTester tester = new IConditionTester() { - @Override - public boolean isConditionFulfilled() { - return completed.get(); - } - - @Override - public void cleanup() {} - }; - - while ((startTime + 1000) < System.currentTimeMillis() && !tester.isConditionFulfilled()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { /* ignored on purpose */ } - } - - return services.get(); - } - - /* default */ final Map> serviceQueriesInProgress = new HashMap>(); - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService#queryServicesAsync(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService.DoneQueryServices) - */ - @Override - public void queryServicesAsync(final IPeerModel node, final DoneQueryServices done) { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(node); - Assert.isNotNull(done); - - // If a service query for the same peer is already in progress, - // attach the new done to the list to call and drop out - if (serviceQueriesInProgress.containsKey(node)) { - List dones = serviceQueriesInProgress.get(node); - Assert.isNotNull(dones); - dones.add(done); - return; - } - - // Add the done callback to a list of waiting callbacks per peer node - List dones = new ArrayList(); - dones.add(done); - serviceQueriesInProgress.put(node, dones); - - // Create the inner callback that invokes the queued outer callbacks - final DoneQueryServices innerDone = new DoneQueryServices() { - - @Override - public void doneQueryServices(Throwable error) { - // Get the list of the original done callbacks - List dones = serviceQueriesInProgress.remove(node); - if (dones != null) { - for (DoneQueryServices done : dones) { - done.doneQueryServices(error); - } - } - } - }; - - // Do not try to open a channel to peers known to be unreachable - int state = node.getIntProperty(IPeerModelProperties.PROP_STATE); - if (state == IPeerModelProperties.STATE_ERROR || state == IPeerModelProperties.STATE_NOT_REACHABLE || !node.isComplete()) { - innerDone.doneQueryServices(null); - return; - } - - // Opens a channel with the full value-add chain - Map flags = new HashMap(); - flags.put(IChannelManager.FLAG_NO_PATH_MAP, Boolean.TRUE); - Tcf.getChannelManager().openChannel(node.getPeer(), flags, new IChannelManager.DoneOpenChannel() { - - @Override - public void doneOpenChannel(Throwable error, IChannel channel) { - // If the channel opening failed -> return immediately - if (error != null) { - innerDone.doneQueryServices(error); - } else { - // Get the local service - List localServices = new ArrayList(channel.getLocalServices()); - // Get the remote services - List remoteServices = new ArrayList(channel.getRemoteServices()); - - // Close the channel - Tcf.getChannelManager().closeChannel(channel); - - // Sort the service lists - Collections.sort(localServices); - Collections.sort(remoteServices); - - // Update the services - ILocatorModelUpdateService updateService = node.getModel().getService(ILocatorModelUpdateService.class); - updateService.updatePeerServices(node, localServices, remoteServices); - - // Invoke the callback - innerDone.doneQueryServices(null); - } - } - }); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java deleted file mode 100644 index 2894548ce..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java +++ /dev/null @@ -1,620 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.services; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.tcf.protocol.IChannel; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.IToken; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.services.ILocator; -import org.eclipse.tcf.te.runtime.callback.AsyncCallbackCollector; -import org.eclipse.tcf.te.runtime.callback.Callback; -import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; -import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties; -import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; -import org.eclipse.tcf.te.runtime.services.ServiceManager; -import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil; -import org.eclipse.tcf.te.tcf.core.Tcf; -import org.eclipse.tcf.te.tcf.core.async.CallbackInvocationDelegate; -import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; -import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.ScannerRunnable; -import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.preferences.IPreferenceKeys; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; -import org.eclipse.tcf.te.tcf.locator.model.ModelLocationUtil; -import org.eclipse.tcf.te.tcf.locator.nodes.ConnectablePeerModel; -import org.eclipse.tcf.te.tcf.locator.nodes.LocatorModel; -import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel; -import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; - - -/** - * Default locator model refresh service implementation. - */ -public class LocatorModelRefreshService extends AbstractLocatorModelService implements ILocatorModelRefreshService { - - /** - * Constructor. - * - * @param parentModel The parent locator model instance. Must not be null. - */ - public LocatorModelRefreshService(ILocatorModel parentModel) { - super(parentModel); - } - - /** - * Asynchronously invoke the callback within the TCF dispatch thread. - * - * @param callback The callback to invoke or null. - */ - protected final void invokeCallback(final ICallback callback) { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - if (callback != null) { - Protocol.invokeLater(new Runnable() { - @Override - public void run() { - callback.done(LocatorModelRefreshService.this, Status.OK_STATUS); - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService#refresh(org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) - */ - @Override - public void refresh(final ICallback callback) { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // Get the parent locator model - ILocatorModel model = getLocatorModel(); - - // If the parent model is already disposed, the service will drop out immediately - if (model.isDisposed()) { - invokeCallback(callback); - return; - } - - // If the TCF framework isn't initialized yet, the service will drop out immediately - if (!Tcf.isRunning()) { - invokeCallback(callback); - return; - } - - // Get the list of old children (update node instances where possible) - final List oldChildren = new ArrayList(Arrays.asList(model.getPeers())); - - // Refresh the static peer definitions - refreshStaticPeers(oldChildren, model); - - // Get the locator service - ILocator locatorService = Protocol.getLocator(); - if (locatorService != null) { - // Check for the locator listener to be created and registered - if (model instanceof LocatorModel) { - ((LocatorModel)model).checkLocatorListener(); - } - // Get the map of peers known to the locator service. - Map peers = locatorService.getPeers(); - // Process the peers - processPeers(peers, oldChildren, model); - } - - // If there are remaining old children, remove them from the model (non-recursive) - for (IPeerModel oldChild : oldChildren) { - model.getService(ILocatorModelUpdateService.class).remove(oldChild); - } - - // Invoke the callback - invokeCallback(callback); - } - - /** - * Process the given map of peers and update the given locator model. - * - * @param peers The map of peers to process. Must not be null. - * @param oldChildren The list of old children. Must not be null. - * @param model The locator model. Must not be null. - */ - protected void processPeers(Map peers, List oldChildren, ILocatorModel model) { - Assert.isNotNull(peers); - Assert.isNotNull(oldChildren); - Assert.isNotNull(model); - - for (Entry entry : peers.entrySet()) { - // Get the peer instance for the current peer id - IPeer peer = entry.getValue(); - // Try to find an existing peer node first - IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(entry.getKey()); - // And create a new one if we cannot find it - if (peerNode == null) { - String value = peer.getAttributes().get("static.transient"); //$NON-NLS-1$ - if (value != null && Boolean.parseBoolean(value.trim())) { - peerNode = new ConnectablePeerModel(model, peer); - } - else { - peerNode = new PeerModel(model, peer); - } - } - else { - oldChildren.remove(peerNode); - } - - if (peerNode.getPeer() != peer) { - if (!peerNode.isStatic()) { - peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer); - } else { - String value = peerNode.getPeer().getAttributes().get(IPersistableNodeProperties.PROPERTY_URI); - URI uri = value != null ? URI.create(value) : null; - File file = uri != null && "file".equals(uri.getScheme()) ? new File(uri.normalize()) : null; //$NON-NLS-1$ - if (file != null && !file.exists()) { - peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer); - } else { - // Merge user configured properties between the peers - model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, peer, false); - } - } - } - - // Validate the peer node before adding - peerNode = model.validatePeerNodeForAdd(peerNode); - if (peerNode != null) { - // There is still the chance that the node we add is a static node and - // there exist an dynamically discovered node with a different id but - // for the same peer. Do this check only if the peer to add is a static one. - if (peerNode.isStatic()) { - IPeerModel toRemove = null; - for (IPeerModel candidate : model.getPeers()) { - if (candidate.isStatic() || candidate.equals(peerNode))continue; - String peerID = peerNode.getPeerId(); - String clientID = candidate.getPeer().getAttributes().get("ClientID"); //$NON-NLS-1$ - if (clientID != null && clientID.equals(peerID)) { - // Merge user configured properties between the peers - model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(candidate, peerNode.getPeer(), true); - peerNode = null; - break; - } - - if (peerNode.getPeer().getTransportName() != null && peerNode.getPeer().getTransportName().equals(candidate.getPeer().getTransportName())) { - // Same transport name - if ("PIPE".equals(candidate.getPeer().getTransportName())) { //$NON-NLS-1$ - // Compare the pipe name - String name1 = peerNode.getPeer().getAttributes().get("PipeName"); //$NON-NLS-1$ - String name2 = candidate.getPeer().getAttributes().get("PipeName"); //$NON-NLS-1$ - // Same pipe -> same node - if (name1 != null && name1.equals(name2)) { - // Merge user configured properties between the peers - model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true); - toRemove = candidate; - break; - } - } else if ("Loop".equals(candidate.getPeer().getTransportName())) { //$NON-NLS-1$ - // Merge user configured properties between the peers - model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true); - toRemove = candidate; - break; - } else { - // Compare IP_HOST and IP_Port; - String ip1 = peerNode.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST); - String ip2 = candidate.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST); - if (IPAddressUtil.getInstance().isSameHost(ip1, ip2)) { - // Compare the ports - String port1 = peerNode.getPeer().getAttributes().get(IPeer.ATTR_IP_PORT); - String port2 = candidate.getPeer().getAttributes().get(IPeer.ATTR_IP_PORT); - - if (port1 != null && port1.equals(port2)) { - // Merge user configured properties between the peers - model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true); - toRemove = candidate; - break; - } - } - } - } - } - - if (toRemove != null) { - model.getService(ILocatorModelUpdateService.class).remove(toRemove); - toRemove = null; - } - } - - if (peerNode != null) { - // Add the peer node to model - model.getService(ILocatorModelUpdateService.class).add(peerNode); - // And schedule for immediate status update - Runnable runnable = new ScannerRunnable(model.getScanner(), peerNode); - Protocol.invokeLater(runnable); - } - } - } - } - - private final AtomicBoolean REFRESH_STATIC_PEERS_GUARD = new AtomicBoolean(false); - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService#refreshStaticPeers() - */ - @Override - public void refreshStaticPeers() { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // This method might be called reentrant while processing. Return immediately - // in this case. - if (REFRESH_STATIC_PEERS_GUARD.get()) { - return; - } - REFRESH_STATIC_PEERS_GUARD.set(true); - - // Get the parent locator model - ILocatorModel model = getLocatorModel(); - - // If the parent model is already disposed, the service will drop out immediately - if (model.isDisposed()) { - return; - } - - // Get the list of old children (update node instances where possible) - final List oldChildren = new ArrayList(Arrays.asList(model.getPeers())); - - // Refresh the static peer definitions - refreshStaticPeers(oldChildren, model); - - REFRESH_STATIC_PEERS_GUARD.set(false); - } - - /** - * Refresh the static peer definitions. - * - * @param oldChildren The list of old children. Must not be null. - * @param model The locator model. Must not be null. - */ - protected void refreshStaticPeers(List oldChildren, ILocatorModel model) { - Assert.isNotNull(oldChildren); - Assert.isNotNull(model); - - // Get the root locations to lookup the static peer definitions - File[] roots = getStaticPeerLookupDirectories(); - if (roots.length > 0) { - // The map of peers created from the static definitions - Map peers = new HashMap(); - // The list of peer attributes with postponed peer instance creation - List> postponed = new ArrayList>(); - // Process the root locations - for (File root : roots) { - // List all "*.json" and "*.peer" files within the root location - File[] candidates = root.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - IPath path = new Path(pathname.getAbsolutePath()); - return path.getFileExtension() != null && - (path.getFileExtension().toLowerCase().equals("json") || path.getFileExtension().toLowerCase().equals("peer")); //$NON-NLS-1$ //$NON-NLS-2$ - } - }); - // If there are ini files to read, process them - if (candidates != null && candidates.length > 0) { - - for (File candidate : candidates) { - try { - IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class); - IPeer tempPeer = (IPeer)service.read(IPeer.class, candidate.getAbsoluteFile().toURI()); - - Map attrs = new HashMap(tempPeer.getAttributes()); - - // Remember the file path within the properties - attrs.put(IPersistableNodeProperties.PROPERTY_URI, candidate.getAbsoluteFile().toURI().toString()); - // Mark the node as static peer model node - attrs.put("static.transient", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - - // Validate the name attribute. If not set, set - // it to the file name without the .ini extension. - String name = attrs.get(IPeer.ATTR_NAME); - if (name == null || "".equals(name.trim())) { //$NON-NLS-1$ - name = new Path(candidate.getAbsolutePath()).removeFileExtension().lastSegment(); - attrs.put(IPeer.ATTR_NAME, name); - } - - // Validate the id attribute. If not set, generate one. - String id = attrs.get(IPeer.ATTR_ID); - if (id == null || "".equals(id.trim()) || "USR:".equals(id.trim())) { //$NON-NLS-1$ //$NON-NLS-2$ - String transport = attrs.get(IPeer.ATTR_TRANSPORT_NAME); - String host = attrs.get(IPeer.ATTR_IP_HOST); - String port = attrs.get(IPeer.ATTR_IP_PORT); - - if (transport != null && host != null && !(id != null && "USR:".equals(id.trim()))) { //$NON-NLS-1$ - id = transport.trim() + ":" + host.trim(); //$NON-NLS-1$ - id += port != null ? ":" + port.trim() : ":1534"; //$NON-NLS-1$ //$NON-NLS-2$ - } else { - id = "USR:" + System.currentTimeMillis(); //$NON-NLS-1$ - // If the key is not unique, we have to wait a little bit an try again - while (peers.containsKey(id)) { - try { Thread.sleep(20); } catch (InterruptedException e) { /* ignored on purpose */ } - id = "USR:" + System.currentTimeMillis(); //$NON-NLS-1$ - } - } - attrs.put(IPeer.ATTR_ID, id); - } - - // If the redirect property is not set, create the peer right away - if (attrs.get(IPeerModelProperties.PROP_REDIRECT_PROXY) == null) { - // Construct the peer from the attributes - IPeer peer = new Peer(attrs); - // Add the constructed peer to the peers map - peers.put(peer.getID(), peer); - } else { - // Try to get the peer proxy - String proxyId = attrs.get(IPeerModelProperties.PROP_REDIRECT_PROXY); - IPeer proxy = peers.get(proxyId); - if (proxy == null) { - IPeerModel peerModel = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(proxyId); - if (peerModel != null) { - proxy = peerModel.getPeer(); - } - } - - if (proxy != null) { - // Construct the peer redirector - PeerRedirector redirector = new PeerRedirector(proxy, attrs); - // Add the redirector to the peers map - peers.put(redirector.getID(), redirector); - } else { - // Postpone peer creation - postponed.add(attrs); - } - } - } catch (IOException e) { - /* ignored on purpose */ - } - } - } - } - - // Process postponed peers if there are any - if (!postponed.isEmpty()) { - for (Map attrs : postponed) { - String proxyId = attrs.get(IPeerModelProperties.PROP_REDIRECT_PROXY); - IPeer proxy = proxyId != null ? peers.get(proxyId) : null; - if (proxy == null) { - IPeerModel peerModel = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(proxyId); - if (peerModel != null) { - proxy = peerModel.getPeer(); - } - } - - if (proxy != null) { - // Construct the peer redirector - PeerRedirector redirector = new PeerRedirector(proxy, attrs); - // Add the redirector to the peers map - peers.put(redirector.getID(), redirector); - } else { - // Proxy not available -> reset redirection - attrs.remove(IPeerModelProperties.PROP_REDIRECT_PROXY); - // Construct the peer from the attributes - IPeer peer = new Peer(attrs); - // Add the constructed peer to the peers map - peers.put(peer.getID(), peer); - } - } - } - - // Process the read peers - if (!peers.isEmpty()) { - processPeers(peers, oldChildren, model); - } - - // Scan the peers for redirected ones ... and set up the peer model association - for (Entry entry : peers.entrySet()) { - IPeer peer = entry.getValue(); - if (!(peer instanceof PeerRedirector)) { - continue; - } - - // Get the peers peer model object - IPeerModel peerModel = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(entry.getKey()); - Assert.isNotNull(peerModel); - - // The peer is a peer redirector -> get the proxy peer id and proxy peer model - String proxyPeerId = ((PeerRedirector)peer).getParent().getID(); - IPeerModel proxy = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(proxyPeerId); - Assert.isNotNull(proxy); - - peerModel.setParent(proxy); - model.getService(ILocatorModelUpdateService.class).addChild(peerModel); - } - } - } - - /** - * Returns the list of root locations to lookup for static peers definitions. - * - * @return The list of root locations or an empty list. - */ - protected File[] getStaticPeerLookupDirectories() { - // The list defining the root locations - List rootLocations = new ArrayList(); - - // Check on the peers root locations preference setting - String roots = CoreBundleActivator.getScopedPreferences().getString(IPreferenceKeys.PREF_STATIC_PEERS_ROOT_LOCATIONS); - // If set, split it in its single components - if (roots != null) { - String[] candidates = roots.split(File.pathSeparator); - // Check on each candidate to denote an existing directory - for (String candidate : candidates) { - File file = new File(candidate); - if (file.canRead() && file.isDirectory() && !rootLocations.contains(file)) { - rootLocations.add(file); - } - } - } - - // always add default root location - IPath defaultPath = ModelLocationUtil.getStaticPeersRootLocation(); - if (defaultPath != null) { - File file = defaultPath.toFile(); - if (file.canRead() && file.isDirectory() && !rootLocations.contains(file)) { - rootLocations.add(file); - } - } - - return rootLocations.toArray(new File[rootLocations.size()]); - } - - /* default */ final List refreshAgentIDCallbacks = new ArrayList(); - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService#refreshAgentIDs(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel[], org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) - */ - @Override - public void refreshAgentIDs(IPeerModel[] nodes, final ICallback callback) { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // This method might be called reentrant while processing. Add - // the callback to the "wait" list and return immediately. - if (refreshAgentIDCallbacks.size() > 0) { - refreshAgentIDCallbacks.add(callback); - return; - } - refreshAgentIDCallbacks.add(callback); - - // Get the parent locator model - ILocatorModel model = getLocatorModel(); - - // If the parent model is already disposed, the service will drop out immediately - if (model.isDisposed()) { - return; - } - - // The callback collector will fire once all static peers have been refreshed - final AsyncCallbackCollector collector = new AsyncCallbackCollector(new Callback() { - @Override - protected void internalDone(Object caller, IStatus status) { - // Make a copy of the callbacks to invoke - List callbacks = new ArrayList(refreshAgentIDCallbacks); - refreshAgentIDCallbacks.clear(); - // And invoke the final callbacks - for (ICallback callback : callbacks) { - invokeCallback(callback); - } - } - }, new CallbackInvocationDelegate()); - - // Make a copy of the current list of static peers before processing - List nodesToProcess = new ArrayList(Arrays.asList(nodes != null ? nodes : model.getPeers())); - // Loop the list of static peers and try to get the agent ID - for (IPeerModel node : nodesToProcess) { - // If not static or not complete --> ignore - if (!node.isStatic() || !node.isComplete()) continue; - // Refresh the agent ID - refreshAgentID(node, new AsyncCallbackCollector.SimpleCollectorCallback(collector)); - } - - // Mark the collector initialization as done - collector.initDone(); - } - - /** - * Refreshes the agent ID of the given static peer node, if reachable. - * - * @param node The peer model node. Must not be null. - * @param callback The callback. Must not be null. - */ - protected void refreshAgentID(final IPeerModel node, final ICallback callback) { - Assert.isNotNull(node); - Assert.isNotNull(callback); - - // If the peer is not static or associated with an remote peer - // --> skip the node - if (!node.isStatic() || node.isRemote()) { - callback.done(LocatorModelRefreshService.this, Status.OK_STATUS); - return; - } - - Assert.isTrue(node.getPeer() instanceof Peer); - - // Try to open a channel to the node - Map flags = new HashMap(); - flags.put(IChannelManager.FLAG_FORCE_NEW, Boolean.TRUE); - flags.put(IChannelManager.FLAG_NO_VALUE_ADD, Boolean.TRUE); - - Tcf.getChannelManager().openChannel(node.getPeer(), flags, new IChannelManager.DoneOpenChannel() { - - @Override - public void doneOpenChannel(Throwable error, final IChannel channel) { - if (channel != null && channel.getState() == IChannel.STATE_OPEN) { - // Get the locator service - ILocator service = channel.getRemoteService(ILocator.class); - if (service != null) { - // Query the agent ID - service.getAgentID(new ILocator.DoneGetAgentID() { - @Override - public void doneGetAgentID(IToken token, Exception error, String agentID) { - // Close the channel - Tcf.getChannelManager().closeChannel(channel); - - // Update the peer - if (agentID == null || "".equals(agentID)) { //$NON-NLS-1$ - if (node.getPeer().getAgentID() != null) { - // Remove the old agent ID - Map attrs = new HashMap(channel.getRemotePeer().getAttributes()); - attrs.remove(IPeer.ATTR_AGENT_ID); - node.setProperty(IPeerModelProperties.PROP_INSTANCE, new Peer(attrs)); - } - } else if (node.getPeer().getAgentID() == null || !agentID.equals(node.getPeer().getAgentID())){ - // Set the new agent ID - Map attrs = new HashMap(channel.getRemotePeer().getAttributes()); - attrs.put(IPeer.ATTR_AGENT_ID, agentID); - node.setProperty(IPeerModelProperties.PROP_INSTANCE, new Peer(attrs)); - } - - // Invoke the callback - callback.done(LocatorModelRefreshService.this, Status.OK_STATUS); - } - }); - } else { - // Close the channel - Tcf.getChannelManager().closeChannel(channel); - // Invoke the callback - callback.done(LocatorModelRefreshService.this, Status.OK_STATUS); - } - } else { - // Close the channel in any case - if (channel != null) Tcf.getChannelManager().closeChannel(channel); - // Invoke the callback - callback.done(LocatorModelRefreshService.this, Status.OK_STATUS); - } - - } - }); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelUpdateService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelUpdateService.java deleted file mode 100644 index f55587249..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelUpdateService.java +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.services; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties; -import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; -import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; - - -/** - * Default locator model update service implementation. - */ -public class LocatorModelUpdateService extends AbstractLocatorModelService implements ILocatorModelUpdateService { - - /** - * Constructor. - * - * @param parentModel The parent locator model instance. Must not be null. - */ - public LocatorModelUpdateService(ILocatorModel parentModel) { - super(parentModel); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#add(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel) - */ - @Override - public void add(final IPeerModel peer) { - Assert.isNotNull(peer); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - Map peers = (Map)getLocatorModel().getAdapter(Map.class); - Assert.isNotNull(peers); - peers.put(peer.getPeerId(), peer); - - final IModelListener[] listeners = getLocatorModel().getListener(); - if (listeners.length > 0) { - Protocol.invokeLater(new Runnable() { - @Override - public void run() { - for (IModelListener listener : listeners) { - listener.locatorModelChanged(getLocatorModel(), peer, true); - } - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#remove(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel) - */ - @Override - public void remove(final IPeerModel peer) { - Assert.isNotNull(peer); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - Map peers = (Map)getLocatorModel().getAdapter(Map.class); - Assert.isNotNull(peers); - peers.remove(peer.getPeerId()); - - getLocatorModel().setChildren(peer.getPeerId(), null); - - final IModelListener[] listeners = getLocatorModel().getListener(); - if (listeners.length > 0) { - Protocol.invokeLater(new Runnable() { - @Override - public void run() { - for (IModelListener listener : listeners) { - listener.locatorModelChanged(getLocatorModel(), peer, false); - } - } - }); - } - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#updatePeerServices(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel, java.util.Collection, java.util.Collection) - */ - @Override - public void updatePeerServices(IPeerModel peerNode, Collection localServices, Collection remoteServices) { - Assert.isNotNull(peerNode); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - peerNode.setProperty(IPeerModelProperties.PROP_LOCAL_SERVICES, localServices != null ? makeString(localServices) : null); - peerNode.setProperty(IPeerModelProperties.PROP_REMOTE_SERVICES, remoteServices != null ? makeString(remoteServices) : null); - } - - /** - * Transform the given collection into a plain string. - * - * @param collection The collection. Must not be null. - * @return The plain string. - */ - protected String makeString(Collection collection) { - Assert.isNotNull(collection); - - if (collection.isEmpty()) return null; - - String buffer = collection.toString(); - buffer = buffer.replaceAll("\\[", "").replaceAll("\\]", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - - return buffer.trim(); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService#addChild(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) - */ - @Override - public void addChild(final IPeerModel child) { - Assert.isNotNull(child); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // Determine the parent node - final IPeerModel parent = child.getParent(IPeerModel.class); - if (parent == null) return; - - // Determine the peer id of the parent - String parentPeerId = parent.getPeerId(); - Assert.isNotNull(parentPeerId); - - // Get the list of existing children - List children = new ArrayList(getLocatorModel().getChildren(parentPeerId)); - if (!children.contains(child)) { - children.add(child); - getLocatorModel().setChildren(parentPeerId, children); - } - - // Notify listeners - parent.fireChangeEvent("changed", null, children); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService#removeChild(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) - */ - @Override - public void removeChild(final IPeerModel child) { - Assert.isNotNull(child); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // Determine the parent node - final IPeerModel parent = child.getParent(IPeerModel.class); - if (parent == null) return; - - // Determine the peer id of the parent - String parentPeerId = parent.getPeerId(); - Assert.isNotNull(parentPeerId); - - // Get the list of existing children - List children = new ArrayList(getLocatorModel().getChildren(parentPeerId)); - if (children.contains(child)) { - children.remove(child); - getLocatorModel().setChildren(parentPeerId, children); - } - - // Notify listeners - parent.fireChangeEvent("changed", null, children); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService#mergeUserDefinedAttributes(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.protocol.IPeer, boolean) - */ - @Override - public void mergeUserDefinedAttributes(IPeerModel node, IPeer peer, boolean force) { - Assert.isNotNull(node); - Assert.isNotNull(peer); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // We can merge the peer attributes only if the destination peer is a AbstractPeer - IPeer dst = node.getPeer(); - // If not of correct type, than we cannot update the attributes - if (!(dst instanceof PeerRedirector) && !(dst instanceof Peer)) return; - // If destination and source peer are the same objects(!) nothing to do here - if (dst == peer) return; - - // If not forced, the peer id's of both attribute maps must be the same - if (!force) Assert.isTrue(dst.getID().equals(peer.getID()) - || (dst.getAttributes().get("remote.id.transient") != null && dst.getAttributes().get("remote.id.transient").equals(peer.getID()))); //$NON-NLS-1$ //$NON-NLS-2$ - - // Get a modifiable copy of the destination peer attributes - Map dstAttrs = new HashMap(dst.getAttributes()); - - // Get a modifiable copy of the source peer attributes - Map srcAttrs = new HashMap(peer.getAttributes()); - - // Remove the URI from the destination if requested - boolean removeURI = srcAttrs.containsKey(IPersistableNodeProperties.PROPERTY_URI + ".remove"); //$NON-NLS-1$ - removeURI = removeURI ? Boolean.parseBoolean(srcAttrs.remove(IPersistableNodeProperties.PROPERTY_URI + ".remove")) : false; //$NON-NLS-1$ - if (removeURI) dstAttrs.remove(IPersistableNodeProperties.PROPERTY_URI); - - // Determine the peer class - String peerClassSimpleName = peer.getClass().getSimpleName(); - if (peer.getAttributes().containsKey("remote.transient")) { //$NON-NLS-1$ - peerClassSimpleName = "RemotePeer"; //$NON-NLS-1$ - } - - // If the source is a RemotePeer and the destination not, attributes from - // the remote peer overwrites local attributes. - if ("RemotePeer".equals(peerClassSimpleName) && !"RemotePeer".equals(dst.getClass().getSimpleName())) { //$NON-NLS-1$ //$NON-NLS-2$ - // The ID is not merged from remote to local - srcAttrs.remove(IPeer.ATTR_ID); - // The Name is not merged from remote to local - srcAttrs.remove(IPeer.ATTR_NAME); - - // Eliminate all attributes already set in the destination attributes map - String merged = dstAttrs.get("remote.merged.transient"); //$NON-NLS-1$ - for (String key : dstAttrs.keySet()) { - if (merged == null || !merged.contains(key)) { - srcAttrs.remove(key); - } - } - } - - // Mark the peer as a remote peer and remember the remote peer id - if ("RemotePeer".equals(peerClassSimpleName) && !"RemotePeer".equals(dst.getClass().getSimpleName())) { //$NON-NLS-1$ //$NON-NLS-2$ - srcAttrs.put("remote.transient", Boolean.TRUE.toString()); //$NON-NLS-1$ - srcAttrs.put("remote.id.transient", peer.getID()); //$NON-NLS-1$ - srcAttrs.put("remote.merged.transient", srcAttrs.keySet().toString()); //$NON-NLS-1$ - } - - // Copy all remaining attributes from source to destination - if (!srcAttrs.isEmpty()) { - dstAttrs.putAll(srcAttrs); - } - - // If the ID's are different between the peers to merge and force is set, - // we have set the ID in dstAttrs to the original one as set in the destination peer. - if (force && !dst.getID().equals(dstAttrs.get(IPeer.ATTR_ID))) { - dstAttrs.put(IPeer.ATTR_ID, dst.getID()); - } - - // And update the destination peer attributes - if (dst instanceof PeerRedirector) { - ((PeerRedirector)dst).updateAttributes(dstAttrs); - } else if (dst instanceof Peer) { - ((Peer)dst).updateAttributes(dstAttrs); - } - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelLookupService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelLookupService.java new file mode 100644 index 000000000..b21e4f898 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelLookupService.java @@ -0,0 +1,247 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.services; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; + + +/** + * Default locator model lookup service implementation. + */ +public class PeerModelLookupService extends AbstractPeerModelService implements IPeerModelLookupService { + + /** + * Constructor. + * + * @param parentModel The parent locator model instance. Must not be null. + */ + public PeerModelLookupService(IPeerModel parentModel) { + super(parentModel); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelLookupService#lkupPeerModelById(java.lang.String) + */ + @Override + public IPeerNode lkupPeerModelById(String id) { + Assert.isNotNull(id); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + IPeerNode node = null; + for (IPeerNode candidate : getPeerModel().getPeers()) { + IPeer peer = candidate.getPeer(); + if (id.equals(peer.getID())) { + node = candidate; + break; + } else if (peer.getAttributes().get("remote.id.transient") != null //$NON-NLS-1$ + && peer.getAttributes().get("remote.id.transient").equals(id)) { //$NON-NLS-1$ + node = candidate; + break; + } + } + + return node; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelById(java.lang.String, java.lang.String) + */ + @Override + public IPeerNode lkupPeerModelById(String parentId, String id) { + Assert.isNotNull(parentId); + Assert.isNotNull(id); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + IPeerNode node = null; + for (IPeerNode candidate : getPeerModel().getChildren(parentId)) { + IPeer peer = candidate.getPeer(); + if (id.equals(peer.getID())) { + node = candidate; + break; + } else if (peer.getAttributes().get("remote.id.transient") != null //$NON-NLS-1$ + && peer.getAttributes().get("remote.id.transient").equals(id)) { //$NON-NLS-1$ + node = candidate; + break; + } + } + + return node; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelByAgentId(java.lang.String) + */ + @Override + public IPeerNode[] lkupPeerModelByAgentId(String agentId) { + Assert.isNotNull(agentId); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + List nodes = new ArrayList(); + for (IPeerNode candidate : getPeerModel().getPeers()) { + IPeer peer = candidate.getPeer(); + if (agentId.equals(peer.getAgentID())) { + nodes.add(candidate); + } + } + + return nodes.toArray(new IPeerNode[nodes.size()]); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelByAgentId(java.lang.String, java.lang.String) + */ + @Override + public IPeerNode[] lkupPeerModelByAgentId(String parentId, String agentId) { + Assert.isNotNull(parentId); + Assert.isNotNull(agentId); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + List nodes = new ArrayList(); + for (IPeerNode candidate : getPeerModel().getChildren(parentId)) { + IPeer peer = candidate.getPeer(); + if (agentId.equals(peer.getAgentID())) { + nodes.add(candidate); + } + } + + return nodes.toArray(new IPeerNode[nodes.size()]); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelByName(java.lang.String) + */ + @Override + public IPeerNode[] lkupPeerModelByName(String name) { + Assert.isNotNull(name); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + List nodes = new ArrayList(); + for (IPeerNode candidate : getPeerModel().getPeers()) { + IPeer peer = candidate.getPeer(); + if (name.equals(peer.getName())) { + nodes.add(candidate); + } + } + + return nodes.toArray(new IPeerNode[nodes.size()]); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelBySupportedServices(java.lang.String[], java.lang.String[]) + */ + @Override + public IPeerNode[] lkupPeerModelBySupportedServices(String[] expectedLocalServices, String[] expectedRemoteServices) { + Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + IPeerModel model = getPeerModel(); + IPeerModelQueryService queryService = model.getService(IPeerModelQueryService.class); + + List nodes = new ArrayList(); + for (IPeerNode candidate : model.getPeers()) { + String services = queryService.queryLocalServices(candidate); + + boolean matchesExpectations = true; + + // Ignore the local services if no expectations are set + if (expectedLocalServices != null && expectedLocalServices.length > 0) { + if (services != null) { + for (String service : expectedLocalServices) { + if (!services.contains(service)) { + matchesExpectations = false; + break; + } + } + } else { + matchesExpectations = false; + } + } + + if (!matchesExpectations) continue; + + services = queryService.queryRemoteServices(candidate); + + // Ignore the remote services if no expectations are set + if (expectedRemoteServices != null && expectedRemoteServices.length > 0) { + if (services != null) { + for (String service : expectedRemoteServices) { + if (!services.contains(service)) { + matchesExpectations = false; + break; + } + } + } else { + matchesExpectations = false; + } + } + + if (matchesExpectations) nodes.add(candidate); + } + + return nodes.toArray(new IPeerNode[nodes.size()]); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupMatchingStaticPeerModels(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) + */ + @Override + public IPeerNode[] lkupMatchingStaticPeerModels(IPeerNode peerNode) { + Assert.isNotNull(peerNode); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + return lkupMatchingStaticPeerModels(peerNode.getPeer()); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupMatchingStaticPeerModels(org.eclipse.tcf.protocol.IPeer) + */ + @Override + public IPeerNode[] lkupMatchingStaticPeerModels(IPeer peer) { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + List nodes = new ArrayList(); + + if (peer != null) { + for (IPeerNode candidate : getPeerModel().getPeers()) { + // If the agent id is available, match up the agent id first. + if (candidate.getPeer().getAgentID() != null && candidate.getPeer().getAgentID().equals(peer.getAgentID())) { + nodes.add(candidate); + continue; + } + + // Get the transport types. Transport type must match and must be either "TCP" or "SSL". + String t1 = peer.getTransportName(); + String t2 = candidate.getPeer().getTransportName(); + + if (t1 != null && t1.equals(t2) && ("TCP".equals(t1) || "SSL".equals(t1))) { //$NON-NLS-1$ //$NON-NLS-2$ + // Compare IP and Port. If they match, add the candidate to the result list + String i1 = peer.getAttributes().get(IPeer.ATTR_IP_HOST); + String i2 = candidate.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST); + if (i1 != null && i1.equals(i2)) { + String p1 = peer.getAttributes().get(IPeer.ATTR_IP_PORT); + String p2 = candidate.getPeer().getAttributes().get(IPeer.ATTR_IP_PORT); + if (p1 != null && p1.equals(p2)) { + nodes.add(candidate); + } + } + } + } + } + + return nodes.toArray(new IPeerNode[nodes.size()]); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelQueryService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelQueryService.java new file mode 100644 index 000000000..51f3cd282 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelQueryService.java @@ -0,0 +1,246 @@ +/******************************************************************************* + * Copyright (c) 2012, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.services; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.runtime.interfaces.IConditionTester; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; + +/** + * Default locator model peer node query service implementation. + */ +public class PeerModelQueryService extends AbstractPeerModelService implements IPeerModelQueryService { + + /** + * Constructor. + * + * @param parentModel The parent locator model instance. Must not be null. + */ + public PeerModelQueryService(IPeerModel parentModel) { + super(parentModel); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService#queryLocalServices(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) + */ + @Override + public String queryLocalServices(final IPeerNode node) { + Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + Assert.isNotNull(node); + + // Check if the services has been cached before + final AtomicReference services = new AtomicReference(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + services.set(node.getStringProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES)); + } + }); + + if (services.get() != null && !"".equals(services.get())) { //$NON-NLS-1$ + // Services are cached -> return immediately + return services.get(); + } + + // Get the service asynchronously and block the caller thread until + // the callback returned + final AtomicBoolean completed = new AtomicBoolean(false); + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + queryServicesAsync(node, new DoneQueryServices() { + @Override + public void doneQueryServices(Throwable error) { + if (error == null) { + services.set(node.getStringProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES)); + } + completed.set(true); + } + }); + } + }); + + final long startTime = System.currentTimeMillis(); + final IConditionTester tester = new IConditionTester() { + @Override + public boolean isConditionFulfilled() { + return completed.get(); + } + + @Override + public void cleanup() {} + }; + + while ((startTime + 1000) < System.currentTimeMillis() && !tester.isConditionFulfilled()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { /* ignored on purpose */ } + } + + return services.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService#queryRemoteServices(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) + */ + @Override + public String queryRemoteServices(final IPeerNode node) { + Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + Assert.isNotNull(node); + + // Check if the services has been cached before + final AtomicReference services = new AtomicReference(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + services.set(node.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES)); + } + }); + + if (services.get() != null && !"".equals(services.get())) { //$NON-NLS-1$ + // Services are cached -> return immediately + return services.get(); + } + + // Get the service asynchronously and block the caller thread until + // the callback returned + final AtomicBoolean completed = new AtomicBoolean(false); + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + queryServicesAsync(node, new DoneQueryServices() { + @Override + public void doneQueryServices(Throwable error) { + if (error == null) { + services.set(node.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES)); + } + completed.set(true); + } + }); + } + }); + + final long startTime = System.currentTimeMillis(); + final IConditionTester tester = new IConditionTester() { + @Override + public boolean isConditionFulfilled() { + return completed.get(); + } + + @Override + public void cleanup() {} + }; + + while ((startTime + 1000) < System.currentTimeMillis() && !tester.isConditionFulfilled()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { /* ignored on purpose */ } + } + + return services.get(); + } + + /* default */ final Map> serviceQueriesInProgress = new HashMap>(); + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService#queryServicesAsync(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService.DoneQueryServices) + */ + @Override + public void queryServicesAsync(final IPeerNode node, final DoneQueryServices done) { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + Assert.isNotNull(node); + Assert.isNotNull(done); + + // If a service query for the same peer is already in progress, + // attach the new done to the list to call and drop out + if (serviceQueriesInProgress.containsKey(node)) { + List dones = serviceQueriesInProgress.get(node); + Assert.isNotNull(dones); + dones.add(done); + return; + } + + // Add the done callback to a list of waiting callbacks per peer node + List dones = new ArrayList(); + dones.add(done); + serviceQueriesInProgress.put(node, dones); + + // Create the inner callback that invokes the queued outer callbacks + final DoneQueryServices innerDone = new DoneQueryServices() { + + @Override + public void doneQueryServices(Throwable error) { + // Get the list of the original done callbacks + List dones = serviceQueriesInProgress.remove(node); + if (dones != null) { + for (DoneQueryServices done : dones) { + done.doneQueryServices(error); + } + } + } + }; + + // Do not try to open a channel to peers known to be unreachable + int state = node.getIntProperty(IPeerNodeProperties.PROP_STATE); + if (state == IPeerNodeProperties.STATE_ERROR || state == IPeerNodeProperties.STATE_NOT_REACHABLE || !node.isComplete()) { + innerDone.doneQueryServices(null); + return; + } + + // Opens a channel with the full value-add chain + Map flags = new HashMap(); + flags.put(IChannelManager.FLAG_NO_PATH_MAP, Boolean.TRUE); + Tcf.getChannelManager().openChannel(node.getPeer(), flags, new IChannelManager.DoneOpenChannel() { + + @Override + public void doneOpenChannel(Throwable error, IChannel channel) { + // If the channel opening failed -> return immediately + if (error != null) { + innerDone.doneQueryServices(error); + } else { + // Get the local service + List localServices = new ArrayList(channel.getLocalServices()); + // Get the remote services + List remoteServices = new ArrayList(channel.getRemoteServices()); + + // Close the channel + Tcf.getChannelManager().closeChannel(channel); + + // Sort the service lists + Collections.sort(localServices); + Collections.sort(remoteServices); + + // Update the services + IPeerModelUpdateService updateService = node.getModel().getService(IPeerModelUpdateService.class); + updateService.updatePeerServices(node, localServices, remoteServices); + + // Invoke the callback + innerDone.doneQueryServices(null); + } + } + }); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelRefreshService.java new file mode 100644 index 000000000..ba31a6891 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelRefreshService.java @@ -0,0 +1,599 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.services; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.services.ILocator; +import org.eclipse.tcf.te.runtime.callback.AsyncCallbackCollector; +import org.eclipse.tcf.te.runtime.callback.Callback; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties; +import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; +import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.core.async.CallbackInvocationDelegate; +import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; +import org.eclipse.tcf.te.tcf.core.peers.Peer; +import org.eclipse.tcf.te.tcf.locator.ScannerRunnable; +import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.preferences.IPreferenceKeys; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.model.ModelLocationUtil; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; + + +/** + * Default locator model refresh service implementation. + */ +public class PeerModelRefreshService extends AbstractPeerModelService implements IPeerModelRefreshService { + + /** + * Constructor. + * + * @param parentModel The parent locator model instance. Must not be null. + */ + public PeerModelRefreshService(IPeerModel parentModel) { + super(parentModel); + } + + /** + * Asynchronously invoke the callback within the TCF dispatch thread. + * + * @param callback The callback to invoke or null. + */ + protected final void invokeCallback(final ICallback callback) { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + if (callback != null) { + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + callback.done(PeerModelRefreshService.this, Status.OK_STATUS); + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService#refresh(org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void refresh(final ICallback callback) { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + // Get the parent locator model + IPeerModel model = getPeerModel(); + + // If the parent model is already disposed, the service will drop out immediately + if (model.isDisposed()) { + invokeCallback(callback); + return; + } + + // If the TCF framework isn't initialized yet, the service will drop out immediately + if (!Tcf.isRunning()) { + invokeCallback(callback); + return; + } + + // Get the list of old children (update node instances where possible) + final List oldChildren = new ArrayList(Arrays.asList(model.getPeers())); + + // Refresh the static peer definitions + refreshStaticPeers(oldChildren, model); + +// // Get the locator service +// ILocator locatorService = Protocol.getLocator(); +// if (locatorService != null) { +// // Check for the locator listener to be created and registered +// if (model instanceof PeerModel) { +// ((PeerModel)model).checkLocatorListener(); +// } +// // Get the map of peers known to the locator service. +// Map peers = locatorService.getPeers(); +// // Process the peers +// processPeers(peers, oldChildren, model); +// } + + // If there are remaining old children, remove them from the model (non-recursive) + for (IPeerNode oldChild : oldChildren) { + model.getService(IPeerModelUpdateService.class).remove(oldChild); + } + + // Invoke the callback + invokeCallback(callback); + } + + /** + * Process the given map of peers and update the given locator model. + * + * @param peers The map of peers to process. Must not be null. + * @param oldChildren The list of old children. Must not be null. + * @param model The locator model. Must not be null. + */ + protected void processPeers(Map peers, List oldChildren, IPeerModel model) { + Assert.isNotNull(peers); + Assert.isNotNull(oldChildren); + Assert.isNotNull(model); + + for (Entry entry : peers.entrySet()) { + // Get the peer instance for the current peer id + IPeer peer = entry.getValue(); + // Try to find an existing peer node first + IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(entry.getKey()); + // And create a new one if we cannot find it + if (peerNode == null) { + peerNode = new PeerNode(model, peer); + } + else { + oldChildren.remove(peerNode); + } + + if (peerNode.getPeer() != peer) { + String value = peerNode.getPeer().getAttributes().get(IPersistableNodeProperties.PROPERTY_URI); + URI uri = value != null ? URI.create(value) : null; + File file = uri != null && "file".equals(uri.getScheme()) ? new File(uri.normalize()) : null; //$NON-NLS-1$ + if (file != null && !file.exists()) { + peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer); + } else { + // Merge user configured properties between the peers + model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, peer, false); + } + } + + // Validate the peer node before adding + peerNode = model.validatePeerNodeForAdd(peerNode); + if (peerNode != null) { + // There is still the chance that the node we add is a static node and + // there exist an dynamically discovered node with a different id but + // for the same peer. Do this check only if the peer to add is a static one. + IPeerNode toRemove = null; + for (IPeerNode candidate : model.getPeers()) { + if (candidate.equals(peerNode))continue; + String peerID = peerNode.getPeerId(); + String clientID = candidate.getPeer().getAttributes().get("ClientID"); //$NON-NLS-1$ + if (clientID != null && clientID.equals(peerID)) { + // Merge user configured properties between the peers + model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(candidate, peerNode.getPeer(), true); + peerNode = null; + break; + } + + if (peerNode.getPeer().getTransportName() != null && peerNode.getPeer().getTransportName().equals(candidate.getPeer().getTransportName())) { + // Same transport name + if ("PIPE".equals(candidate.getPeer().getTransportName())) { //$NON-NLS-1$ + // Compare the pipe name + String name1 = peerNode.getPeer().getAttributes().get("PipeName"); //$NON-NLS-1$ + String name2 = candidate.getPeer().getAttributes().get("PipeName"); //$NON-NLS-1$ + // Same pipe -> same node + if (name1 != null && name1.equals(name2)) { + // Merge user configured properties between the peers + model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true); + toRemove = candidate; + break; + } + } else if ("Loop".equals(candidate.getPeer().getTransportName())) { //$NON-NLS-1$ + // Merge user configured properties between the peers + model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true); + toRemove = candidate; + break; + } else { + // Compare IP_HOST and IP_Port; + String ip1 = peerNode.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST); + String ip2 = candidate.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST); + if (IPAddressUtil.getInstance().isSameHost(ip1, ip2)) { + // Compare the ports + String port1 = peerNode.getPeer().getAttributes().get(IPeer.ATTR_IP_PORT); + String port2 = candidate.getPeer().getAttributes().get(IPeer.ATTR_IP_PORT); + + if (port1 != null && port1.equals(port2)) { + // Merge user configured properties between the peers + model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true); + toRemove = candidate; + break; + } + } + } + } + } + + if (toRemove != null) { + model.getService(IPeerModelUpdateService.class).remove(toRemove); + toRemove = null; + } + + if (peerNode != null) { + // Add the peer node to model + model.getService(IPeerModelUpdateService.class).add(peerNode); + // And schedule for immediate status update + Runnable runnable = new ScannerRunnable(model.getScanner(), peerNode); + Protocol.invokeLater(runnable); + } + } + } + } + + private final AtomicBoolean REFRESH_STATIC_PEERS_GUARD = new AtomicBoolean(false); + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService#refreshStaticPeers() + */ + @Override + public void refreshStaticPeers() { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + // This method might be called reentrant while processing. Return immediately + // in this case. + if (REFRESH_STATIC_PEERS_GUARD.get()) { + return; + } + REFRESH_STATIC_PEERS_GUARD.set(true); + + // Get the parent locator model + IPeerModel model = getPeerModel(); + + // If the parent model is already disposed, the service will drop out immediately + if (model.isDisposed()) { + return; + } + + // Get the list of old children (update node instances where possible) + final List oldChildren = new ArrayList(Arrays.asList(model.getPeers())); + + // Refresh the static peer definitions + refreshStaticPeers(oldChildren, model); + + REFRESH_STATIC_PEERS_GUARD.set(false); + } + + /** + * Refresh the static peer definitions. + * + * @param oldChildren The list of old children. Must not be null. + * @param model The locator model. Must not be null. + */ + protected void refreshStaticPeers(List oldChildren, IPeerModel model) { + Assert.isNotNull(oldChildren); + Assert.isNotNull(model); + + // Get the root locations to lookup the static peer definitions + File[] roots = getStaticPeerLookupDirectories(); + if (roots.length > 0) { + // The map of peers created from the static definitions + Map peers = new HashMap(); + // The list of peer attributes with postponed peer instance creation + List> postponed = new ArrayList>(); + // Process the root locations + for (File root : roots) { + // List all "*.json" and "*.peer" files within the root location + File[] candidates = root.listFiles(new FileFilter() { + @Override + public boolean accept(File pathname) { + IPath path = new Path(pathname.getAbsolutePath()); + return path.getFileExtension() != null && + (path.getFileExtension().toLowerCase().equals("json") || path.getFileExtension().toLowerCase().equals("peer")); //$NON-NLS-1$ //$NON-NLS-2$ + } + }); + // If there are ini files to read, process them + if (candidates != null && candidates.length > 0) { + + for (File candidate : candidates) { + try { + IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class); + IPeer tempPeer = (IPeer)service.read(IPeer.class, candidate.getAbsoluteFile().toURI()); + + Map attrs = new HashMap(tempPeer.getAttributes()); + + // Remember the file path within the properties + attrs.put(IPersistableNodeProperties.PROPERTY_URI, candidate.getAbsoluteFile().toURI().toString()); + // Mark the node as static peer model node + attrs.put("static.transient", "true"); //$NON-NLS-1$ //$NON-NLS-2$ + + // Validate the name attribute. If not set, set + // it to the file name without the .ini extension. + String name = attrs.get(IPeer.ATTR_NAME); + if (name == null || "".equals(name.trim())) { //$NON-NLS-1$ + name = new Path(candidate.getAbsolutePath()).removeFileExtension().lastSegment(); + attrs.put(IPeer.ATTR_NAME, name); + } + + // Validate the id attribute. If not set, generate one. + String id = attrs.get(IPeer.ATTR_ID); + if (id == null || "".equals(id.trim()) || "USR:".equals(id.trim())) { //$NON-NLS-1$ //$NON-NLS-2$ + String transport = attrs.get(IPeer.ATTR_TRANSPORT_NAME); + String host = attrs.get(IPeer.ATTR_IP_HOST); + String port = attrs.get(IPeer.ATTR_IP_PORT); + + if (transport != null && host != null && !(id != null && "USR:".equals(id.trim()))) { //$NON-NLS-1$ + id = transport.trim() + ":" + host.trim(); //$NON-NLS-1$ + id += port != null ? ":" + port.trim() : ":1534"; //$NON-NLS-1$ //$NON-NLS-2$ + } else { + id = "USR:" + System.currentTimeMillis(); //$NON-NLS-1$ + // If the key is not unique, we have to wait a little bit an try again + while (peers.containsKey(id)) { + try { Thread.sleep(20); } catch (InterruptedException e) { /* ignored on purpose */ } + id = "USR:" + System.currentTimeMillis(); //$NON-NLS-1$ + } + } + attrs.put(IPeer.ATTR_ID, id); + } + + // If the redirect property is not set, create the peer right away + if (attrs.get(IPeerNodeProperties.PROP_REDIRECT_PROXY) == null) { + // Construct the peer from the attributes + IPeer peer = new Peer(attrs); + // Add the constructed peer to the peers map + peers.put(peer.getID(), peer); + } else { + // Try to get the peer proxy + String proxyId = attrs.get(IPeerNodeProperties.PROP_REDIRECT_PROXY); + IPeer proxy = peers.get(proxyId); + if (proxy == null) { + IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(proxyId); + if (peerNode != null) { + proxy = peerNode.getPeer(); + } + } + + if (proxy != null) { + // Construct the peer redirector + PeerRedirector redirector = new PeerRedirector(proxy, attrs); + // Add the redirector to the peers map + peers.put(redirector.getID(), redirector); + } else { + // Postpone peer creation + postponed.add(attrs); + } + } + } catch (IOException e) { + /* ignored on purpose */ + } + } + } + } + + // Process postponed peers if there are any + if (!postponed.isEmpty()) { + for (Map attrs : postponed) { + String proxyId = attrs.get(IPeerNodeProperties.PROP_REDIRECT_PROXY); + IPeer proxy = proxyId != null ? peers.get(proxyId) : null; + if (proxy == null) { + IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(proxyId); + if (peerNode != null) { + proxy = peerNode.getPeer(); + } + } + + if (proxy != null) { + // Construct the peer redirector + PeerRedirector redirector = new PeerRedirector(proxy, attrs); + // Add the redirector to the peers map + peers.put(redirector.getID(), redirector); + } else { + // Proxy not available -> reset redirection + attrs.remove(IPeerNodeProperties.PROP_REDIRECT_PROXY); + // Construct the peer from the attributes + IPeer peer = new Peer(attrs); + // Add the constructed peer to the peers map + peers.put(peer.getID(), peer); + } + } + } + + // Process the read peers + if (!peers.isEmpty()) { + processPeers(peers, oldChildren, model); + } + + // Scan the peers for redirected ones ... and set up the peer model association + for (Entry entry : peers.entrySet()) { + IPeer peer = entry.getValue(); + if (!(peer instanceof PeerRedirector)) { + continue; + } + + // Get the peers peer model object + IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(entry.getKey()); + Assert.isNotNull(peerNode); + + // The peer is a peer redirector -> get the proxy peer id and proxy peer model + String proxyPeerId = ((PeerRedirector)peer).getParent().getID(); + IPeerNode proxy = model.getService(IPeerModelLookupService.class).lkupPeerModelById(proxyPeerId); + Assert.isNotNull(proxy); + + peerNode.setParent(proxy); + model.getService(IPeerModelUpdateService.class).addChild(peerNode); + } + } + } + + /** + * Returns the list of root locations to lookup for static peers definitions. + * + * @return The list of root locations or an empty list. + */ + protected File[] getStaticPeerLookupDirectories() { + // The list defining the root locations + List rootLocations = new ArrayList(); + + // Check on the peers root locations preference setting + String roots = CoreBundleActivator.getScopedPreferences().getString(IPreferenceKeys.PREF_STATIC_PEERS_ROOT_LOCATIONS); + // If set, split it in its single components + if (roots != null) { + String[] candidates = roots.split(File.pathSeparator); + // Check on each candidate to denote an existing directory + for (String candidate : candidates) { + File file = new File(candidate); + if (file.canRead() && file.isDirectory() && !rootLocations.contains(file)) { + rootLocations.add(file); + } + } + } + + // always add default root location + IPath defaultPath = ModelLocationUtil.getStaticPeersRootLocation(); + if (defaultPath != null) { + File file = defaultPath.toFile(); + if (file.canRead() && file.isDirectory() && !rootLocations.contains(file)) { + rootLocations.add(file); + } + } + + return rootLocations.toArray(new File[rootLocations.size()]); + } + + /* default */ final List refreshAgentIDCallbacks = new ArrayList(); + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService#refreshAgentIDs(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode[], org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void refreshAgentIDs(IPeerNode[] nodes, final ICallback callback) { + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + // This method might be called reentrant while processing. Add + // the callback to the "wait" list and return immediately. + if (refreshAgentIDCallbacks.size() > 0) { + refreshAgentIDCallbacks.add(callback); + return; + } + refreshAgentIDCallbacks.add(callback); + + // Get the parent locator model + IPeerModel model = getPeerModel(); + + // If the parent model is already disposed, the service will drop out immediately + if (model.isDisposed()) { + return; + } + + // The callback collector will fire once all static peers have been refreshed + final AsyncCallbackCollector collector = new AsyncCallbackCollector(new Callback() { + @Override + protected void internalDone(Object caller, IStatus status) { + // Make a copy of the callbacks to invoke + List callbacks = new ArrayList(refreshAgentIDCallbacks); + refreshAgentIDCallbacks.clear(); + // And invoke the final callbacks + for (ICallback callback : callbacks) { + invokeCallback(callback); + } + } + }, new CallbackInvocationDelegate()); + + // Make a copy of the current list of static peers before processing + List nodesToProcess = new ArrayList(Arrays.asList(nodes != null ? nodes : model.getPeers())); + // Loop the list of static peers and try to get the agent ID + for (IPeerNode node : nodesToProcess) { + // If not static or not complete --> ignore + if (!node.isComplete()) continue; + // Refresh the agent ID + refreshAgentID(node, new AsyncCallbackCollector.SimpleCollectorCallback(collector)); + } + + // Mark the collector initialization as done + collector.initDone(); + } + + /** + * Refreshes the agent ID of the given static peer node, if reachable. + * + * @param node The peer model node. Must not be null. + * @param callback The callback. Must not be null. + */ + protected void refreshAgentID(final IPeerNode node, final ICallback callback) { + Assert.isNotNull(node); + Assert.isNotNull(callback); + + if (!(node.getPeer() instanceof Peer)) return; + + // Try to open a channel to the node + Map flags = new HashMap(); + flags.put(IChannelManager.FLAG_FORCE_NEW, Boolean.TRUE); + flags.put(IChannelManager.FLAG_NO_VALUE_ADD, Boolean.TRUE); + + Tcf.getChannelManager().openChannel(node.getPeer(), flags, new IChannelManager.DoneOpenChannel() { + + @Override + public void doneOpenChannel(Throwable error, final IChannel channel) { + if (channel != null && channel.getState() == IChannel.STATE_OPEN) { + // Get the locator service + ILocator service = channel.getRemoteService(ILocator.class); + if (service != null) { + // Query the agent ID + service.getAgentID(new ILocator.DoneGetAgentID() { + @Override + public void doneGetAgentID(IToken token, Exception error, String agentID) { + // Close the channel + Tcf.getChannelManager().closeChannel(channel); + + // Update the peer + if (agentID == null || "".equals(agentID)) { //$NON-NLS-1$ + if (node.getPeer().getAgentID() != null) { + // Remove the old agent ID + Map attrs = new HashMap(channel.getRemotePeer().getAttributes()); + attrs.remove(IPeer.ATTR_AGENT_ID); + node.setProperty(IPeerNodeProperties.PROP_INSTANCE, new Peer(attrs)); + } + } else if (node.getPeer().getAgentID() == null || !agentID.equals(node.getPeer().getAgentID())){ + // Set the new agent ID + Map attrs = new HashMap(channel.getRemotePeer().getAttributes()); + attrs.put(IPeer.ATTR_AGENT_ID, agentID); + node.setProperty(IPeerNodeProperties.PROP_INSTANCE, new Peer(attrs)); + } + + // Invoke the callback + callback.done(PeerModelRefreshService.this, Status.OK_STATUS); + } + }); + } else { + // Close the channel + Tcf.getChannelManager().closeChannel(channel); + // Invoke the callback + callback.done(PeerModelRefreshService.this, Status.OK_STATUS); + } + } else { + // Close the channel in any case + if (channel != null) Tcf.getChannelManager().closeChannel(channel); + // Invoke the callback + callback.done(PeerModelRefreshService.this, Status.OK_STATUS); + } + + } + }); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelUpdateService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelUpdateService.java new file mode 100644 index 000000000..0f4684ca4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelUpdateService.java @@ -0,0 +1,259 @@ +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.services; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties; +import org.eclipse.tcf.te.tcf.core.peers.Peer; +import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; + + +/** + * Default locator model update service implementation. + */ +public class PeerModelUpdateService extends AbstractPeerModelService implements IPeerModelUpdateService { + + /** + * Constructor. + * + * @param parentModel The parent locator model instance. Must not be null. + */ + public PeerModelUpdateService(IPeerModel parentModel) { + super(parentModel); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#add(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel) + */ + @Override + public void add(final IPeerNode peer) { + Assert.isNotNull(peer); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + Map peers = (Map)getPeerModel().getAdapter(Map.class); + Assert.isNotNull(peers); + peers.put(peer.getPeerId(), peer); + + final IModelListener[] listeners = getPeerModel().getListener(); + if (listeners.length > 0) { + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + for (IModelListener listener : listeners) { + listener.locatorModelChanged(getPeerModel(), peer, true); + } + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#remove(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel) + */ + @Override + public void remove(final IPeerNode peer) { + Assert.isNotNull(peer); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + Map peers = (Map)getPeerModel().getAdapter(Map.class); + Assert.isNotNull(peers); + peers.remove(peer.getPeerId()); + + getPeerModel().setChildren(peer.getPeerId(), null); + + final IModelListener[] listeners = getPeerModel().getListener(); + if (listeners.length > 0) { + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + for (IModelListener listener : listeners) { + listener.locatorModelChanged(getPeerModel(), peer, false); + } + } + }); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#updatePeerServices(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel, java.util.Collection, java.util.Collection) + */ + @Override + public void updatePeerServices(IPeerNode peerNode, Collection localServices, Collection remoteServices) { + Assert.isNotNull(peerNode); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + peerNode.setProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES, localServices != null ? makeString(localServices) : null); + peerNode.setProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES, remoteServices != null ? makeString(remoteServices) : null); + } + + /** + * Transform the given collection into a plain string. + * + * @param collection The collection. Must not be null. + * @return The plain string. + */ + protected String makeString(Collection collection) { + Assert.isNotNull(collection); + + if (collection.isEmpty()) return null; + + String buffer = collection.toString(); + buffer = buffer.replaceAll("\\[", "").replaceAll("\\]", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + + return buffer.trim(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService#addChild(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) + */ + @Override + public void addChild(final IPeerNode child) { + Assert.isNotNull(child); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + // Determine the parent node + final IPeerNode parent = child.getParent(IPeerNode.class); + if (parent == null) return; + + // Determine the peer id of the parent + String parentPeerId = parent.getPeerId(); + Assert.isNotNull(parentPeerId); + + // Get the list of existing children + List children = new ArrayList(getPeerModel().getChildren(parentPeerId)); + if (!children.contains(child)) { + children.add(child); + getPeerModel().setChildren(parentPeerId, children); + } + + // Notify listeners + parent.fireChangeEvent("changed", null, children); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService#removeChild(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) + */ + @Override + public void removeChild(final IPeerNode child) { + Assert.isNotNull(child); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + // Determine the parent node + final IPeerNode parent = child.getParent(IPeerNode.class); + if (parent == null) return; + + // Determine the peer id of the parent + String parentPeerId = parent.getPeerId(); + Assert.isNotNull(parentPeerId); + + // Get the list of existing children + List children = new ArrayList(getPeerModel().getChildren(parentPeerId)); + if (children.contains(child)) { + children.remove(child); + getPeerModel().setChildren(parentPeerId, children); + } + + // Notify listeners + parent.fireChangeEvent("changed", null, children); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService#mergeUserDefinedAttributes(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, org.eclipse.tcf.protocol.IPeer, boolean) + */ + @Override + public void mergeUserDefinedAttributes(IPeerNode node, IPeer peer, boolean force) { + Assert.isNotNull(node); + Assert.isNotNull(peer); + Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ + + // We can merge the peer attributes only if the destination peer is a AbstractPeer + IPeer dst = node.getPeer(); + // If not of correct type, than we cannot update the attributes + if (!(dst instanceof PeerRedirector) && !(dst instanceof Peer)) return; + // If destination and source peer are the same objects(!) nothing to do here + if (dst == peer) return; + + // If not forced, the peer id's of both attribute maps must be the same + if (!force) Assert.isTrue(dst.getID().equals(peer.getID()) + || (dst.getAttributes().get("remote.id.transient") != null && dst.getAttributes().get("remote.id.transient").equals(peer.getID()))); //$NON-NLS-1$ //$NON-NLS-2$ + + // Get a modifiable copy of the destination peer attributes + Map dstAttrs = new HashMap(dst.getAttributes()); + + // Get a modifiable copy of the source peer attributes + Map srcAttrs = new HashMap(peer.getAttributes()); + + // Remove the URI from the destination if requested + boolean removeURI = srcAttrs.containsKey(IPersistableNodeProperties.PROPERTY_URI + ".remove"); //$NON-NLS-1$ + removeURI = removeURI ? Boolean.parseBoolean(srcAttrs.remove(IPersistableNodeProperties.PROPERTY_URI + ".remove")) : false; //$NON-NLS-1$ + if (removeURI) dstAttrs.remove(IPersistableNodeProperties.PROPERTY_URI); + + // Determine the peer class + String peerClassSimpleName = peer.getClass().getSimpleName(); + if (peer.getAttributes().containsKey("remote.transient")) { //$NON-NLS-1$ + peerClassSimpleName = "RemotePeer"; //$NON-NLS-1$ + } + + // If the source is a RemotePeer and the destination not, attributes from + // the remote peer overwrites local attributes. + if ("RemotePeer".equals(peerClassSimpleName) && !"RemotePeer".equals(dst.getClass().getSimpleName())) { //$NON-NLS-1$ //$NON-NLS-2$ + // The ID is not merged from remote to local + srcAttrs.remove(IPeer.ATTR_ID); + // The Name is not merged from remote to local + srcAttrs.remove(IPeer.ATTR_NAME); + + // Eliminate all attributes already set in the destination attributes map + String merged = dstAttrs.get("remote.merged.transient"); //$NON-NLS-1$ + for (String key : dstAttrs.keySet()) { + if (merged == null || !merged.contains(key)) { + srcAttrs.remove(key); + } + } + } + + // Mark the peer as a remote peer and remember the remote peer id + if ("RemotePeer".equals(peerClassSimpleName) && !"RemotePeer".equals(dst.getClass().getSimpleName())) { //$NON-NLS-1$ //$NON-NLS-2$ + srcAttrs.put("remote.transient", Boolean.TRUE.toString()); //$NON-NLS-1$ + srcAttrs.put("remote.id.transient", peer.getID()); //$NON-NLS-1$ + srcAttrs.put("remote.merged.transient", srcAttrs.keySet().toString()); //$NON-NLS-1$ + } + + // Copy all remaining attributes from source to destination + if (!srcAttrs.isEmpty()) { + dstAttrs.putAll(srcAttrs); + } + + // If the ID's are different between the peers to merge and force is set, + // we have set the ID in dstAttrs to the original one as set in the destination peer. + if (force && !dst.getID().equals(dstAttrs.get(IPeer.ATTR_ID))) { + dstAttrs.put(IPeer.ATTR_ID, dst.getID()); + } + + // And update the destination peer attributes + if (dst instanceof PeerRedirector) { + ((PeerRedirector)dst).updateAttributes(dstAttrs); + } else if (dst instanceof Peer) { + ((Peer)dst).updateAttributes(dstAttrs); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java index 70fabdaaf..f1ff8984e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java @@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.locator.services; import org.eclipse.core.runtime.Assert; import org.eclipse.tcf.te.core.interfaces.IConnectable; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; /** @@ -40,7 +40,7 @@ public class StepperOperationService extends org.eclipse.tcf.te.runtime.stepper. */ @Override public String getStepGroupId(Object context, String operation) { - Assert.isTrue(context instanceof IPeerModel); + Assert.isTrue(context instanceof IPeerNode); if (IStepperServiceOperations.CONNECT.equals(operation)) { return "org.eclipse.tcf.te.tcf.locator.connectStepGroup"; //$NON-NLS-1$ @@ -57,13 +57,13 @@ public class StepperOperationService extends org.eclipse.tcf.te.runtime.stepper. */ @Override public String getStepGroupName(Object context, String operation) { - Assert.isTrue(context instanceof IPeerModel); + Assert.isTrue(context instanceof IPeerNode); if (IStepperServiceOperations.CONNECT.equals(operation)) { - return "Connect "+((IPeerModel)context).getName(); //$NON-NLS-1$ + return "Connect "+((IPeerNode)context).getName(); //$NON-NLS-1$ } if (IStepperServiceOperations.DISCONNECT.equals(operation)) { - return "Disconnect "+((IPeerModel)context).getName(); //$NON-NLS-1$ + return "Disconnect "+((IPeerNode)context).getName(); //$NON-NLS-1$ } return null; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java index e23d2f3d6..9cf2ffa15 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java @@ -17,8 +17,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.core.runtime.Assert; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; /** @@ -51,19 +51,19 @@ public class RuntimeServiceContextFilter implements IDefaultContextService.ICont } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService.IContextFilter#select(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService.IContextFilter#select(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) */ @Override - public boolean select(final IPeerModel peerModel) { - Assert.isNotNull(peerModel); + public boolean select(final IPeerNode peerNode) { + Assert.isNotNull(peerNode); - final IPeer peer = peerModel.getPeer(); + final IPeer peer = peerNode.getPeer(); final AtomicBoolean result = new AtomicBoolean(false); Protocol.invokeAndWait(new Runnable() { @Override public void run() { List list; - String services = peerModel.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES); + String services = peerNode.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES); if (services != null) { list = Arrays.asList(services.split(",\\s*")); //$NON-NLS-1$ boolean containsAll = true; @@ -78,7 +78,7 @@ public class RuntimeServiceContextFilter implements IDefaultContextService.ICont } if (useDisconnectedContexts) { - services = peer.getAttributes().get(IPeerModelProperties.PROP_OFFLINE_SERVICES); + services = peer.getAttributes().get(IPeerNodeProperties.PROP_OFFLINE_SERVICES); list = services != null ? Arrays.asList(services.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$ boolean containsAll = true; for (String serviceName : serviceNames) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerModelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerModelStep.java deleted file mode 100644 index 3effd5fbf..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerModelStep.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.steps; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.core.steps.AbstractPeerStep; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; - -/** - * Abstract peer model context step - */ -public abstract class AbstractPeerModelStep extends AbstractPeerStep { - - /** - * Returns the active peer model context that is currently used. - * - * @param context The step context. Must not be null. - * @param data The data giving object. Must not be null. - * @param fullQualifiedId The full qualfied id for this step. Must not be null. - * @return The active peer model context. - */ - protected IPeerModel getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) { - Object activeContext = getActiveContext(context, data, fullQualifiedId); - IPeerModel peerModel = null; - if (activeContext instanceof IPeerModel) - return (IPeerModel)activeContext; - if (activeContext instanceof IAdaptable) - peerModel = (IPeerModel)((IAdaptable)activeContext).getAdapter(IPeerModel.class); - if (peerModel == null) - peerModel = (IPeerModel)Platform.getAdapterManager().getAdapter(activeContext, IPeerModel.class); - - return peerModel; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerNodeStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerNodeStep.java new file mode 100644 index 000000000..98fdd69c4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerNodeStep.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.steps; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.core.steps.AbstractPeerStep; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; + +/** + * Abstract peer model context step + */ +public abstract class AbstractPeerNodeStep extends AbstractPeerStep { + + /** + * Returns the active peer model context that is currently used. + * + * @param context The step context. Must not be null. + * @param data The data giving object. Must not be null. + * @param fullQualifiedId The full qualfied id for this step. Must not be null. + * @return The active peer model context. + */ + protected IPeerNode getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) { + Object activeContext = getActiveContext(context, data, fullQualifiedId); + IPeerNode peerNode = null; + if (activeContext instanceof IPeerNode) + return (IPeerNode)activeContext; + if (activeContext instanceof IAdaptable) + peerNode = (IPeerNode)((IAdaptable)activeContext).getAdapter(IPeerNode.class); + if (peerNode == null) + peerNode = (IPeerNode)Platform.getAdapterManager().getAdapter(activeContext, IPeerNode.class); + + return peerNode; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java index 69b562ec4..2af3fb0ab 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java @@ -27,12 +27,12 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.tcf.core.interfaces.steps.ITcfStepAttributes; import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; /** * Check service step implementation. */ -public class CheckServiceStep extends AbstractPeerModelStep { +public class CheckServiceStep extends AbstractPeerNodeStep { public static final String PARAMETER_REMOTE_SERVICE = "remoteService"; //$NON-NLS-1$ public static final String PARAMETER_LOCAL_SERVICE = "localService"; //$NON-NLS-1$ @@ -88,7 +88,7 @@ public class CheckServiceStep extends AbstractPeerModelStep { } String offlineService = getParameters().get(PARAMETER_OFFLINE_SERVICE); - String services = getActivePeerContext(context, data, fullQualifiedId).getAttributes().get(IPeerModelProperties.PROP_OFFLINE_SERVICES); + String services = getActivePeerContext(context, data, fullQualifiedId).getAttributes().get(IPeerNodeProperties.PROP_OFFLINE_SERVICES); List list = services != null ? Arrays.asList(services.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$ if (offlineService != null && !list.contains(offlineService)) { throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing offline service '" + offlineService + "'")); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java index 023622795..df40c6157 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java @@ -23,7 +23,7 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService /** * Set the active context as default context. */ -public class SetAsDefaultContextStep extends AbstractPeerModelStep { +public class SetAsDefaultContextStep extends AbstractPeerNodeStep { /** * Constructor. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java index 386d936ea..369a2b4e1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java @@ -19,12 +19,12 @@ import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; /** * Set the waiting_for_ready state. */ -public class SetWaitForReadyStep extends AbstractPeerModelStep { +public class SetWaitForReadyStep extends AbstractPeerNodeStep { /** * Constructor. @@ -47,9 +47,9 @@ public class SetWaitForReadyStep extends AbstractPeerModelStep { Protocol.invokeAndWait(new Runnable() { @Override public void run() { - int state = getActivePeerModelContext(context, data, fullQualifiedId).getIntProperty(IPeerModelProperties.PROP_STATE); - if (state == IPeerModelProperties.STATE_UNKNOWN || state == IPeerModelProperties.STATE_NOT_REACHABLE || state == IPeerModelProperties.STATE_ERROR) { - getActivePeerModelContext(context, data, fullQualifiedId).setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_WAITING_FOR_READY); + int state = getActivePeerModelContext(context, data, fullQualifiedId).getIntProperty(IPeerNodeProperties.PROP_STATE); + if (state == IPeerNodeProperties.STATE_UNKNOWN || state == IPeerNodeProperties.STATE_NOT_REACHABLE || state == IPeerNodeProperties.STATE_ERROR) { + getActivePeerModelContext(context, data, fullQualifiedId).setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_WAITING_FOR_READY); } } }); @@ -72,7 +72,7 @@ public class SetWaitForReadyStep extends AbstractPeerModelStep { Protocol.invokeAndWait(new Runnable() { @Override public void run() { - getActivePeerModelContext(context, data, fullQualifiedId).setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_NOT_REACHABLE); + getActivePeerModelContext(context, data, fullQualifiedId).setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_NOT_REACHABLE); } }); super.rollback(context, data, status, fullQualifiedId, monitor, callback); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java index cbf2a034e..f29164fca 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java @@ -19,14 +19,14 @@ import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.model.Model; /** * Signal peer disconnected step. */ -public class SignalPeerDisconnectedStep extends AbstractPeerModelStep { +public class SignalPeerDisconnectedStep extends AbstractPeerNodeStep { /* (non-Javadoc) * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) @@ -46,14 +46,14 @@ public class SignalPeerDisconnectedStep extends AbstractPeerModelStep { Assert.isNotNull(monitor); Assert.isNotNull(callback); - final IPeerModel peerModel = getActivePeerModelContext(context, data, fullQualifiedId); - if (peerModel != null) { + final IPeerNode peerNode = getActivePeerModelContext(context, data, fullQualifiedId); + if (peerNode != null) { Protocol.invokeLater(new Runnable() { @Override public void run() { - ILocatorModel model = Model.getModel(); + IPeerModel model = Model.getModel(); for (IModelListener listener : model.getListener()) { - listener.locatorModelChanged(model, peerModel, false); + listener.locatorModelChanged(model, peerNode, false); } callback.done(SignalPeerDisconnectedStep.this, Status.OK_STATUS); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java index 73ae17f02..58b66d40c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java @@ -30,14 +30,14 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.runtime.utils.StatusHelper; import org.eclipse.tcf.te.tcf.locator.interfaces.IStepAttributes; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; /** * Start debugger step implementation. */ -public class StartDebuggerStep extends AbstractPeerModelStep { +public class StartDebuggerStep extends AbstractPeerNodeStep { /** * Interface to be implemented by start debugger step delegates. @@ -51,7 +51,7 @@ public class StartDebuggerStep extends AbstractPeerModelStep { * @param monitor The progress monitor. Must not be null. * @param callback The callback to invoke if finished. Must not be null. */ - public void postAttachDebugger(IPeerModel node, IProgressMonitor monitor, ICallback callback); + public void postAttachDebugger(IPeerNode node, IProgressMonitor monitor, ICallback callback); } /** @@ -72,7 +72,7 @@ public class StartDebuggerStep extends AbstractPeerModelStep { */ @Override public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { - final IPeerModel node = getActivePeerModelContext(context, data, fullQualifiedId); + final IPeerNode node = getActivePeerModelContext(context, data, fullQualifiedId); Assert.isNotNull(node); String value = getParameters().get("autoAttachAll"); //$NON-NLS-1$ final boolean autoAttachAll = value != null ? Boolean.parseBoolean(value) : false; @@ -82,14 +82,14 @@ public class StartDebuggerStep extends AbstractPeerModelStep { @Override public void run() { // Don't attach the debugger if no run control is provided by the target - final ILocatorModelPeerNodeQueryService queryService = node.getModel().getService(ILocatorModelPeerNodeQueryService.class); + final IPeerModelQueryService queryService = node.getModel().getService(IPeerModelQueryService.class); Assert.isNotNull(queryService); - queryService.queryServicesAsync(node, new ILocatorModelPeerNodeQueryService.DoneQueryServices() { + queryService.queryServicesAsync(node, new IPeerModelQueryService.DoneQueryServices() { @Override public void doneQueryServices(Throwable error) { if (error == null) { // Get the list of available remote services - String remoteServices = node.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES); + String remoteServices = node.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES); Assert.isNotNull(remoteServices); boolean canAttachDbg = false; StringTokenizer tokenizer = new StringTokenizer(remoteServices, ","); //$NON-NLS-1$ @@ -157,7 +157,7 @@ public class StartDebuggerStep extends AbstractPeerModelStep { */ @Override public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { - final IPeerModel node = getActivePeerModelContext(context, data, fullQualifiedId); + final IPeerNode node = getActivePeerModelContext(context, data, fullQualifiedId); IDebugService dbgService = ServiceManager.getInstance().getService(node, IDebugService.class, false); if (dbgService != null) { IPropertiesContainer props = new PropertiesContainer(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java index cde08c7d6..905d0830e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java @@ -21,7 +21,7 @@ import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; /** * Start simulator step implementation. */ -public class StartSimulatorStep extends AbstractPeerModelStep { +public class StartSimulatorStep extends AbstractPeerNodeStep { /** * Constructor. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java index 3fe928a33..d6ea6557c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java @@ -1,55 +1,55 @@ -/******************************************************************************* - * Copyright (c) 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.steps; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; -import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; -import org.eclipse.tcf.te.runtime.services.ServiceManager; -import org.eclipse.tcf.te.runtime.services.interfaces.IDebugService; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; - -/** - * Stop debugger step implementation. - */ -public class StopDebuggerStep extends AbstractPeerModelStep { - - /** - * Constructor. - */ - public StopDebuggerStep() { - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public void validateExecute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor) throws CoreException { - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) - */ - @Override - public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { - IDebugService dbgService = ServiceManager.getInstance().getService(getActivePeerModelContext(context, data, fullQualifiedId), IDebugService.class, false); - if (dbgService != null) { - IPropertiesContainer props = new PropertiesContainer(); - dbgService.detach(getActivePeerModelContext(context, data, fullQualifiedId), props, monitor, callback); - } - else { - callback.done(this, Status.OK_STATUS); - } - } -} +/******************************************************************************* + * Copyright (c) 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.steps; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; +import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.runtime.services.interfaces.IDebugService; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; + +/** + * Stop debugger step implementation. + */ +public class StopDebuggerStep extends AbstractPeerNodeStep { + + /** + * Constructor. + */ + public StopDebuggerStep() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void validateExecute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor) throws CoreException { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { + IDebugService dbgService = ServiceManager.getInstance().getService(getActivePeerModelContext(context, data, fullQualifiedId), IDebugService.class, false); + if (dbgService != null) { + IPropertiesContainer props = new PropertiesContainer(); + dbgService.detach(getActivePeerModelContext(context, data, fullQualifiedId), props, monitor, callback); + } + else { + callback.done(this, Status.OK_STATUS); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java index 3edf32507..0f91d460a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java @@ -1,45 +1,45 @@ -/******************************************************************************* - * Copyright (c) 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.locator.steps; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; -import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; - -/** - * Stop simulator step implementation. - */ -public class StopSimulatorStep extends AbstractPeerModelStep { - - /** - * Constructor. - */ - public StopSimulatorStep() { - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public void validateExecute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor) throws CoreException { - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) - */ - @Override - public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { - SimulatorUtils.stop(getActivePeerModelContext(context, data, fullQualifiedId), monitor, callback); - } -} +/******************************************************************************* + * Copyright (c) 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.steps; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; + +/** + * Stop simulator step implementation. + */ +public class StopSimulatorStep extends AbstractPeerNodeStep { + + /** + * Constructor. + */ + public StopSimulatorStep() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void validateExecute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor) throws CoreException { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { + SimulatorUtils.stop(getActivePeerModelContext(context, data, fullQualifiedId), monitor, callback); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java index d5e635fe1..f1c79cc7a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java @@ -27,13 +27,13 @@ import org.eclipse.tcf.te.runtime.utils.ProgressHelper; import org.eclipse.tcf.te.runtime.utils.StatusHelper; import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.nls.Messages; /** * WaitForReadyStep */ -public class WaitForReadyStep extends AbstractPeerModelStep { +public class WaitForReadyStep extends AbstractPeerNodeStep { /** * Constructor. @@ -53,9 +53,9 @@ public class WaitForReadyStep extends AbstractPeerModelStep { */ @Override public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { - final IPeerModel peerModel = getActivePeerModelContext(context, data, fullQualifiedId); + final IPeerNode peerNode = getActivePeerModelContext(context, data, fullQualifiedId); - if (peerModel != null && !Boolean.getBoolean("WaitForReadyStep.skip")) { //$NON-NLS-1$ + if (peerNode != null && !Boolean.getBoolean("WaitForReadyStep.skip")) { //$NON-NLS-1$ Protocol.invokeLater(new Runnable() { final Runnable thisRunnable = this; int refreshCount = 0; @@ -71,7 +71,7 @@ public class WaitForReadyStep extends AbstractPeerModelStep { } else { // Try to open a channel to the target and check for errors - Tcf.getChannelManager().openChannel(peerModel.getPeer(), null, new IChannelManager.DoneOpenChannel() { + Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, new IChannelManager.DoneOpenChannel() { @Override public void doneOpenChannel(final Throwable error, final IChannel channel) { if (ProgressHelper.isCancel(WaitForReadyStep.this, monitor, callback)) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java index c58c09538..e9a3520f8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java @@ -23,8 +23,8 @@ import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IService; import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; /** * Simulator related utilities. @@ -43,18 +43,18 @@ public final class SimulatorUtils { /** * Returns if or if the given peer model has the simulator enabled or not. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @return True if the simulator is enabled, false otherwise. */ - public static boolean isSimulatorEnabled(final IPeerModel peerModel) { - Assert.isNotNull(peerModel); + public static boolean isSimulatorEnabled(final IPeerNode peerNode) { + Assert.isNotNull(peerNode); final AtomicBoolean isEnabled = new AtomicBoolean(false); Runnable runnable = new Runnable() { @Override public void run() { - String value = peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_ENABLED); + String value = peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_ENABLED); if (value != null) { isEnabled.set(Boolean.parseBoolean(value)); } @@ -72,11 +72,11 @@ public final class SimulatorUtils { * If no simulator service is configured in the peer * or the configured service is not available, null will be returned. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @return The {@link Result} containing the simulator service and the settings or null. */ - public static Result getSimulatorService(final IPeerModel peerModel) { - Assert.isNotNull(peerModel); + public static Result getSimulatorService(final IPeerNode peerNode) { + Assert.isNotNull(peerNode); final AtomicBoolean isEnabled = new AtomicBoolean(false); final AtomicReference type = new AtomicReference(); @@ -85,13 +85,13 @@ public final class SimulatorUtils { Runnable runnable = new Runnable() { @Override public void run() { - String value = peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_ENABLED); + String value = peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_ENABLED); if (value != null) { isEnabled.set(Boolean.parseBoolean(value)); } - type.set(peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_TYPE)); - properties.set(peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_PROPERTIES)); + type.set(peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_TYPE)); + properties.set(peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_PROPERTIES)); } }; @@ -101,7 +101,7 @@ public final class SimulatorUtils { Result result = null; if (isEnabled.get()) { - IService[] services = ServiceManager.getInstance().getServices(peerModel, ISimulatorService.class, false); + IService[] services = ServiceManager.getInstance().getServices(peerNode, ISimulatorService.class, false); for (IService service : services) { Assert.isTrue(service instanceof ISimulatorService); // Get the UI service which is associated with the simulator service @@ -123,25 +123,25 @@ public final class SimulatorUtils { * model node and the configured simulator service type is available. In any * other cases, the given callback is invoked immediately. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @param monitor The progress monitor. * @param callback The callback to invoke if finished. Must not be null. */ - public static void start(final IPeerModel peerModel, final IProgressMonitor monitor, final ICallback callback) { - Assert.isNotNull(peerModel); + public static void start(final IPeerNode peerNode, final IProgressMonitor monitor, final ICallback callback) { + Assert.isNotNull(peerNode); Assert.isNotNull(callback); // Determine if we have to start a simulator first - final Result result = getSimulatorService(peerModel); + final Result result = getSimulatorService(peerNode); if (result != null && result.service != null) { // Check if the simulator is already running - result.service.isRunning(peerModel, result.settings, new Callback() { + result.service.isRunning(peerNode, result.settings, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { Object cbResult = getResult(); if (cbResult instanceof Boolean && !((Boolean)cbResult).booleanValue()) { // Start the simulator - result.service.start(peerModel, result.settings, new Callback() { + result.service.start(peerNode, result.settings, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { callback.setResult(new Boolean(status.isOK())); @@ -165,25 +165,25 @@ public final class SimulatorUtils { * model node and the configured simulator service type is available. In any * other cases, the given callback is invoked immediately. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @param monitor The progress monitor. * @param callback The callback to invoke if finished. Must not be null. */ - public static void stop(final IPeerModel peerModel, final IProgressMonitor monitor, final ICallback callback) { - Assert.isNotNull(peerModel); + public static void stop(final IPeerNode peerNode, final IProgressMonitor monitor, final ICallback callback) { + Assert.isNotNull(peerNode); Assert.isNotNull(callback); // Get the associated simulator service - final Result result = getSimulatorService(peerModel); + final Result result = getSimulatorService(peerNode); if (result != null && result.service != null) { // Determine if the simulator is at all running - result.service.isRunning(peerModel, result.settings, new Callback() { + result.service.isRunning(peerNode, result.settings, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { Object cbResult = getResult(); if (cbResult instanceof Boolean && ((Boolean)cbResult).booleanValue()) { // Stop the simulator - result.service.stop(peerModel, result.settings, new Callback(callback) { + result.service.stop(peerNode, result.settings, new Callback(callback) { @Override protected void internalDone(Object caller, IStatus status) { callback.done(caller, status); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/activator/CoreBundleActivator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/activator/CoreBundleActivator.java index aed90e597..855302f66 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/activator/CoreBundleActivator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/activator/CoreBundleActivator.java @@ -1,121 +1,121 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.processes.core.activator; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.runtime.tracing.TraceHandler; -import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.model.Model; -import org.eclipse.tcf.te.tcf.processes.core.model.listener.ModelListener; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class CoreBundleActivator extends Plugin { - // The bundle context - private static BundleContext context; - // The trace handler instance - private static volatile TraceHandler traceHandler; - // The locator model listener instance - /* default */ IModelListener listener; - - // The shared instance - private static CoreBundleActivator plugin; - - /** - * Returns the bundle context - * - * @return the bundle context - */ - public static BundleContext getContext() { - return context; - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static CoreBundleActivator getDefault() { - return plugin; - } - - /** - * Convenience method which returns the unique identifier of this plugin. - */ - public static String getUniqueIdentifier() { - if (getContext() != null && getContext().getBundle() != null) { - return getContext().getBundle().getSymbolicName(); - } - return "org.eclipse.tcf.te.tcf.processes.core"; //$NON-NLS-1$ - } - - /** - * Returns the bundles trace handler. - * - * @return The bundles trace handler. - */ - public static TraceHandler getTraceHandler() { - if (traceHandler == null) { - traceHandler = new TraceHandler(getUniqueIdentifier()); - } - return traceHandler; - } - - /* (non-Javadoc) - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext bundleContext) throws Exception { - CoreBundleActivator.context = bundleContext; - plugin = this; - - // Create the model listener instance - listener = new ModelListener(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - if (listener == null) return; - // Register the model listener with the locator model - Model.getModel().addListener(listener); - } - }; - - Protocol.invokeLater(runnable); - } - - /* (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext bundleContext) throws Exception { - CoreBundleActivator.context = null; - plugin = null; - - // Remove the model listener from the locator model - if (listener != null) { - Runnable runnable = new Runnable() { - @Override - public void run() { - ILocatorModel model = Model.getModel(true); - if (model != null) model.removeListener(listener); - listener = null; - } - }; - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - } - } - -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.processes.core.activator; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.runtime.tracing.TraceHandler; +import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.model.Model; +import org.eclipse.tcf.te.tcf.processes.core.model.listener.ModelListener; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class CoreBundleActivator extends Plugin { + // The bundle context + private static BundleContext context; + // The trace handler instance + private static volatile TraceHandler traceHandler; + // The locator model listener instance + /* default */ IModelListener listener; + + // The shared instance + private static CoreBundleActivator plugin; + + /** + * Returns the bundle context + * + * @return the bundle context + */ + public static BundleContext getContext() { + return context; + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static CoreBundleActivator getDefault() { + return plugin; + } + + /** + * Convenience method which returns the unique identifier of this plugin. + */ + public static String getUniqueIdentifier() { + if (getContext() != null && getContext().getBundle() != null) { + return getContext().getBundle().getSymbolicName(); + } + return "org.eclipse.tcf.te.tcf.processes.core"; //$NON-NLS-1$ + } + + /** + * Returns the bundles trace handler. + * + * @return The bundles trace handler. + */ + public static TraceHandler getTraceHandler() { + if (traceHandler == null) { + traceHandler = new TraceHandler(getUniqueIdentifier()); + } + return traceHandler; + } + + /* (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext bundleContext) throws Exception { + CoreBundleActivator.context = bundleContext; + plugin = this; + + // Create the model listener instance + listener = new ModelListener(); + + Runnable runnable = new Runnable() { + @Override + public void run() { + if (listener == null) return; + // Register the model listener with the locator model + Model.getModel().addListener(listener); + } + }; + + Protocol.invokeLater(runnable); + } + + /* (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext bundleContext) throws Exception { + CoreBundleActivator.context = null; + plugin = null; + + // Remove the model listener from the locator model + if (listener != null) { + Runnable runnable = new Runnable() { + @Override + public void run() { + IPeerModel model = Model.getModel(true); + if (model != null) model.removeListener(listener); + listener = null; + } + }; + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); + } + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/ModelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/ModelManager.java index e323927ef..ac5850b73 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/ModelManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/ModelManager.java @@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.Assert; import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.core.model.runtime.RuntimeModel; @@ -31,11 +31,11 @@ public class ModelManager { *

* If not yet initialized, a new runtime model will be initialized before returning. * - * @param peerModel The peer model instance. Must not be null. + * @param peerNode The peer model instance. Must not be null. * @return The runtime model. */ - public static IRuntimeModel getRuntimeModel(final IPeerModel peerModel) { - Assert.isNotNull(peerModel); + public static IRuntimeModel getRuntimeModel(final IPeerNode peerNode) { + Assert.isNotNull(peerNode); // The result reference holder final AtomicReference runtimeModel = new AtomicReference(); @@ -47,12 +47,12 @@ public class ModelManager { Assert.isTrue(Protocol.isDispatchThread()); // Get the peer id - String id = peerModel.getPeerId(); + String id = peerNode.getPeerId(); // Lookup the runtime model instance IRuntimeModel candidate = runtimeModels.get(id); // Initialize a new runtime model instance if necessary if (candidate == null) { - candidate = initializeRuntimeModel(peerModel); + candidate = initializeRuntimeModel(peerNode); if (candidate != null) runtimeModels.put(id, candidate); } // Store to the result reference holder @@ -72,22 +72,22 @@ public class ModelManager { *

* Must be called within the TCF dispatch thread. * - * @param peerModel The peer model instance. Must not be null. + * @param peerNode The peer model instance. Must not be null. * @return The runtime model. */ - protected static IRuntimeModel initializeRuntimeModel(IPeerModel peerModel) { + protected static IRuntimeModel initializeRuntimeModel(IPeerNode peerNode) { Assert.isTrue(Protocol.isDispatchThread()); - IRuntimeModel runtimeModel = new RuntimeModel(peerModel); + IRuntimeModel runtimeModel = new RuntimeModel(peerNode); return runtimeModel; } /** * Dispose the runtime model. * - * @param peerModel The peer model instance. Must not be null. + * @param peerNode The peer model instance. Must not be null. */ - public static void disposeRuntimeModel(final IPeerModel peerModel) { - Assert.isNotNull(peerModel); + public static void disposeRuntimeModel(final IPeerNode peerNode) { + Assert.isNotNull(peerNode); Runnable runnable = new Runnable() { @Override @@ -95,7 +95,7 @@ public class ModelManager { Assert.isTrue(Protocol.isDispatchThread()); // Get the peer id - String id = peerModel.getPeerId(); + String id = peerNode.getPeerId(); // Lookup the runtime model instance IRuntimeModel candidate = runtimeModels.remove(id); // Dispose it diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/interfaces/runtime/IRuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/interfaces/runtime/IRuntimeModel.java index a4c7fa33c..202fb645d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/interfaces/runtime/IRuntimeModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/interfaces/runtime/IRuntimeModel.java @@ -10,7 +10,7 @@ package org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime; import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; /** @@ -22,7 +22,7 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; *

* All model access must happen in the TCF dispatch thread. */ -public interface IRuntimeModel extends IModel, IPeerModelProvider { +public interface IRuntimeModel extends IModel, IPeerNodeProvider { /** * Set the auto-refresh interval in seconds. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/listener/ModelListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/listener/ModelListener.java index e5d979468..216609e9d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/listener/ModelListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/listener/ModelListener.java @@ -11,8 +11,8 @@ package org.eclipse.tcf.te.tcf.processes.core.model.listener; import org.eclipse.core.runtime.Assert; import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter; import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager; @@ -22,10 +22,10 @@ import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager; public class ModelListener extends ModelAdapter { /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, boolean) + * @see org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean) */ @Override - public void locatorModelChanged(ILocatorModel model, IPeerModel peer, boolean added) { + public void locatorModelChanged(IPeerModel model, IPeerNode peer, boolean added) { Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ if (peer == null) return; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/nodes/ProcessContextNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/nodes/ProcessContextNode.java index 0dc33b65f..2bf003277 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/nodes/ProcessContextNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/nodes/ProcessContextNode.java @@ -25,15 +25,15 @@ import org.eclipse.tcf.te.runtime.model.interfaces.contexts.IAsyncRefreshableCtx import org.eclipse.tcf.te.runtime.model.interfaces.contexts.IAsyncRefreshableCtx.QueryState; import org.eclipse.tcf.te.runtime.model.interfaces.contexts.IAsyncRefreshableCtx.QueryType; import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNodeProperties; /** * A process context node implementation. */ -public class ProcessContextNode extends ContainerModelNode implements IProcessContextNode, IPeerModelProvider, IFilterable { +public class ProcessContextNode extends ContainerModelNode implements IProcessContextNode, IPeerNodeProvider, IFilterable { // Reference to the agent side process context object private IProcesses.ProcessContext pContext = null; // Reference to the agent side system monitor context object @@ -156,11 +156,11 @@ public class ProcessContextNode extends ContainerModelNode implements IProcessCo } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider#getPeerModel() + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider#getPeerModel() */ @Override - public IPeerModel getPeerModel() { - return (IPeerModel)getAdapter(IPeerModel.class); + public IPeerNode getPeerModel() { + return (IPeerNode)getAdapter(IPeerNode.class); } /* (non-Javadoc) @@ -224,13 +224,13 @@ public class ProcessContextNode extends ContainerModelNode implements IProcessCo if (ISysMonitor.SysMonitorContext.class.isAssignableFrom(adapter)) { return sContext; } - if (IPeerModelProvider.class.isAssignableFrom(adapter)) { + if (IPeerNodeProvider.class.isAssignableFrom(adapter)) { IModel model = getParent(IModel.class); - if (model instanceof IPeerModelProvider) return model; + if (model instanceof IPeerNodeProvider) return model; } - if (IPeerModel.class.isAssignableFrom(adapter)) { + if (IPeerNode.class.isAssignableFrom(adapter)) { IModel model = getParent(IModel.class); - if (model instanceof IPeerModelProvider) return ((IPeerModelProvider)model).getPeerModel(); + if (model instanceof IPeerNodeProvider) return ((IPeerNodeProvider)model).getPeerModel(); } if (IAsyncRefreshableCtx.class.isAssignableFrom(adapter)) { return refreshableCtxAdapter; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/RuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/RuntimeModel.java index 384a785bd..5bccafe5a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/RuntimeModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/RuntimeModel.java @@ -29,7 +29,7 @@ import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelLookupService import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelRefreshService; import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelService; import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelUpdateService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModelLookupService; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModelRefreshService; @@ -51,7 +51,7 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo private IFactory factory = null; // Reference to the associated peer model - private final IPeerModel peerModel; + private final IPeerNode peerNode; // Reference to the refresh service private final IRuntimeModelRefreshService refreshService = new RuntimeModelRefreshService(this); @@ -73,17 +73,17 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo /** * Constructor. * - * @param peerModel The peerModel to associated. Must not be null. + * @param peerNode The peerNode to associated. Must not be null. */ - public RuntimeModel(IPeerModel peerModel) { + public RuntimeModel(IPeerNode peerNode) { super(); disposed = false; setChangeEventsEnabled(true); suppressEventsOnNullParent = false; - Assert.isNotNull(peerModel); - this.peerModel = peerModel; + Assert.isNotNull(peerNode); + this.peerNode = peerNode; // No initial context query required refreshableCtxAdapter.setQueryState(QueryType.CONTEXT, QueryState.DONE); @@ -180,12 +180,12 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider#getPeerModel() + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider#getPeerModel() */ @Override - public IPeerModel getPeerModel() { + public IPeerNode getPeerModel() { Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ - return peerModel; + return peerNode; } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java index 7ed2fdf3d..14f2887e0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/services/RuntimeModelChannelService.java @@ -19,7 +19,7 @@ import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelChannelService; import org.eclipse.tcf.te.tcf.core.model.services.AbstractModelService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.core.model.runtime.listener.RuntimeModelProcessServiceListener; import org.eclipse.tcf.te.tcf.processes.core.model.runtime.listener.RuntimeModelRunControlServiceListener; @@ -67,7 +67,7 @@ public class RuntimeModelChannelService extends AbstractModelService * Note: This method must be called from within the TCF dispatch thread. * - * @param peerModel The peer model. Must not be null. + * @param peerNode The peer model. Must not be null. * @param nodes The list of process context nodes. Must not be null. * @param callback The callback to invoke once the operation completed, ornull. */ - public void executeAttach(final IPeerModel peerModel, final IProcessContextNode[] nodes, final ICallback callback) { + public void executeAttach(final IPeerNode peerNode, final IProcessContextNode[] nodes, final ICallback callback) { Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(peerModel); + Assert.isNotNull(peerNode); Assert.isNotNull(nodes); // Determine if we have to execute the attach at all final List nodesToAttach = new ArrayList(); for (IProcessContextNode node : nodes) { - IPeerModel parentPeerModel = (IPeerModel)node.getAdapter(IPeerModel.class); - if (!peerModel.equals(parentPeerModel)) continue; + IPeerNode parentPeerModel = (IPeerNode)node.getAdapter(IPeerNode.class); + if (!peerNode.equals(parentPeerModel)) continue; // If not yet attached, we have to attach to it if (node.getProcessContext() != null && !node.getProcessContext().isAttached()) { @@ -78,17 +78,17 @@ public class AttachStep { // Anything to attach? if (!nodesToAttach.isEmpty()) { // Determine the debug service to attach to the peer node - IDebugService dbgService = ServiceManager.getInstance().getService(peerModel, IDebugService.class, false); + IDebugService dbgService = ServiceManager.getInstance().getService(peerNode, IDebugService.class, false); if (dbgService != null) { // Attach to the peer node first - dbgService.attach(peerModel, new PropertiesContainer(), null, new Callback() { + dbgService.attach(peerNode, new PropertiesContainer(), null, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { callback.setProperty("launch", getProperty("launch")); //$NON-NLS-1$ //$NON-NLS-2$ Runnable runnable = new Runnable() { @Override public void run() { - doAttach(peerModel, Collections.unmodifiableList(nodesToAttach), callback); + doAttach(peerNode, Collections.unmodifiableList(nodesToAttach), callback); } }; if (Protocol.isDispatchThread()) runnable.run(); @@ -96,7 +96,7 @@ public class AttachStep { } }); } else { - doAttach(peerModel, Collections.unmodifiableList(nodesToAttach), callback); + doAttach(peerNode, Collections.unmodifiableList(nodesToAttach), callback); } } else { onDone(callback); @@ -109,19 +109,19 @@ public class AttachStep { *

* Note: This method must be called from within the TCF dispatch thread. * - * @param peerModel The peer model. Must not be null. + * @param peerNode The peer model. Must not be null. * @param nodes The process context node. Must not be null. * @param callback The callback to invoke once the operation completed, ornull. */ - protected void doAttach(final IPeerModel peerModel, final List nodes, final ICallback callback) { + protected void doAttach(final IPeerNode peerNode, final List nodes, final ICallback callback) { Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(peerModel); + Assert.isNotNull(peerNode); Assert.isNotNull(nodes); // Loop the nodes and attach to them if (!nodes.isEmpty()) { // Open a channel - Tcf.getChannelManager().openChannel(peerModel.getPeer(), null, new IChannelManager.DoneOpenChannel() { + Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, new IChannelManager.DoneOpenChannel() { @Override public void doneOpenChannel(final Throwable error, final IChannel channel) { if (error == null) { @@ -132,7 +132,7 @@ public class AttachStep { @Override protected void internalDone(Object caller, IStatus status) { if (status.getSeverity() == IStatus.ERROR) { - onError(peerModel, status.getMessage(), status.getException(), callback); + onError(peerNode, status.getMessage(), status.getException(), callback); } else { onDone(callback); } @@ -177,10 +177,10 @@ public class AttachStep { // Mark the collector initialization done collector.initDone(); } else { - onError(peerModel, NLS.bind(Messages.AttachStep_error_missingService, peerModel.getName()), null, callback); + onError(peerNode, NLS.bind(Messages.AttachStep_error_missingService, peerNode.getName()), null, callback); } } else { - onError(peerModel, NLS.bind(Messages.AttachStep_error_openChannel, peerModel.getName()), error, callback); + onError(peerNode, NLS.bind(Messages.AttachStep_error_openChannel, peerNode.getName()), error, callback); } } }); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/steps/DetachStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/steps/DetachStep.java index 3d43b7a1a..9313cea9f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/steps/DetachStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/steps/DetachStep.java @@ -30,7 +30,7 @@ import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel; import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.activator.CoreBundleActivator; import org.eclipse.tcf.te.tcf.processes.core.interfaces.IContextHelpIds; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; @@ -55,7 +55,7 @@ public class DetachStep { // If the context is not attached, there is nothing to do if (node.getProcessContext() != null && node.getProcessContext().isAttached()) { - IPeerModel peerNode = (IPeerModel)node.getAdapter(IPeerModel.class); + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); if (peerNode != null) { doDetach(node, callback); } else { @@ -84,7 +84,7 @@ public class DetachStep { Assert.isNotNull(node); // Determine the peer model node - final IPeerModel peerNode = (IPeerModel)node.getAdapter(IPeerModel.class); + final IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); // Open a channel Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, new IChannelManager.DoneOpenChannel() { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/steps/TerminateStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/steps/TerminateStep.java index c3534d7ff..d5bc4f9c8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/steps/TerminateStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/steps/TerminateStep.java @@ -27,7 +27,7 @@ import org.eclipse.tcf.te.runtime.statushandler.interfaces.IStatusHandler; import org.eclipse.tcf.te.runtime.statushandler.interfaces.IStatusHandlerConstants; import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.activator.CoreBundleActivator; import org.eclipse.tcf.te.tcf.processes.core.interfaces.IContextHelpIds; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; @@ -52,7 +52,7 @@ public class TerminateStep { // If the context is not attached, there is nothing to do if (node.getProcessContext() != null) { - IPeerModel peerNode = (IPeerModel)node.getAdapter(IPeerModel.class); + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); if (peerNode != null) { doTerminate(node, callback); } else { @@ -78,7 +78,7 @@ public class TerminateStep { Assert.isNotNull(node); // Determine the peer model node - final IPeerModel peerNode = (IPeerModel)node.getAdapter(IPeerModel.class); + final IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); // Open a channel Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, new IChannelManager.DoneOpenChannel() { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml index 0d976fc89..ae462b3cc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml @@ -8,7 +8,7 @@ adaptableType="org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode" class="org.eclipse.tcf.te.tcf.processes.ui.internal.adapters.AdapterFactory"> - + @@ -56,7 +56,7 @@ id="org.eclipse.tcf.te.tcf.processes.ui.properties" namespace="processMonitor.delegatedActivation" properties="isColumnActive,isFilterActive" - type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"> + type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"> @@ -86,7 +86,7 @@ - + @@ -154,7 +154,7 @@ - + @@ -182,7 +182,7 @@ - + - + - + - + - + @@ -657,7 +657,7 @@ width="50"> - + @@ -673,7 +673,7 @@ width="50"> - + @@ -689,7 +689,7 @@ width="50"> - + @@ -705,7 +705,7 @@ width="50"> - + @@ -721,7 +721,7 @@ width="100"> - + @@ -738,7 +738,7 @@ name="%singlethreadfilter.name"> - + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java index 27ec2b409..8e6aca1a1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java @@ -20,7 +20,7 @@ import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.tcf.te.runtime.events.ChangeEvent; import org.eclipse.tcf.te.runtime.events.EventManager; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager; import org.eclipse.tcf.te.tcf.processes.ui.navigator.events.TreeViewerListener; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; @@ -176,10 +176,10 @@ public class ProcessMonitorEditorPage extends TreeViewerExplorerEditorPage { @Override protected Object getViewerInput() { Object element = getEditorInputNode(); - IPeerModel peerModel = element instanceof IPeerModel ? (IPeerModel)element : null; - if (peerModel == null && element instanceof IAdaptable) { - peerModel = (IPeerModel)((IAdaptable)element).getAdapter(IPeerModel.class); + IPeerNode peerNode = element instanceof IPeerNode ? (IPeerNode)element : null; + if (peerNode == null && element instanceof IAdaptable) { + peerNode = (IPeerNode)((IAdaptable)element).getAdapter(IPeerNode.class); } - return peerModel != null ? ModelManager.getRuntimeModel(peerModel) : null; + return peerNode != null ? ModelManager.getRuntimeModel(peerNode) : null; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/ContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/ContentProvider.java index e854ae43b..c579540df 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/ContentProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/ContentProvider.java @@ -10,7 +10,7 @@ package org.eclipse.tcf.te.tcf.processes.ui.editor.tree; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; @@ -19,15 +19,15 @@ import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeMo */ public class ContentProvider extends org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.ContentProvider { // The target's peer model. - private IPeerModel peerModel; + private IPeerNode peerNode; /* (non-Javadoc) * @see org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.ContentProvider#dispose() */ @Override public void dispose() { - if (peerModel != null) { - IRuntimeModel model = ModelManager.getRuntimeModel(peerModel); + if (peerNode != null) { + IRuntimeModel model = ModelManager.getRuntimeModel(peerNode); if (model != null && model.getAutoRefreshInterval() > 0) { // If the model is auto refreshing, then stop it when the editor is disposed. model.setAutoRefreshInterval(0); @@ -41,8 +41,8 @@ public class ContentProvider extends org.eclipse.tcf.te.tcf.processes.ui.navigat @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { super.inputChanged(viewer, oldInput, newInput); - if (newInput instanceof IPeerModel) { - peerModel = (IPeerModel) newInput; + if (newInput instanceof IPeerNode) { + peerNode = (IPeerNode) newInput; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PIDLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PIDLabelProvider.java index 3a65a5bdd..c1a12491e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PIDLabelProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PIDLabelProvider.java @@ -15,7 +15,7 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IPendingOperationNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; @@ -55,9 +55,9 @@ public class PIDLabelProvider extends AbstractLabelProviderDelegate { String id = pid.get() >= 0 ? Long.toString(pid.get()) : ""; //$NON-NLS-1$ if (id.startsWith("P")) id = id.substring(1); //$NON-NLS-1$ - IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class); - IUIService service = peerModel != null ? ServiceManager.getInstance().getService(peerModel, IUIService.class) : null; - IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerModel, IProcessMonitorUIDelegate.class) : null; + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); + IUIService service = peerNode != null ? ServiceManager.getInstance().getService(peerNode, IUIService.class) : null; + IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerNode, IProcessMonitorUIDelegate.class) : null; String newId = delegate != null ? delegate.getText(element, "PID", id) : null; //$NON-NLS-1$ return newId != null ? newId : id; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java index 184cad8c5..2cb8a8769 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java @@ -15,7 +15,7 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IPendingOperationNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; @@ -53,9 +53,9 @@ public class PPIDLabelProvider extends AbstractLabelProviderDelegate { String id = ppid.get() >= 0 ? Long.toString(ppid.get()) : ""; //$NON-NLS-1$ - IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class); - IUIService service = peerModel != null ? ServiceManager.getInstance().getService(peerModel, IUIService.class) : null; - IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerModel, IProcessMonitorUIDelegate.class) : null; + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); + IUIService service = peerNode != null ? ServiceManager.getInstance().getService(peerNode, IUIService.class) : null; + IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerNode, IProcessMonitorUIDelegate.class) : null; String newId = delegate != null ? delegate.getText(element, "PPID", id) : null; //$NON-NLS-1$ return newId != null ? newId : id; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachHandler.java index 88c076a9c..c0004f7dd 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachHandler.java @@ -24,7 +24,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.callback.Callback; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.core.model.steps.AttachStep; import org.eclipse.ui.handlers.HandlerUtil; @@ -67,18 +67,18 @@ public class AttachHandler extends AbstractHandler { Assert.isNotNull(selection); // Analyze the selection and collect all nodes per parent peer model node. - final Map> contexts = new HashMap>(); + final Map> contexts = new HashMap>(); Iterator iterator = selection.iterator(); while (iterator.hasNext()) { Object candidate = iterator.next(); if (candidate instanceof IProcessContextNode) { IProcessContextNode node = (IProcessContextNode)candidate; - IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class); - if (peerModel != null) { - List nodes = contexts.get(peerModel); + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); + if (peerNode != null) { + List nodes = contexts.get(peerNode); if (nodes == null) { nodes = new ArrayList(); - contexts.put(peerModel, nodes); + contexts.put(peerNode, nodes); } if (!nodes.contains(node)) nodes.add(node); } @@ -87,10 +87,10 @@ public class AttachHandler extends AbstractHandler { // If not empty, attach to all nodes of the original selection per parent peer model node. if (!contexts.isEmpty()) { - for (Entry> entry : contexts.entrySet()) { - IPeerModel peerModel = entry.getKey(); + for (Entry> entry : contexts.entrySet()) { + IPeerNode peerNode = entry.getKey(); List nodes = entry.getValue(); - doAttach(event, peerModel, nodes.toArray(new IProcessContextNode[nodes.size()])); + doAttach(event, peerNode, nodes.toArray(new IProcessContextNode[nodes.size()])); } } } @@ -103,14 +103,14 @@ public class AttachHandler extends AbstractHandler { * @param event The execution event. * @param nodes The list of process context nodes. Must not be null. */ - protected void doAttach(final ExecutionEvent event, final IPeerModel peerModel, final IProcessContextNode[] nodes) { + protected void doAttach(final ExecutionEvent event, final IPeerNode peerNode, final IProcessContextNode[] nodes) { Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(peerModel); + Assert.isNotNull(peerNode); Assert.isNotNull(nodes); if (nodes.length > 0) { AttachStep step = new AttachStep(); - step.executeAttach(peerModel, nodes, new Callback()); + step.executeAttach(peerNode, nodes, new Callback()); } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigIntervalDynamicContribution.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigIntervalDynamicContribution.java index 8392909a4..39546dc3c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigIntervalDynamicContribution.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigIntervalDynamicContribution.java @@ -25,7 +25,7 @@ import org.eclipse.jface.action.Separator; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.SafeRunnable; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.ui.activator.UIPlugin; @@ -174,10 +174,10 @@ public class ConfigIntervalDynamicContribution extends CompoundContributionItem @Override protected IContributionItem[] getContributionItems() { IEditorInput editorInput = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput(); - IPeerModel peerModel = (IPeerModel) editorInput.getAdapter(IPeerModel.class); + IPeerNode peerNode = (IPeerNode) editorInput.getAdapter(IPeerNode.class); List items = new ArrayList(); - if (peerModel != null) { - IRuntimeModel model = ModelManager.getRuntimeModel(peerModel); + if (peerNode != null) { + IRuntimeModel model = ModelManager.getRuntimeModel(peerNode); List groupItems = createGradeActions(model); if(!groupItems.isEmpty()) { items.addAll(groupItems); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java index 36b0285ee..f8194cf99 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java @@ -14,7 +14,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs.IntervalConfigDialog; @@ -33,7 +33,7 @@ public class ConfigRefreshIntervalHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorInput editorInput = HandlerUtil.getActiveEditorInputChecked(event); - IPeerModel peer = (IPeerModel) editorInput.getAdapter(IPeerModel.class); + IPeerNode peer = (IPeerNode) editorInput.getAdapter(IPeerNode.class); if (peer != null) { Shell parent = HandlerUtil.getActiveShellChecked(event); IntervalConfigDialog dialog = new IntervalConfigDialog(peer, parent); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/EditorHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/EditorHandlerDelegate.java index 10d56d09d..60b6787b2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/EditorHandlerDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/EditorHandlerDelegate.java @@ -15,7 +15,7 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.ui.editor.ProcessMonitorEditorPage; -import org.eclipse.tcf.te.tcf.ui.handler.AbstractPeerModelEditorHandlerDelegate; +import org.eclipse.tcf.te.tcf.ui.handler.AbstractPeerNodeEditorHandlerDelegate; import org.eclipse.tcf.te.ui.swt.DisplayUtil; import org.eclipse.tcf.te.ui.views.editor.Editor; import org.eclipse.ui.IEditorPart; @@ -25,7 +25,7 @@ import org.eclipse.ui.forms.editor.IFormPage; /** * Processes properties command handler implementation. */ -public class EditorHandlerDelegate extends AbstractPeerModelEditorHandlerDelegate { +public class EditorHandlerDelegate extends AbstractPeerNodeEditorHandlerDelegate { /* (non-Javadoc) * @see org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate#postOpenProperties(org.eclipse.ui.IEditorPart, java.lang.Object) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java index e398ea4b9..968c48fb5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java @@ -24,7 +24,7 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel; import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager; import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate; import org.eclipse.ui.IEditorInput; @@ -47,7 +47,7 @@ public class RefreshProcessListHandler extends AbstractHandler implements IEleme @Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorInput editorInput = HandlerUtil.getActiveEditorInputChecked(event); - final IPeerModel peer = (IPeerModel) editorInput.getAdapter(IPeerModel.class); + final IPeerNode peer = (IPeerNode) editorInput.getAdapter(IPeerNode.class); if (peer != null) { BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), new Runnable() { @Override @@ -85,7 +85,7 @@ public class RefreshProcessListHandler extends AbstractHandler implements IEleme IWorkbenchPart part = site.getPart(); if (part instanceof IEditorPart) { IEditorInput editorInput = ((IEditorPart)part).getEditorInput(); - IPeerModel node = editorInput != null ? (IPeerModel) editorInput.getAdapter(IPeerModel.class) : null; + IPeerNode node = editorInput != null ? (IPeerNode) editorInput.getAdapter(IPeerNode.class) : null; IUIService service = ServiceManager.getInstance().getService(node, IUIService.class); IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(node, IProcessMonitorUIDelegate.class) : null; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java index e111f41e5..c39ef8a7a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java @@ -27,7 +27,7 @@ import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel; import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelUpdateService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.core.model.steps.TerminateStep; import org.eclipse.tcf.te.tcf.processes.ui.help.IContextHelpIds; @@ -97,7 +97,7 @@ public class TerminateHandler extends AbstractHandler implements IElementUpdater IWorkbenchPart part = site.getPart(); if (part instanceof IEditorPart) { IEditorInput editorInput = ((IEditorPart)part).getEditorInput(); - IPeerModel node = editorInput != null ? (IPeerModel) editorInput.getAdapter(IPeerModel.class) : null; + IPeerNode node = editorInput != null ? (IPeerNode) editorInput.getAdapter(IPeerNode.class) : null; IUIService service = ServiceManager.getInstance().getService(node, IUIService.class); IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(node, IProcessMonitorUIDelegate.class) : null; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/interfaces/IProcessMonitorUIDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/interfaces/IProcessMonitorUIDelegate.java index 677e4105d..bb0acbe7e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/interfaces/IProcessMonitorUIDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/interfaces/IProcessMonitorUIDelegate.java @@ -9,7 +9,7 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.processes.ui.interfaces; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.interfaces.ISearchable; @@ -65,5 +65,5 @@ public interface IProcessMonitorUIDelegate { * @param node The peer model node context. Must not be null. * @return The list of searchables to use or null. */ - public ISearchable[] getSearchables(IPeerModel node); + public ISearchable[] getSearchables(IPeerNode node); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java index e26b1cc9c..b4c6ca5b7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java @@ -14,7 +14,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.LabelProviderDelegate; @@ -30,7 +30,7 @@ public class AdapterFactory implements IAdapterFactory { private static final Class[] CLASSES = new Class[] { ILabelProvider.class, - IPeerModel.class, + IPeerNode.class, ISearchable.class }; @@ -43,17 +43,17 @@ public class AdapterFactory implements IAdapterFactory { if (ILabelProvider.class.equals(adapterType)) { return labelProvider; } - if (IPeerModel.class.equals(adapterType)) { + if (IPeerNode.class.equals(adapterType)) { return ((IProcessContextNode) adaptableObject).getAdapter(adapterType); } if (ISearchable.class.equals(adapterType)) { - return new ProcessSearchable((IPeerModel)((IProcessContextNode)adaptableObject).getAdapter(IPeerModel.class)); + return new ProcessSearchable((IPeerNode)((IProcessContextNode)adaptableObject).getAdapter(IPeerNode.class)); } } if (adaptableObject instanceof IRuntimeModel) { if (ISearchable.class.equals(adapterType)) { - final AtomicReference node = new AtomicReference(); + final AtomicReference node = new AtomicReference(); Runnable runnable = new Runnable() { @Override diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java index bfa30f2d4..b9ba191b8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java @@ -29,7 +29,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.ui.activator.UIPlugin; import org.eclipse.tcf.te.tcf.processes.ui.internal.preferences.IPreferenceConsts; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; @@ -44,7 +44,7 @@ public class IntervalConfigDialog extends StatusDialog implements ModifyListener // The entered result private int result; // The parent element - private final IPeerModel node; + private final IPeerNode node; /** * Constructor @@ -52,7 +52,7 @@ public class IntervalConfigDialog extends StatusDialog implements ModifyListener * @param node The parent peer model node. Must not be null. * @param parent The parent shell or null. */ - public IntervalConfigDialog(IPeerModel node, Shell parent) { + public IntervalConfigDialog(IPeerNode node, Shell parent) { super(parent); Assert.isNotNull(node); this.node = node; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/properties/ContextPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/properties/ContextPage.java index 5a936adf3..cdc445cb9 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/properties/ContextPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/properties/ContextPage.java @@ -25,7 +25,7 @@ import org.eclipse.tcf.services.ISysMonitor; import org.eclipse.tcf.services.ISysMonitor.SysMonitorContext; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; @@ -59,9 +59,9 @@ public class ContextPage extends PropertyPage { Assert.isTrue(!Protocol.isDispatchThread()); Protocol.invokeAndWait(runnable); - IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class); - IUIService service = peerModel != null ? ServiceManager.getInstance().getService(peerModel, IUIService.class) : null; - IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerModel, IProcessMonitorUIDelegate.class) : null; + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); + IUIService service = peerNode != null ? ServiceManager.getInstance().getService(peerNode, IUIService.class) : null; + IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerNode, IProcessMonitorUIDelegate.class) : null; SysMonitorContext context = ctx.get(); createField(Messages.ContextPage_File, context == null ? null : context.getFile(), page); @@ -73,11 +73,11 @@ public class ContextPage extends PropertyPage { createField(Messages.ContextPage_ID, context == null ? null : context.getID(), page); createField(Messages.ContextPage_ParentID, context == null ? null : context.getParentID(), page); createField(Messages.ContextPage_GroupID, context == null || context.getPGRP() < 0 ? null : Long.valueOf(context.getPGRP()), page); - String label = Messages.getStringDelegated(peerModel, "ContextPage_PID"); //$NON-NLS-1$ + String label = Messages.getStringDelegated(peerNode, "ContextPage_PID"); //$NON-NLS-1$ Long v = context == null || context.getPID() < 0 ? null : Long.valueOf(context.getPID()); String value = delegate != null && v != null ? delegate.getText(node, "PID", v.toString()) : null; //$NON-NLS-1$ createField(label != null ? label : Messages.ContextPage_PID, value != null ? value : v, page); - label = Messages.getStringDelegated(peerModel, "ContextPage_PPID"); //$NON-NLS-1$ + label = Messages.getStringDelegated(peerNode, "ContextPage_PPID"); //$NON-NLS-1$ v = context == null || context.getPPID() < 0 ? null : Long.valueOf(context.getPPID()); value = delegate != null && v != null ? delegate.getText(node, "PPID", v.toString()) : null; //$NON-NLS-1$ createField(label != null ? label : Messages.ContextPage_PPID, value != null ? value : v, page); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/properties/GeneralInformationPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/properties/GeneralInformationPage.java index a79e88e41..ecfc3bdbf 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/properties/GeneralInformationPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/properties/GeneralInformationPage.java @@ -27,7 +27,7 @@ import org.eclipse.tcf.services.ISysMonitor; import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; @@ -50,9 +50,9 @@ public class GeneralInformationPage extends PropertyPage { node = (IProcessContextNode) element; - IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class); - IUIService service = peerModel != null ? ServiceManager.getInstance().getService(peerModel, IUIService.class) : null; - IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerModel, IProcessMonitorUIDelegate.class) : null; + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); + IUIService service = peerNode != null ? ServiceManager.getInstance().getService(peerNode, IUIService.class) : null; + IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerNode, IProcessMonitorUIDelegate.class) : null; final Map props = new HashMap(); @@ -77,15 +77,15 @@ public class GeneralInformationPage extends PropertyPage { createField(Messages.GeneralInformationPage_User, props.get(ISysMonitor.PROP_USERNAME), page); createSeparator(page); - String label = Messages.getStringDelegated(peerModel, "GeneralInformationPage_ProcessID"); //$NON-NLS-1$ + String label = Messages.getStringDelegated(peerNode, "GeneralInformationPage_ProcessID"); //$NON-NLS-1$ String value = delegate != null ? delegate.getText(node, "PID", (props.get(ISysMonitor.PROP_PID) != null ? props.get(ISysMonitor.PROP_PID).toString() : null)) : null; //$NON-NLS-1$ createField(label != null ? label : Messages.GeneralInformationPage_ProcessID, value != null ? value : props.get(ISysMonitor.PROP_PID), page); - label = Messages.getStringDelegated(peerModel, "GeneralInformationPage_ParentPID"); //$NON-NLS-1$ + label = Messages.getStringDelegated(peerNode, "GeneralInformationPage_ParentPID"); //$NON-NLS-1$ value = delegate != null ? delegate.getText(node, "PPID", (props.get(ISysMonitor.PROP_PPID) != null ? props.get(ISysMonitor.PROP_PPID).toString() : null)) : null; //$NON-NLS-1$ createField(label != null ? label : Messages.GeneralInformationPage_ParentPID, props.get(ISysMonitor.PROP_PPID), page); - label = Messages.getStringDelegated(peerModel, "GeneralInformationPage_InternalPID"); //$NON-NLS-1$ + label = Messages.getStringDelegated(peerNode, "GeneralInformationPage_InternalPID"); //$NON-NLS-1$ createField(label != null ? label : Messages.GeneralInformationPage_InternalPID, props.get(IProcesses.PROP_ID), page); - label = Messages.getStringDelegated(peerModel, "GeneralInformationPage_InternalPPID"); //$NON-NLS-1$ + label = Messages.getStringDelegated(peerNode, "GeneralInformationPage_InternalPPID"); //$NON-NLS-1$ createField(label != null ? label : Messages.GeneralInformationPage_InternalPPID, props.get(IProcesses.PROP_PARENTID), page); return page; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/BasicContextSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/BasicContextSection.java index 64a8aaf58..9531ba04b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/BasicContextSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/BasicContextSection.java @@ -14,7 +14,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.services.ISysMonitor; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; @@ -60,7 +60,7 @@ public class BasicContextSection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { + protected void updateInput(IPeerNodeProvider input) { Assert.isTrue(input instanceof IProcessContextNode); final IProcessContextNode node = (IProcessContextNode) input; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/BasicInformationSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/BasicInformationSection.java index 4cbd54132..6a57b6d3f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/BasicInformationSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/BasicInformationSection.java @@ -14,7 +14,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.services.ISysMonitor; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; @@ -58,7 +58,7 @@ public class BasicInformationSection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { + protected void updateInput(IPeerNodeProvider input) { Assert.isTrue(input instanceof IProcessContextNode); final IProcessContextNode node = (IProcessContextNode) input; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java index bb8637aa9..920a644ec 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/ContextIDSection.java @@ -17,8 +17,8 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.services.ISysMonitor; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; @@ -79,10 +79,10 @@ public class ContextIDSection extends BaseTitledSection { } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection#updateInput(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider) + * @see org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection#updateInput(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { + protected void updateInput(IPeerNodeProvider input) { Assert.isTrue(input instanceof IProcessContextNode); final IProcessContextNode node = (IProcessContextNode) input; this.node = node; @@ -103,9 +103,9 @@ public class ContextIDSection extends BaseTitledSection { */ @Override public void refresh() { - IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class); - IUIService service = peerModel != null ? ServiceManager.getInstance().getService(peerModel, IUIService.class) : null; - IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerModel, IProcessMonitorUIDelegate.class) : null; + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); + IUIService service = peerNode != null ? ServiceManager.getInstance().getService(peerNode, IUIService.class) : null; + IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerNode, IProcessMonitorUIDelegate.class) : null; String label = delegate != null ? delegate.getMessage("ContextIDSection_PID") : null; //$NON-NLS-1$ if (label != null) SWTControlUtil.setText(pidLabel, label); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java index 948525b3a..72ace325c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/IDSection.java @@ -17,8 +17,8 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.services.ISysMonitor; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; @@ -72,7 +72,7 @@ public class IDSection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { + protected void updateInput(IPeerNodeProvider input) { Assert.isTrue(input instanceof IProcessContextNode); final IProcessContextNode node = (IProcessContextNode) input; this.node = node; @@ -93,9 +93,9 @@ public class IDSection extends BaseTitledSection { */ @Override public void refresh() { - IPeerModel peerModel = (IPeerModel)node.getAdapter(IPeerModel.class); - IUIService service = peerModel != null ? ServiceManager.getInstance().getService(peerModel, IUIService.class) : null; - IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerModel, IProcessMonitorUIDelegate.class) : null; + IPeerNode peerNode = (IPeerNode)node.getAdapter(IPeerNode.class); + IUIService service = peerNode != null ? ServiceManager.getInstance().getService(peerNode, IUIService.class) : null; + IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerNode, IProcessMonitorUIDelegate.class) : null; String label = delegate != null ? delegate.getMessage("IDSection_Title") : null; //$NON-NLS-1$ if (label != null && section != null && !section.isDisposed()) section.setText(label); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/MemorySection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/MemorySection.java index 674962f3a..b58ffacb3 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/MemorySection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/tabbed/MemorySection.java @@ -14,7 +14,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.services.ISysMonitor; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages; import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; @@ -57,7 +57,7 @@ public class MemorySection extends BaseTitledSection { * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) */ @Override - protected void updateInput(IPeerModelProvider input) { + protected void updateInput(IPeerNodeProvider input) { Assert.isTrue(input instanceof IProcessContextNode); final IProcessContextNode node = (IProcessContextNode) input; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/ContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/ContentProvider.java index cc9bca283..ed42eb963 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/ContentProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/ContentProvider.java @@ -30,7 +30,7 @@ import org.eclipse.tcf.te.runtime.model.interfaces.contexts.IAsyncRefreshableCtx import org.eclipse.tcf.te.runtime.model.interfaces.contexts.IAsyncRefreshableCtx.QueryState; import org.eclipse.tcf.te.runtime.model.interfaces.contexts.IAsyncRefreshableCtx.QueryType; import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IPendingOperationNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; @@ -57,8 +57,8 @@ public class ContentProvider implements ITreeContentProvider { // If the parent element is a peer model node, than return // the children of the corresponding runtime model. - if (parentElement instanceof IPeerModel) { - IRuntimeModel model = ModelManager.getRuntimeModel((IPeerModel)parentElement); + if (parentElement instanceof IPeerNode) { + IRuntimeModel model = ModelManager.getRuntimeModel((IPeerNode)parentElement); return isRuntimeModelNodeVisible() ? new Object[] { model } : getChildren(model); } @@ -280,7 +280,7 @@ public class ContentProvider implements ITreeContentProvider { } } } - else if (element instanceof IPeerModel) { + else if (element instanceof IPeerNode) { hasChildren = true; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java index b3ee3db2f..5ac1825e0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java @@ -16,7 +16,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; import org.eclipse.tcf.te.runtime.services.interfaces.delegates.ILabelProviderDelegate; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.ui.activator.UIPlugin; @@ -35,7 +35,7 @@ public class LabelProviderDelegate extends AbstractLabelProviderDelegate impleme @Override public String getText(final Object element) { if (element instanceof IRuntimeModel) { - final AtomicReference node = new AtomicReference(); + final AtomicReference node = new AtomicReference(); Runnable runnable = new Runnable() { @Override diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java index 06b26b022..964856b11 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java @@ -18,7 +18,7 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate; import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.LabelProviderDelegate; @@ -39,7 +39,7 @@ public class ProcessSearchable extends CompositeSearchable { * * @param node The peer model node context. Must not be null. */ - public ProcessSearchable(IPeerModel node) { + public ProcessSearchable(IPeerNode node) { super(); IUIService service = ServiceManager.getInstance().getService(node, IUIService.class); @@ -56,7 +56,7 @@ public class ProcessSearchable extends CompositeSearchable { */ @Override public String getSearchTitle(final Object rootElement) { - final AtomicReference node = new AtomicReference(); + final AtomicReference node = new AtomicReference(); if (rootElement instanceof IRuntimeModel) { Runnable runnable = new Runnable() { @@ -72,7 +72,7 @@ public class ProcessSearchable extends CompositeSearchable { else Protocol.invokeAndWait(runnable); } else if (rootElement != null) { - node.set(rootElement instanceof IAdaptable ? (IPeerModel)((IAdaptable)rootElement).getAdapter(IPeerModel.class) : (IPeerModel)Platform.getAdapterManager().getAdapter(rootElement, IPeerModel.class)); + node.set(rootElement instanceof IAdaptable ? (IPeerNode)((IAdaptable)rootElement).getAdapter(IPeerNode.class) : (IPeerNode)Platform.getAdapterManager().getAdapter(rootElement, IPeerNode.class)); } String label = Messages.getStringDelegated(node.get(), "ProcessSearchable_SearchTitle"); //$NON-NLS-1$ @@ -85,7 +85,7 @@ public class ProcessSearchable extends CompositeSearchable { @Override public String getSearchMessage(final Object rootElement) { if (rootElement == null || rootElement instanceof IRuntimeModel) { - final AtomicReference node = new AtomicReference(); + final AtomicReference node = new AtomicReference(); Runnable runnable = new Runnable() { @Override @@ -103,7 +103,7 @@ public class ProcessSearchable extends CompositeSearchable { return label != null ? label : Messages.ProcessSearchable_PromptFindInProcessList; } - IPeerModel node = rootElement instanceof IAdaptable ? (IPeerModel)((IAdaptable)rootElement).getAdapter(IPeerModel.class) : (IPeerModel)Platform.getAdapterManager().getAdapter(rootElement, IPeerModel.class); + IPeerNode node = rootElement instanceof IAdaptable ? (IPeerNode)((IAdaptable)rootElement).getAdapter(IPeerNode.class) : (IPeerNode)Platform.getAdapterManager().getAdapter(rootElement, IPeerNode.class); String label = Messages.getStringDelegated(node, "ProcessSearchable_PromptFindUnderProcess"); //$NON-NLS-1$ String message = label != null ? label : Messages.ProcessSearchable_PromptFindUnderProcess; String rootName = "\"" + getElementName(rootElement) + "\""; //$NON-NLS-1$//$NON-NLS-2$ @@ -116,7 +116,7 @@ public class ProcessSearchable extends CompositeSearchable { */ @Override public String getCustomMessage(final Object rootElement, final String key) { - final AtomicReference node = new AtomicReference(); + final AtomicReference node = new AtomicReference(); if (rootElement instanceof IRuntimeModel) { Runnable runnable = new Runnable() { @@ -132,7 +132,7 @@ public class ProcessSearchable extends CompositeSearchable { else Protocol.invokeAndWait(runnable); } else if (rootElement != null) { - node.set(rootElement instanceof IAdaptable ? (IPeerModel)((IAdaptable)rootElement).getAdapter(IPeerModel.class) : (IPeerModel)Platform.getAdapterManager().getAdapter(rootElement, IPeerModel.class)); + node.set(rootElement instanceof IAdaptable ? (IPeerNode)((IAdaptable)rootElement).getAdapter(IPeerNode.class) : (IPeerNode)Platform.getAdapterManager().getAdapter(rootElement, IPeerNode.class)); } String message = Messages.getStringDelegated(node.get(), key); @@ -147,7 +147,7 @@ public class ProcessSearchable extends CompositeSearchable { */ private String getElementName(final Object rootElement) { if (rootElement == null || rootElement instanceof IRuntimeModel) { - final AtomicReference node = new AtomicReference(); + final AtomicReference node = new AtomicReference(); Runnable runnable = new Runnable() { @Override diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/AdapterFactory.java index 144f56895..77d4174f0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/AdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/AdapterFactory.java @@ -1,92 +1,92 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.services.contexts.internal; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.runtime.interfaces.IDisposable; -import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter; -import org.eclipse.tcf.te.tcf.locator.model.Model; -import org.eclipse.tcf.te.tcf.services.contexts.interfaces.IContextService; - -/** - * Context service adapter factory implementation. - */ -public class AdapterFactory implements IAdapterFactory { - // Maintain a map of contexts service adapters per peer - /* default */ Map adapters = new HashMap(); - - private static final Class[] CLASSES = new Class[] { - IContextService.class - }; - - /** - * Constructor. - */ - public AdapterFactory() { - final IModelListener listener = new ModelAdapter() { - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, boolean) - */ - @Override - public void locatorModelChanged(ILocatorModel model, IPeerModel peer, boolean added) { - // If a peer gets removed, remove the context service proxy - if (peer != null && peer.getPeer() != null && !added) { - IContextService adapter = adapters.remove(peer.getPeer()); - if (adapter instanceof IDisposable) ((IDisposable)adapter).dispose(); - } - } - }; - - Runnable runnable = new Runnable() { - @Override - public void run() { - Model.getModel().addListener(listener); - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - @Override - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adaptableObject instanceof IPeer) { - // Lookup the adapter - IContextService adapter = adapters.get(adaptableObject); - // No adapter yet -> create a new one for this peer - if (adapter == null) { - adapter = new ContextServiceAdapter((IPeer)adaptableObject); - adapters.put((IPeer)adaptableObject, adapter); - } - return adapter; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - @Override - public Class[] getAdapterList() { - return CLASSES; - } - -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.services.contexts.internal; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.runtime.interfaces.IDisposable; +import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter; +import org.eclipse.tcf.te.tcf.locator.model.Model; +import org.eclipse.tcf.te.tcf.services.contexts.interfaces.IContextService; + +/** + * Context service adapter factory implementation. + */ +public class AdapterFactory implements IAdapterFactory { + // Maintain a map of contexts service adapters per peer + /* default */ Map adapters = new HashMap(); + + private static final Class[] CLASSES = new Class[] { + IContextService.class + }; + + /** + * Constructor. + */ + public AdapterFactory() { + final IModelListener listener = new ModelAdapter() { + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean) + */ + @Override + public void locatorModelChanged(IPeerModel model, IPeerNode peer, boolean added) { + // If a peer gets removed, remove the context service proxy + if (peer != null && peer.getPeer() != null && !added) { + IContextService adapter = adapters.remove(peer.getPeer()); + if (adapter instanceof IDisposable) ((IDisposable)adapter).dispose(); + } + } + }; + + Runnable runnable = new Runnable() { + @Override + public void run() { + Model.getModel().addListener(listener); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (adaptableObject instanceof IPeer) { + // Lookup the adapter + IContextService adapter = adapters.get(adaptableObject); + // No adapter yet -> create a new one for this peer + if (adapter == null) { + adapter = new ContextServiceAdapter((IPeer)adaptableObject); + adapters.put((IPeer)adaptableObject, adapter); + } + return adapter; + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + @Override + public Class[] getAdapterList() { + return CLASSES; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml index 03a38ec60..9316b0575 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml @@ -30,7 +30,7 @@ - + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsLauncherDelegate.java index 651cc2231..78575e471 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsLauncherDelegate.java @@ -19,7 +19,7 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.terminals.core.interfaces.launcher.ITerminalsLauncher; import org.eclipse.tcf.te.tcf.terminals.core.launcher.TerminalsLauncher; import org.eclipse.tcf.te.tcf.terminals.ui.controls.TerminalsWizardConfigurationPanel; @@ -62,16 +62,16 @@ public class TerminalsLauncherDelegate extends AbstractLauncherDelegate { ISelection selection = (ISelection)properties.getProperty(ITerminalsConnectorConstants.PROP_SELECTION); if (selection instanceof IStructuredSelection && !selection.isEmpty()) { Object element = ((IStructuredSelection)selection).getFirstElement(); - if (element instanceof IPeerModel) { - final IPeerModel peerModel = (IPeerModel)element; + if (element instanceof IPeerNode) { + final IPeerNode peerNode = (IPeerNode)element; final AtomicReference peer = new AtomicReference(); if (Protocol.isDispatchThread()) { - peer.set(peerModel.getPeer()); + peer.set(peerNode.getPeer()); } else { Protocol.invokeAndWait(new Runnable() { @Override public void run() { - peer.set(peerModel.getPeer()); + peer.set(peerNode.getPeer()); } }); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsMementoHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsMementoHandler.java index 4ee81b551..cffd6ed86 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsMementoHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsMementoHandler.java @@ -18,9 +18,9 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler; import org.eclipse.ui.IMemento; @@ -46,9 +46,9 @@ public class TerminalsMementoHandler implements IMementoHandler { ISelection selection = (ISelection)properties.getProperty(ITerminalsConnectorConstants.PROP_SELECTION); if (selection instanceof IStructuredSelection && !selection.isEmpty()) { Object element = ((IStructuredSelection)selection).getFirstElement(); - if (element instanceof IPeerModel) { - IPeerModel peerModel = (IPeerModel)element; - memento.putString("peerID", peerModel.getPeerId()); //$NON-NLS-1$ + if (element instanceof IPeerNode) { + IPeerNode peerNode = (IPeerNode)element; + memento.putString("peerID", peerNode.getPeerId()); //$NON-NLS-1$ } } } @@ -66,13 +66,13 @@ public class TerminalsMementoHandler implements IMementoHandler { final String peerID = memento.getString("peerID"); //$NON-NLS-1$ if (peerID != null) { - final ILocatorModel model = Model.getModel(); + final IPeerModel model = Model.getModel(); Assert.isNotNull(model); - final AtomicReference peerModel = new AtomicReference(); + final AtomicReference peerNode = new AtomicReference(); Runnable runnable = new Runnable() { @Override public void run() { - peerModel.set(model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peerID)); + peerNode.set(model.getService(IPeerModelLookupService.class).lkupPeerModelById(peerID)); } }; Assert.isTrue(!Protocol.isDispatchThread()); @@ -80,14 +80,14 @@ public class TerminalsMementoHandler implements IMementoHandler { // If the node is null, this might mean that the peer to restore is a dynamically discovered peer. // In this case, we have to wait a little bit to give the locator service the chance to sync. - if (peerModel.get() == null) { + if (peerNode.get() == null) { // Sleep shortly try { Thread.sleep(300); } catch (InterruptedException e) {} Protocol.invokeAndWait(runnable); } - if (peerModel.get() != null) { - properties.setProperty(ITerminalsConnectorConstants.PROP_SELECTION, new StructuredSelection(peerModel.get())); + if (peerNode.get() != null) { + properties.setProperty(ITerminalsConnectorConstants.PROP_SELECTION, new StructuredSelection(peerNode.get())); } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java index b0f3fee33..adcf443f2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java @@ -58,7 +58,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Menu; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.runtime.utils.StatusHelper; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.ui.views.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.ui.views.nls.Messages; import org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions.CopyAction; @@ -91,7 +91,7 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection private final List listeners = new ArrayList(); // Reference to the selected peer model - /* default */ IPeerModel peerModel; + /* default */ IPeerNode peerNode; // References to the global action handlers private CutAction cutHandler; @@ -392,10 +392,10 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection label.append(" - "); //$NON-NLS-1$ - if (peerModel == null) { + if (peerNode == null) { label.append(""); //$NON-NLS-1$ } else { - PeerAction action = new PeerAction(this, peerModel); + PeerAction action = new PeerAction(this, peerNode); label.append(action.getText()); } @@ -421,10 +421,10 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection /** * Sets the peer model. * - * @param peerModel The peer model or null. + * @param peerNode The peer model or null. */ - public void setPeerModel(IPeerModel peerModel) { - this.peerModel = peerModel; + public void setPeerModel(IPeerNode peerNode) { + this.peerNode = peerNode; // Update the head label updateHeadLabel(); // Update the action bars @@ -444,8 +444,8 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection * * @return The associated peer model. */ - public IPeerModel getPeerModel() { - return peerModel; + public IPeerNode getPeerModel() { + return peerNode; } /** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java index 7882de782..5f87474a2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeerAction.java @@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.action.Action; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad; import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; import org.eclipse.ui.IViewPart; @@ -24,7 +24,7 @@ public class PeerAction extends Action { private final static DelegatingLabelProvider delegate = new DelegatingLabelProvider(); // Reference to the peer model - private IPeerModel peerModel; + private IPeerNode peerNode; // Reference to the parent view part private IViewPart view; @@ -32,17 +32,17 @@ public class PeerAction extends Action { * Constructor. * * @param view The parent view part. Must not be null. - * @param peerModel The peer model. Must not be null. + * @param peerNode The peer model. Must not be null. */ - public PeerAction(IViewPart view, IPeerModel peerModel) { + public PeerAction(IViewPart view, IPeerNode peerNode) { super("", AS_CHECK_BOX); //$NON-NLS-1$ - Assert.isNotNull(peerModel); - this.peerModel = peerModel; + Assert.isNotNull(peerNode); + this.peerNode = peerNode; - String label = delegate.getText(peerModel); + String label = delegate.getText(peerNode); if (label != null) { - setText(delegate.decorateText(label, peerModel)); + setText(delegate.decorateText(label, peerNode)); } Assert.isNotNull(view); @@ -58,7 +58,7 @@ public class PeerAction extends Action { // Pass on the selected peer model to the parent view if (view instanceof ScriptPad) { - ((ScriptPad)view).setPeerModel(peerModel); + ((ScriptPad)view).setPeerModel(peerNode); } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeersSubMenuAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeersSubMenuAction.java index 1075fb32b..436c22425 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeersSubMenuAction.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PeersSubMenuAction.java @@ -26,8 +26,8 @@ import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad; @@ -60,10 +60,10 @@ public class PeersSubMenuAction extends Action implements IMenuCreator, IViewAct // Create and register the locator model listener listener = new ModelAdapter() { @Override - public void locatorModelChanged(ILocatorModel model, IPeerModel peer, boolean added) { + public void locatorModelChanged(IPeerModel model, IPeerNode peer, boolean added) { // Re-evaluate the enablement if (actionProxy != null) { - final IPeerModel[] peers = Model.getModel().getPeers(); + final IPeerNode[] peers = Model.getModel().getPeers(); actionProxy.setEnabled(peers != null && peers.length > 0); // If the peer is not set to the view yet, but the action get's @@ -119,7 +119,7 @@ public class PeersSubMenuAction extends Action implements IMenuCreator, IViewAct // Determine the enablement. The action is disabled // if no peers are available. - IPeerModel[] peers = Model.getModel().getPeers(); + IPeerNode[] peers = Model.getModel().getPeers(); if (peers != null && peers.length > 0) { action.setEnabled(true); if (view instanceof ScriptPad) ((ScriptPad)view).setPeerModel(peers[0]); @@ -204,14 +204,14 @@ public class PeersSubMenuAction extends Action implements IMenuCreator, IViewAct } // Get the selected peer model - IPeerModel selected = null; + IPeerNode selected = null; if (view instanceof ScriptPad) selected = ((ScriptPad)view).getPeerModel(); boolean selectFirst = selected == null; - IPeerModel[] peers = Model.getModel().getPeers(); + IPeerNode[] peers = Model.getModel().getPeers(); if (peers != null && peers.length > 0) { - for (IPeerModel peer : peers) { + for (IPeerNode peer : peers) { if (isValueAdd(peer)) continue; Action action = new PeerAction(view, peer); if (selectFirst) { @@ -235,17 +235,17 @@ public class PeersSubMenuAction extends Action implements IMenuCreator, IViewAct /** * Determines if the given peer model node is a value-add. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @return True if the peer model node is value-add, false otherwise. */ - /* default */ final boolean isValueAdd(final IPeerModel peerModel) { - Assert.isNotNull(peerModel); + /* default */ final boolean isValueAdd(final IPeerNode peerNode) { + Assert.isNotNull(peerNode); final AtomicBoolean isValueAdd = new AtomicBoolean(); Runnable runnable = new Runnable() { @Override public void run() { - String value = peerModel.getPeer().getAttributes().get("ValueAdd"); //$NON-NLS-1$ + String value = peerNode.getPeer().getAttributes().get("ValueAdd"); //$NON-NLS-1$ boolean isValueAddValue = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$ isValueAdd.set(isValueAddValue); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java index a4c4eabda..692e5637f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java @@ -24,7 +24,7 @@ import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.tcf.core.scripting.interfaces.IScriptLauncherProperties; import org.eclipse.tcf.te.tcf.core.scripting.launcher.ScriptLauncher; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.ui.views.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.ui.views.nls.Messages; import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad; @@ -98,21 +98,21 @@ public class PlayAction extends Action implements IViewActionDelegate, IActionDe @Override public void run() { String script = null; - IPeerModel peerModel = null; + IPeerNode peerNode = null; if (view instanceof ScriptPad && ((ScriptPad)view).getStyledText() != null) { script = ((ScriptPad)view).getStyledText().getText(); - peerModel = ((ScriptPad)view).getPeerModel(); + peerNode = ((ScriptPad)view).getPeerModel(); } - if (script != null && !"".equals(script) && peerModel != null) { //$NON-NLS-1$ + if (script != null && !"".equals(script) && peerNode != null) { //$NON-NLS-1$ final ScriptLauncher launcher = new ScriptLauncher(); IPropertiesContainer properties = new PropertiesContainer(); properties.setProperty(IScriptLauncherProperties.PROP_SCRIPT, script); final AtomicReference peer = new AtomicReference(); - final IPeerModel finPeerModel = peerModel; + final IPeerNode finPeerModel = peerNode; Runnable runnable = new Runnable() { @Override public void run() { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml index e2277a9d2..242b3669d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml @@ -5,7 +5,7 @@ @@ -15,7 +15,7 @@ - + @@ -23,7 +23,7 @@ @@ -49,7 +49,7 @@ id="org.eclipse.tcf.te.tcf.ui.propertyTester.simulator" namespace="org.eclipse.tcf.te.tcf.ui" properties="isValidSimulatorConfig" - type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"> + type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"> @@ -75,7 +75,7 @@ class="org.eclipse.tcf.te.tcf.ui.navigator.events.EventListener"> + class="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"> @@ -107,13 +107,13 @@ - + - + @@ -126,7 +126,7 @@ - + @@ -177,7 +177,7 @@ id="org.eclipse.tcf.te.tcf.ui.peerLabelProviderDelegate"> - + @@ -299,7 +299,7 @@ insertBefore="first"> - + @@ -335,7 +335,7 @@ - + @@ -353,7 +353,7 @@ - + @@ -372,7 +372,7 @@ - + - + @@ -506,7 +506,7 @@ - + @@ -523,7 +523,7 @@ - + @@ -532,7 +532,7 @@ - + @@ -546,7 +546,7 @@ - + @@ -554,8 +554,8 @@ - - + + @@ -568,7 +568,7 @@ - + @@ -576,7 +576,7 @@ - + @@ -589,12 +589,12 @@ class="org.eclipse.tcf.te.tcf.ui.handler.StartDebugCommandHandler"> - + - + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java index e3e7256ae..48be9247c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java @@ -40,11 +40,11 @@ import org.eclipse.tcf.te.runtime.events.ChangeEvent; import org.eclipse.tcf.te.runtime.events.EventManager; import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener; import org.eclipse.tcf.te.runtime.persistence.history.HistoryManager; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; -import org.eclipse.tcf.te.tcf.ui.dialogs.AgentSelectionDialog; +import org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog; import org.eclipse.tcf.te.ui.views.editor.EditorInput; import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; import org.eclipse.tcf.te.ui.views.navigator.ViewerSorter; @@ -134,12 +134,12 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA if (e.getSource() instanceof HistoryManager && getPeerTypeId().equals(e.getNewValue())) { recreateMenuCtlParent.set(true); recreateMenuMenuParent.set(true); - IPeerModel peerModel = getPeerModel(HistoryManager.getInstance().getFirst(getPeerTypeId())); + IPeerNode peerNode = getPeerModel(HistoryManager.getInstance().getFirst(getPeerTypeId())); if (action != null) { - if (peerModel != null) { - ILabelProvider labelProvider = getLabelProvider(peerModel); + if (peerNode != null) { + ILabelProvider labelProvider = getLabelProvider(peerNode); if (labelProvider != null) { - action.setToolTipText("Open " + labelProvider.getText(peerModel)); //$NON-NLS-1$ + action.setToolTipText("Open " + labelProvider.getText(peerNode)); //$NON-NLS-1$ return; } @@ -200,16 +200,16 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA }); } - private IPeerModel getPeerModel(final String peerId) { + private IPeerNode getPeerModel(final String peerId) { if (peerId != null) { - final AtomicReference peerModel = new AtomicReference(); + final AtomicReference peerNode = new AtomicReference(); Runnable runnable = new Runnable() { @Override public void run() { - ILocatorModel model = Model.getModel(); + IPeerModel model = Model.getModel(); Assert.isNotNull(model); - peerModel.set(model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId)); + peerNode.set(model.getService(IPeerModelLookupService.class).lkupPeerModelById(peerId)); } }; @@ -220,7 +220,7 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA Protocol.invokeAndWait(runnable); } - return peerModel.get(); + return peerNode.get(); } return null; @@ -234,20 +234,20 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA @SuppressWarnings("unused") protected void fillMenu(Menu menu) { int accelerator = 1; - List peerModels = new ArrayList(); + List peerNodes = new ArrayList(); for (String id : HistoryManager.getInstance().getHistory(getPeerTypeId())) { - IPeerModel peerModel = getPeerModel(id); - if (peerModel != null && !peerModels.contains(peerModel)) { - peerModels.add(peerModel); + IPeerNode peerNode = getPeerModel(id); + if (peerNode != null && !peerNodes.contains(peerNode)) { + peerNodes.add(peerNode); } } - for (final IPeerModel peerModel: peerModels) { - ILabelProvider labelProvider = getLabelProvider(peerModel); - String label = peerModel.getPeer().getName(); + for (final IPeerNode peerNode: peerNodes) { + ILabelProvider labelProvider = getLabelProvider(peerNode); + String label = peerNode.getPeer().getName(); if (labelProvider != null) { - label = labelProvider.getText(peerModel); + label = labelProvider.getText(peerNode); if (labelProvider instanceof ILabelDecorator) { - label = ((ILabelDecorator)labelProvider).decorateText(label, peerModel); + label = ((ILabelDecorator)labelProvider).decorateText(label, peerNode); } } Action action = new Action(label) { @@ -256,7 +256,7 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA // Get the active page IWorkbenchPage page = window.getActivePage(); // Create the editor input object - IEditorInput input = new EditorInput(peerModel); + IEditorInput input = new EditorInput(peerNode); try { // Opens the configuration editor page.openEditor(input, IUIConstants.ID_EDITOR); @@ -266,7 +266,7 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA } }; if (labelProvider != null) { - action.setImageDescriptor(ImageDescriptor.createFromImage(labelProvider.getImage(peerModel))); + action.setImageDescriptor(ImageDescriptor.createFromImage(labelProvider.getImage(peerNode))); } addToMenu(menu, action, accelerator); accelerator++; @@ -283,7 +283,7 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA // Get the active page IWorkbenchPage page = window.getActivePage(); // Create the agent selection dialog - AgentSelectionDialog dialog = new AgentSelectionDialog(null) { + PeerSelectionDialog dialog = new PeerSelectionDialog(null) { @Override protected String getTitle() { return getSelectExistingDialogTitle(); @@ -312,7 +312,7 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA if (dialog.open() == Window.OK) { // Get the selected proxy from the dialog ISelection selection = dialog.getSelection(); - if (selection instanceof IStructuredSelection && !selection.isEmpty() && ((IStructuredSelection)selection).getFirstElement() instanceof IPeerModel) { + if (selection instanceof IStructuredSelection && !selection.isEmpty() && ((IStructuredSelection)selection).getFirstElement() instanceof IPeerNode) { // Create the editor input object IEditorInput input = new EditorInput(((IStructuredSelection)selection).getFirstElement()); try { @@ -375,12 +375,12 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA @SuppressWarnings("restriction") @Override public void run(IAction action) { - IPeerModel peerModel = getPeerModel(HistoryManager.getInstance().getFirst(getPeerTypeId())); - if (peerModel != null) { + IPeerNode peerNode = getPeerModel(HistoryManager.getInstance().getFirst(getPeerTypeId())); + if (peerNode != null) { // Get the active page IWorkbenchPage page = window.getActivePage(); // Create the editor input object - IEditorInput input = new EditorInput(peerModel); + IEditorInput input = new EditorInput(peerNode); try { // Opens the configuration editor page.openEditor(input, IUIConstants.ID_EDITOR); @@ -404,13 +404,13 @@ public abstract class AbstractPeerTypeToolbarAction extends Action implements IA /** * Get the label provider for a peer model node. * - * @param peerModel The peer model node. + * @param peerNode The peer model node. * @return The label provider or null. */ - protected ILabelProvider getLabelProvider(IPeerModel peerModel) { - ILabelProvider labelProvider = (ILabelProvider)peerModel.getAdapter(ILabelProvider.class); + protected ILabelProvider getLabelProvider(IPeerNode peerNode) { + ILabelProvider labelProvider = (ILabelProvider)peerNode.getAdapter(ILabelProvider.class); if (labelProvider == null) { - labelProvider = (ILabelProvider)Platform.getAdapterManager().loadAdapter(peerModel, ILabelProvider.class.getName()); + labelProvider = (ILabelProvider)Platform.getAdapterManager().loadAdapter(peerNode, ILabelProvider.class.getName()); } return labelProvider; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java index 128fd7397..3d06081ad 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java @@ -29,8 +29,8 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService; import org.eclipse.tcf.te.runtime.stepper.job.StepperJob; import org.eclipse.tcf.te.runtime.utils.StatusHelper; import org.eclipse.tcf.te.tcf.core.Tcf; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.internal.ImageConsts; @@ -104,7 +104,7 @@ public class UIPlugin extends AbstractUIPlugin { if (proceedShutdown || forced) { // Terminate the scanner - final ILocatorModel model = Model.getModel(true); + final IPeerModel model = Model.getModel(true); if (model != null) { Runnable runnable = new Runnable() { @Override @@ -125,23 +125,23 @@ public class UIPlugin extends AbstractUIPlugin { @Override public void run() { // Get all peer model objects - IPeerModel[] peers = model.getPeers(); + IPeerNode[] peers = model.getPeers(); // Loop them and check if disconnect is available - for (IPeerModel peerModel : peers) { - IService[] services = ServiceManager.getInstance().getServices(peerModel, IStepperOperationService.class, false); + for (IPeerNode peerNode : peers) { + IService[] services = ServiceManager.getInstance().getServices(peerNode, IStepperOperationService.class, false); IStepperOperationService stepperOperationService = null; for (IService service : services) { - if (service instanceof IStepperOperationService && ((IStepperOperationService)service).isHandledOperation(peerModel, IStepperServiceOperations.DISCONNECT)) { + if (service instanceof IStepperOperationService && ((IStepperOperationService)service).isHandledOperation(peerNode, IStepperServiceOperations.DISCONNECT)) { stepperOperationService = (IStepperOperationService)service; break; } } if (stepperOperationService != null) { - String stepGroupId = stepperOperationService.getStepGroupId(peerModel, IStepperServiceOperations.DISCONNECT); - IStepContext stepContext = stepperOperationService.getStepContext(peerModel, IStepperServiceOperations.DISCONNECT); - String name = stepperOperationService.getStepGroupName(peerModel, IStepperServiceOperations.DISCONNECT); - boolean isEnabled = stepperOperationService.isEnabled(peerModel, IStepperServiceOperations.DISCONNECT); - IPropertiesContainer data = stepperOperationService.getStepData(peerModel, IStepperServiceOperations.DISCONNECT); + String stepGroupId = stepperOperationService.getStepGroupId(peerNode, IStepperServiceOperations.DISCONNECT); + IStepContext stepContext = stepperOperationService.getStepContext(peerNode, IStepperServiceOperations.DISCONNECT); + String name = stepperOperationService.getStepGroupName(peerNode, IStepperServiceOperations.DISCONNECT); + boolean isEnabled = stepperOperationService.isEnabled(peerNode, IStepperServiceOperations.DISCONNECT); + IPropertiesContainer data = stepperOperationService.getStepData(peerNode, IStepperServiceOperations.DISCONNECT); if (isEnabled && stepGroupId != null && stepContext != null) { try { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/DefaultContextStatusTrimControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/DefaultContextStatusTrimControl.java index cfe2abdc9..a54d1c42f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/DefaultContextStatusTrimControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/DefaultContextStatusTrimControl.java @@ -26,7 +26,7 @@ import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; import org.eclipse.tcf.te.runtime.services.interfaces.delegates.ILabelProviderDelegate; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; @@ -60,17 +60,17 @@ public class DefaultContextStatusTrimControl extends WorkbenchWindowControlContr IDefaultContextService service = ServiceManager.getInstance().getService(IDefaultContextService.class); if (service != null) { - IPeerModel peerModel = service.getDefaultContext(null); - if (peerModel != null) { - IUIService uiService = ServiceManager.getInstance().getService(peerModel, IUIService.class); - ILabelProviderDelegate delegate = uiService != null ? uiService.getDelegate(peerModel, ILabelProviderDelegate.class) : null; + IPeerNode peerNode = service.getDefaultContext(null); + if (peerNode != null) { + IUIService uiService = ServiceManager.getInstance().getService(peerNode, IUIService.class); + ILabelProviderDelegate delegate = uiService != null ? uiService.getDelegate(peerNode, ILabelProviderDelegate.class) : null; if (delegate == null) { - ILabelProvider provider = (ILabelProvider)Platform.getAdapterManager().getAdapter(peerModel, ILabelProvider.class); + ILabelProvider provider = (ILabelProvider)Platform.getAdapterManager().getAdapter(peerNode, ILabelProvider.class); if (provider instanceof ILabelProviderDelegate) { delegate = (ILabelProviderDelegate)provider; } } - selected = NLS.bind(Messages.DefaultContextStatusTrimControl_label, delegate != null ? delegate.getText(peerModel) : peerModel.getName()); + selected = NLS.bind(Messages.DefaultContextStatusTrimControl_label, delegate != null ? delegate.getText(peerNode) : peerNode.getName()); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java deleted file mode 100644 index 5bae72b8c..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java +++ /dev/null @@ -1,370 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.ui.dialogs; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.ListIterator; -import java.util.concurrent.atomic.AtomicInteger; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TreePath; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.model.Model; -import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; -import org.eclipse.tcf.te.tcf.ui.nls.Messages; -import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog; -import org.eclipse.tcf.te.ui.swt.SWTControlUtil; -import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; - -/** - * TCF agent selection dialog implementation. - */ -public class AgentSelectionDialog extends CustomTitleAreaDialog { - // The list of remote services the agents must provide to be included - /* default */ final String[] services; - - // The table viewer - /* default */ TableViewer viewer; - - // Button to filter non-reachable targets - /* default */ Button showOnlyReachable; - - // The selection. Will be filled in if either "OK" or "Cancel" is pressed - private ISelection selection; - - /** - * Constructor. - * - * @param services The list of (remote) services the agents must provide to be selectable, or null. - */ - public AgentSelectionDialog(String[] services) { - this(null, services); - } - - /** - * Constructor. - * - * @param parent The parent shell used to view the dialog, or null. - * @param services The list of (remote) services the agents must provide to be selectable, or null. - */ - public AgentSelectionDialog(Shell parent, String[] services) { - super(parent, IContextHelpIds.AGENT_SELECTION_DIALOG); - - this.services = services != null && services.length > 0 ? services : null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#isResizable() - */ - @Override - protected boolean isResizable() { - return true; - } - - /** - * Returns whether the dialog shall support multi selection or not. - *

- * The default implementation returns true. - * - * @return True if multi selection is supported, false otherwise. - */ - protected boolean supportsMultiSelection() { - return true; - } - - /** - * Returns the table viewer instance. - * - * @return The table viewer instance or null. - */ - protected final TableViewer getViewer() { - return viewer; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogAreaContent(org.eclipse.swt.widgets.Composite) - */ - @Override - protected void createDialogAreaContent(Composite parent) { - super.createDialogAreaContent(parent); - - setDialogTitle(getDialogTitle()); - setTitle(getTitle()); - setDefaultMessage(getDefaultMessage(), IMessageProvider.NONE); - - // Create the table viewer - viewer = new TableViewer(parent, (supportsMultiSelection() ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER); - - // Configure the table - Table table = viewer.getTable(); - - @SuppressWarnings("unused") - TableColumn column = new TableColumn(table, SWT.LEFT); - - TableLayout tableLayout = new TableLayout(); - tableLayout.addColumnData(new ColumnWeightData(100)); - table.setLayout(tableLayout); - - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - table.setLayoutData(layoutData); - - viewer.setContentProvider(new ArrayContentProvider()); - DelegatingLabelProvider labelProvider = new DelegatingLabelProvider() { - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object) - */ - @Override - public Image decorateImage(Image image, Object element) { - return image; - } - }; - viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider)); - - // Create the filter buttons area - createFilterButtons(parent); - - // Subclasses may customize the viewer before setting the input - configureTableViewer(viewer); - - // The content to show is static. Do the filtering manually so that - // we can disable the OK Button if the dialog would not show any content. - final ILocatorModelLookupService service = getModel().getService(ILocatorModelLookupService.class); - final List nodes = new ArrayList(); - if (service != null) { - nodes.addAll(Arrays.asList(service.lkupPeerModelBySupportedServices(null, services))); - ListIterator iterator = nodes.listIterator(); - while (iterator.hasNext()) { - IPeerModel node = iterator.next(); - - String value = node.getPeer().getAttributes().get("ValueAdd"); //$NON-NLS-1$ - boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$ - - if (isValueAdd) iterator.remove(); - } - } - viewer.setInput(nodes.size() > 0 ? nodes.toArray(new IPeerModel[nodes.size()]) : null); - viewer.addDoubleClickListener(new IDoubleClickListener() { - @Override - public void doubleClick(DoubleClickEvent event) { - if (!viewer.getSelection().isEmpty()) { - okPressed(); - } - } - }); - - // Determine the initial state of the "show only reachable" button. If there are no - // reachable target while opening the dialog, this button should be not selected. - boolean showOnlyReachableSelected = true; - ViewerFilter[] filters = viewer.getFilters(); - if (filters != null && filters.length > 0) { - TreePath parentPath = new TreePath(new Object[0]); - Object[] result = nodes.toArray(); - for (ViewerFilter filter : filters) { - Object[] filteredResult = filter.filter(viewer, parentPath, result); - result = filteredResult; - } - showOnlyReachableSelected = result.length > 0; - } else { - showOnlyReachableSelected = nodes.size() > 0; - } - - if (showOnlyReachableSelected != SWTControlUtil.getSelection(showOnlyReachable)) { - SWTControlUtil.setSelection(showOnlyReachable, showOnlyReachableSelected); - viewer.refresh(); - updateEnablement(viewer); - } - } - - /** - * Creates a set of filter buttons in between the main dialog area - * and the button bar. - * - * @param parent The parent composite. Must not be null. - */ - protected void createFilterButtons(Composite parent) { - Assert.isNotNull(parent); - - showOnlyReachable = new Button(parent, SWT.CHECK); - SWTControlUtil.setText(showOnlyReachable, getShowOnlyReachableLabel()); - SWTControlUtil.setSelection(showOnlyReachable, true); - showOnlyReachable.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - viewer.refresh(); - updateEnablement(viewer); - } - }); - } - - /** - * Returns the label of the "Show only reachable targets" filter button. - * - * @return The label. - */ - protected String getShowOnlyReachableLabel() { - return Messages.AgentSelectionDialog_button_showOnlyReachable; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Control createButtonBar(Composite parent) { - Control buttonBar = super.createButtonBar(parent); - updateEnablement(viewer); - return buttonBar; - } - - /** - * Update the enablement of the dialog widgets. - * - * @param viewer The table viewer. Must not be null. - */ - protected void updateEnablement(TableViewer viewer) { - Assert.isNotNull(viewer); - - // Adjust the OK button enablement - Button okButton = getButton(IDialogConstants.OK_ID); - SWTControlUtil.setEnabled(okButton, viewer.getTable().getItems().length > 0); - } - - /** - * Configure the table viewer. - *

- * The default implementation does nothing. Subclasses may overwrite this - * method to customize the table viewer before the input gets set. - * - * @param viewer The table viewer. Must not be null. - */ - protected void configureTableViewer(TableViewer viewer) { - Assert.isNotNull(viewer); - - viewer.addFilter(new ViewerFilter() { - - @Override - public boolean select(Viewer viewer, Object parentElement, final Object element) { - if (element instanceof IPeerModel) { - final AtomicInteger state = new AtomicInteger(IPeerModelProperties.STATE_UNKNOWN); - - Runnable runnable = new Runnable() { - @Override - public void run() { - state.set(((IPeerModel)element).getIntProperty(IPeerModelProperties.PROP_STATE)); - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - - boolean isShowOnlyReachable = SWTControlUtil.getSelection(showOnlyReachable); - if (isShowOnlyReachable) { - return state.get() == IPeerModelProperties.STATE_CONNECTED || state.get() == IPeerModelProperties.STATE_REACHABLE || state.get() == IPeerModelProperties.STATE_WAITING_FOR_READY; - } - } - - return true; - } - }); - } - - /** - * Returns the dialog title. - * - * @return The dialog title. - */ - protected String getDialogTitle() { - return Messages.AgentSelectionDialog_dialogTitle; - } - - /** - * Returns the title. - * - * @return The title. - */ - protected String getTitle() { - return Messages.AgentSelectionDialog_title; - } - - /** - * Returns the default message. - * - * @return The default message. - */ - protected String getDefaultMessage() { - return Messages.AgentSelectionDialog_message; - } - - /** - * Returns the locator model instance to use for determining - * the dialogs input. - * - * @return The locator model instance. - */ - protected ILocatorModel getModel() { - return Model.getModel(); - } - - /** - * Returns the selection which had been set to the viewer at - * the time of closing the dialog with either "OK" or "Cancel". - * - * @return The selection or null. - */ - public ISelection getSelection() { - return selection; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#okPressed() - */ - @Override - protected void okPressed() { - selection = viewer.getSelection(); - super.okPressed(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() - */ - @Override - protected void cancelPressed() { - selection = null; - super.cancelPressed(); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java new file mode 100644 index 000000000..aca1888fc --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/PeerSelectionDialog.java @@ -0,0 +1,287 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.ui.dialogs; + +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TableLayout; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.services.ILocator; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.model.Model; +import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; +import org.eclipse.tcf.te.tcf.ui.nls.Messages; +import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog; +import org.eclipse.tcf.te.ui.swt.SWTControlUtil; +import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; + +/** + * TCF agent selection dialog implementation. + */ +public class PeerSelectionDialog extends CustomTitleAreaDialog { + // The list of remote services the agents must provide to be included + /* default */ final String[] services; + + // The table viewer + /* default */ TableViewer viewer; + + // The selection. Will be filled in if either "OK" or "Cancel" is pressed + private ISelection selection; + + /** + * Constructor. + * + * @param services The list of (remote) services the agents must provide to be selectable, or null. + */ + public PeerSelectionDialog(String[] services) { + this(null, services); + } + + /** + * Constructor. + * + * @param parent The parent shell used to view the dialog, or null. + * @param services The list of (remote) services the agents must provide to be selectable, or null. + */ + public PeerSelectionDialog(Shell parent, String[] services) { + super(parent, IContextHelpIds.AGENT_SELECTION_DIALOG); + + this.services = services != null && services.length > 0 ? services : null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#isResizable() + */ + @Override + protected boolean isResizable() { + return true; + } + + /** + * Returns whether the dialog shall support multi selection or not. + *

+ * The default implementation returns true. + * + * @return True if multi selection is supported, false otherwise. + */ + protected boolean supportsMultiSelection() { + return true; + } + + /** + * Returns the table viewer instance. + * + * @return The table viewer instance or null. + */ + protected final TableViewer getViewer() { + return viewer; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogAreaContent(org.eclipse.swt.widgets.Composite) + */ + @Override + protected void createDialogAreaContent(Composite parent) { + super.createDialogAreaContent(parent); + + setDialogTitle(getDialogTitle()); + setTitle(getTitle()); + setDefaultMessage(getDefaultMessage(), IMessageProvider.NONE); + + // Create the table viewer + viewer = new TableViewer(parent, (supportsMultiSelection() ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER); + + // Configure the table + Table table = viewer.getTable(); + + @SuppressWarnings("unused") + TableColumn column = new TableColumn(table, SWT.LEFT); + + TableLayout tableLayout = new TableLayout(); + tableLayout.addColumnData(new ColumnWeightData(100)); + table.setLayout(tableLayout); + + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + table.setLayoutData(layoutData); + + viewer.setContentProvider(new ArrayContentProvider()); + DelegatingLabelProvider labelProvider = new DelegatingLabelProvider() { + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object) + */ + @Override + public Image decorateImage(Image image, Object element) { + return image; + } + }; + viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider)); + + // Subclasses may customize the viewer before setting the input + configureTableViewer(viewer); + + final AtomicReference peers = new AtomicReference(null); + + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + // Get the locator service + ILocator locatorService = Protocol.getLocator(); + if (locatorService != null) { + // Get the map of peers known to the locator service. + Map peerMap = locatorService.getPeers(); + peers.set(peerMap.values().toArray(new IPeer[peerMap.size()])); + } + } + }); + + viewer.setInput(peers.get()); + viewer.addDoubleClickListener(new IDoubleClickListener() { + @Override + public void doubleClick(DoubleClickEvent event) { + if (!viewer.getSelection().isEmpty()) { + okPressed(); + } + } + }); + + viewer.refresh(); + updateEnablement(viewer); + } + + /** + * Returns the label of the "Show only reachable targets" filter button. + * + * @return The label. + */ + protected String getShowOnlyReachableLabel() { + return Messages.AgentSelectionDialog_button_showOnlyReachable; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createButtonBar(Composite parent) { + Control buttonBar = super.createButtonBar(parent); + updateEnablement(viewer); + return buttonBar; + } + + /** + * Update the enablement of the dialog widgets. + * + * @param viewer The table viewer. Must not be null. + */ + protected void updateEnablement(TableViewer viewer) { + Assert.isNotNull(viewer); + + // Adjust the OK button enablement + Button okButton = getButton(IDialogConstants.OK_ID); + SWTControlUtil.setEnabled(okButton, viewer.getTable().getItems().length > 0); + } + + /** + * Configure the table viewer. + *

+ * The default implementation does nothing. Subclasses may overwrite this + * method to customize the table viewer before the input gets set. + * + * @param viewer The table viewer. Must not be null. + */ + protected void configureTableViewer(TableViewer viewer) { + Assert.isNotNull(viewer); + } + + /** + * Returns the dialog title. + * + * @return The dialog title. + */ + protected String getDialogTitle() { + return Messages.AgentSelectionDialog_dialogTitle; + } + + /** + * Returns the title. + * + * @return The title. + */ + protected String getTitle() { + return Messages.AgentSelectionDialog_title; + } + + /** + * Returns the default message. + * + * @return The default message. + */ + protected String getDefaultMessage() { + return Messages.AgentSelectionDialog_message; + } + + /** + * Returns the locator model instance to use for determining + * the dialogs input. + * + * @return The locator model instance. + */ + protected IPeerModel getModel() { + return Model.getModel(); + } + + /** + * Returns the selection which had been set to the viewer at + * the time of closing the dialog with either "OK" or "Cancel". + * + * @return The selection or null. + */ + public ISelection getSelection() { + return selection; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#okPressed() + */ + @Override + protected void okPressed() { + selection = viewer.getSelection(); + super.okPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() + */ + @Override + protected void cancelPressed() { + selection = null; + super.cancelPressed(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectAgentSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectAgentSelectionDialog.java deleted file mode 100644 index 6e0d0d12c..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectAgentSelectionDialog.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.ui.dialogs; - -import org.eclipse.swt.widgets.Shell; -import org.eclipse.tcf.te.tcf.ui.nls.Messages; - - -/** - * Agent selection dialog implementation to choose the proxy to redirect the communication through. - */ -public class RedirectAgentSelectionDialog extends AgentSelectionDialog { - - /** - * Constructor. - * - * @param services The list of (remote) services the agents must provide to be selectable, or null. - */ - public RedirectAgentSelectionDialog(String[] services) { - super(services); - } - - /** - * Constructor. - * - * @param parent The parent shell used to view the dialog, or null. - * @param services The list of (remote) services the agents must provide to be selectable, or null. - */ - public RedirectAgentSelectionDialog(Shell parent, String[] services) { - super(parent, services); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.dialogs.AgentSelectionDialog#getDialogTitle() - */ - @Override - protected String getDialogTitle() { - return Messages.RedirectAgentSelectionDialog_dialogTitle; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.dialogs.AgentSelectionDialog#getTitle() - */ - @Override - protected String getTitle() { - return Messages.RedirectAgentSelectionDialog_title; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.dialogs.AgentSelectionDialog#getDefaultMessage() - */ - @Override - protected String getDefaultMessage() { - return Messages.RedirectAgentSelectionDialog_message; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.dialogs.AgentSelectionDialog#supportsMultiSelection() - */ - @Override - protected boolean supportsMultiSelection() { - return false; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectPeerSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectPeerSelectionDialog.java new file mode 100644 index 000000000..fb3c1125b --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/RedirectPeerSelectionDialog.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2011 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.ui.dialogs; + +import org.eclipse.swt.widgets.Shell; +import org.eclipse.tcf.te.tcf.ui.nls.Messages; + + +/** + * Agent selection dialog implementation to choose the proxy to redirect the communication through. + */ +public class RedirectPeerSelectionDialog extends PeerSelectionDialog { + + /** + * Constructor. + * + * @param services The list of (remote) services the agents must provide to be selectable, or null. + */ + public RedirectPeerSelectionDialog(String[] services) { + super(services); + } + + /** + * Constructor. + * + * @param parent The parent shell used to view the dialog, or null. + * @param services The list of (remote) services the agents must provide to be selectable, or null. + */ + public RedirectPeerSelectionDialog(Shell parent, String[] services) { + super(parent, services); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog#getDialogTitle() + */ + @Override + protected String getDialogTitle() { + return Messages.RedirectAgentSelectionDialog_dialogTitle; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog#getTitle() + */ + @Override + protected String getTitle() { + return Messages.RedirectAgentSelectionDialog_title; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog#getDefaultMessage() + */ + @Override + protected String getDefaultMessage() { + return Messages.RedirectAgentSelectionDialog_message; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog#supportsMultiSelection() + */ + @Override + protected boolean supportsMultiSelection() { + return false; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java index 97de115ca..6b368f08c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java @@ -16,13 +16,14 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.runtime.utils.StatusHelper; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.tcf.ui.sections.SimulatorTypeSelectionSection; @@ -134,33 +135,31 @@ public abstract class AbstractConfigurationEditorPage extends AbstractCustomForm // If necessary, write the changed peer attributes final Object input = getEditorInputNode(); - if (input instanceof IPeerModel) { + if (input instanceof IPeerNode) { Runnable runnable = new Runnable() { @Override public void run() { try { - boolean isDynamic = !((IPeerModel)input).isStatic(); - // Get the persistence service IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class); if (uRIPersistenceService == null) { throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$ } // Save the peer node to the new persistence storage - uRIPersistenceService.write(((IPeerModel)input).getPeer(), null); + uRIPersistenceService.write(((IPeerNode)input).getPeer(), null); // In case the node had been dynamically discovered before, we have to trigger a refresh // to the locator model to read in the newly created static peer - if (isDynamic) { + if (((IPeerNode)input).getConnectState() == IConnectable.STATE_CONNECTED) { // Refresh the static peers - ((IPeerModel)input).getModel().getService(ILocatorModelRefreshService.class).refreshStaticPeers(); + ((IPeerNode)input).getModel().getService(IPeerModelRefreshService.class).refreshStaticPeers(); // Reopen the editor on the current page ViewsUtil.reopenEditor(getEditor(), getEditor().getActivePageInstance().getId(), false); } } catch (IOException e) { // Build up the message template - String template = NLS.bind(Messages.AbstractConfigurationEditorPage_error_save, ((IPeerModel)input).getName(), Messages.AbstractConfigurationEditorPage_error_possibleCause); + String template = NLS.bind(Messages.AbstractConfigurationEditorPage_error_save, ((IPeerNode)input).getName(), Messages.AbstractConfigurationEditorPage_error_possibleCause); // Handle the status StatusHandlerUtil.handleStatus(StatusHelper.getStatus(e), input, template, null, IContextHelpIds.MESSAGE_SAVE_FAILED, AbstractConfigurationEditorPage.this, null); } @@ -173,7 +172,7 @@ public abstract class AbstractConfigurationEditorPage extends AbstractCustomForm @Override public void run() { // Trigger a change event for the original data node - ((IPeerModel)input).fireChangeEvent("properties", null, ((IPeerModel)input).getProperties()); //$NON-NLS-1$ + ((IPeerNode)input).fireChangeEvent("properties", null, ((IPeerNode)input).getProperties()); //$NON-NLS-1$ } }); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/OverviewEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/OverviewEditorPage.java index 3375c572c..d614abe14 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/OverviewEditorPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/OverviewEditorPage.java @@ -24,7 +24,7 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.runtime.utils.StatusHelper; import org.eclipse.tcf.te.tcf.locator.ScannerRunnable; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin; import org.eclipse.tcf.te.tcf.ui.editor.sections.AttributesSection; import org.eclipse.tcf.te.tcf.ui.editor.sections.GeneralInformationSection; @@ -175,9 +175,9 @@ public class OverviewEditorPage extends AbstractCustomFormToolkitEditorPage { return; } super.setInput(input); - if (getEditorInputNode() instanceof IPeerModel) { + if (getEditorInputNode() instanceof IPeerNode) { // Invoke the scanner runnable - ScannerRunnable runnable = new ScannerRunnable(null, ((IPeerModel)getEditorInputNode())); + ScannerRunnable runnable = new ScannerRunnable(null, ((IPeerNode)getEditorInputNode())); Protocol.invokeLater(runnable); } } @@ -188,8 +188,8 @@ public class OverviewEditorPage extends AbstractCustomFormToolkitEditorPage { @Override protected void setInputWithNotify(IEditorInput input) { super.setInputWithNotify(input); - if (getEditorInputNode() instanceof IPeerModel) { - ScannerRunnable runnable = new ScannerRunnable(null, ((IPeerModel)getEditorInputNode())); + if (getEditorInputNode() instanceof IPeerNode) { + ScannerRunnable runnable = new ScannerRunnable(null, ((IPeerNode)getEditorInputNode())); Protocol.invokeLater(runnable); } } @@ -201,24 +201,21 @@ public class OverviewEditorPage extends AbstractCustomFormToolkitEditorPage { public void postDoSave(IProgressMonitor monitor) { // If necessary, write the changed peer attributes final Object input = getEditorInputNode(); - if (input instanceof IPeerModel) { + if (input instanceof IPeerNode) { Runnable runnable = new Runnable() { @Override public void run() { try { - boolean isStatic = ((IPeerModel)input).isStatic(); - if (isStatic) { // Get the persistence service IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class); if (uRIPersistenceService == null) { throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$ } // Save the peer node to the new persistence storage - uRIPersistenceService.write(((IPeerModel)input).getPeer(), null); - } + uRIPersistenceService.write(((IPeerNode)input).getPeer(), null); } catch (IOException e) { // Build up the message template - String template = NLS.bind(Messages.OverviewEditorPage_error_save, ((IPeerModel)input).getName(), Messages.PossibleCause); + String template = NLS.bind(Messages.OverviewEditorPage_error_save, ((IPeerNode)input).getName(), Messages.PossibleCause); // Handle the status StatusHandlerUtil.handleStatus(StatusHelper.getStatus(e), input, template, null, IContextHelpIds.MESSAGE_SAVE_FAILED, OverviewEditorPage.this, null); } @@ -231,12 +228,12 @@ public class OverviewEditorPage extends AbstractCustomFormToolkitEditorPage { @Override public void run() { // Trigger a change event for the original data node - ((IPeerModel)input).fireChangeEvent("properties", null, ((IPeerModel)input).getProperties()); //$NON-NLS-1$ + ((IPeerNode)input).fireChangeEvent("properties", null, ((IPeerNode)input).getProperties()); //$NON-NLS-1$ } }); // Force a scan of the peer - ScannerRunnable runnable2 = new ScannerRunnable(null, ((IPeerModel)input)); + ScannerRunnable runnable2 = new ScannerRunnable(null, ((IPeerNode)input)); Protocol.invokeLater(runnable2); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java index db8cff7c1..cd2f9e825 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/AttributesSection.java @@ -14,7 +14,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.core.runtime.Assert; import org.eclipse.swt.SWT; @@ -24,11 +23,12 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; import org.eclipse.tcf.te.tcf.ui.controls.PeerAttributesTablePart; import org.eclipse.tcf.te.tcf.ui.nls.Messages; @@ -47,7 +47,7 @@ public class AttributesSection extends AbstractSection { private PeerAttributesTablePart tablePart; // Reference to the original data object - /* default */ IPeerModel od; + /* default */ IPeerNode od; // Reference to a copy of the original data /* default */ final IPropertiesContainer odc = new PropertiesContainer(); // Reference to the properties container representing the working copy for the section @@ -62,7 +62,7 @@ public class AttributesSection extends AbstractSection { IPeer.ATTR_NAME, IPeer.ATTR_TRANSPORT_NAME, IPeer.ATTR_IP_HOST, IPeer.ATTR_IP_PORT, "PipeName", //$NON-NLS-1$ "redirect.proxy", //$NON-NLS-1$ - IPeerModelProperties.PROP_VISIBLE, "ClientID" //$NON-NLS-1$ + IPeerNodeProperties.PROP_VISIBLE, "ClientID" //$NON-NLS-1$ }; /* @@ -75,7 +75,7 @@ public class AttributesSection extends AbstractSection { IPeer.ATTR_NAME, IPeer.ATTR_TRANSPORT_NAME, IPeer.ATTR_IP_HOST, IPeer.ATTR_IP_PORT, "PipeName", //$NON-NLS-1$ "redirect.proxy", //$NON-NLS-1$ - IPeerModelProperties.PROP_VISIBLE, "ClientID" //$NON-NLS-1$ + IPeerNodeProperties.PROP_VISIBLE, "ClientID" //$NON-NLS-1$ }; /** @@ -160,8 +160,8 @@ public class AttributesSection extends AbstractSection { if (getManagedForm().getContainer() instanceof AbstractEditorPage && !((AbstractEditorPage)getManagedForm().getContainer()).isDirty()) { Object node = ((AbstractEditorPage)getManagedForm().getContainer()).getEditorInputNode(); - if (node instanceof IPeerModel) { - setupData((IPeerModel)node); + if (node instanceof IPeerNode) { + setupData((IPeerNode)node); } } } else { @@ -178,7 +178,7 @@ public class AttributesSection extends AbstractSection { * * @param node The peer node or null. */ - public void setupData(final IPeerModel node) { + public void setupData(final IPeerNode node) { // If the section is dirty, nothing is changed if (isDirty()) return; @@ -276,7 +276,7 @@ public class AttributesSection extends AbstractSection { * * @param node The GDB Remote configuration node or null. */ - public void extractData(final IPeerModel node) { + public void extractData(final IPeerNode node) { // If no data is available, we are done if (node == null) { return; @@ -330,7 +330,7 @@ public class AttributesSection extends AbstractSection { IPeer newPeer = oldPeer instanceof PeerRedirector ? new PeerRedirector(((PeerRedirector)oldPeer).getParent(), attributes) : new Peer(attributes); // Update the peer node instance (silently) boolean changed = node.setChangeEventsEnabled(false); - node.setProperty(IPeerModelProperties.PROP_INSTANCE, newPeer); + node.setProperty(IPeerNodeProperties.PROP_INSTANCE, newPeer); if (changed) { node.setChangeEventsEnabled(true); } @@ -393,30 +393,12 @@ public class AttributesSection extends AbstractSection { * Updates the control enablement. */ protected void updateEnablement() { - // Determine the input - final Object input = getManagedForm().getInput(); - - // Determine if the peer is a static peer - final AtomicBoolean isStatic = new AtomicBoolean(); - final AtomicBoolean isRemote = new AtomicBoolean(); - Runnable runnable = new Runnable() { - @Override - public void run() { - if (input instanceof IPeerModel) { - isStatic.set(((IPeerModel)input).isStatic()); - isRemote.set(((IPeerModel)input).isRemote()); - } - } - }; - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } - if (tablePart != null) { - tablePart.setReadOnly(!isStatic.get() || isRemote.get()); + // Determine the input + final Object input = getManagedForm().getInput(); + if (input instanceof IPeerNode) { + tablePart.setReadOnly(((IPeerNode)input).getConnectState() != IConnectable.STATE_DISCONNECTED); + } } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java index d36d42cdc..b13904a1f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/GeneralInformationSection.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved. +* Copyright (c) 2011, 2013 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 @@ -13,7 +13,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; @@ -30,6 +29,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties; import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; @@ -38,8 +38,8 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.runtime.utils.StatusHelper; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin; @@ -65,7 +65,7 @@ public class GeneralInformationSection extends AbstractSection { private Label linkStateImage = null; // Reference to the original data object - /* default */ IPeerModel od; + /* default */ IPeerNode od; // Reference to a copy of the original data /* default */ final IPropertiesContainer odc = new PropertiesContainer(); // Reference to the properties container representing the working copy for the section @@ -204,8 +204,8 @@ public class GeneralInformationSection extends AbstractSection { if (getManagedForm().getContainer() instanceof AbstractEditorPage && !((AbstractEditorPage)getManagedForm().getContainer()).isDirty()) { Object node = ((AbstractEditorPage)getManagedForm().getContainer()).getEditorInputNode(); - if (node instanceof IPeerModel) { - setupData((IPeerModel)node); + if (node instanceof IPeerNode) { + setupData((IPeerNode)node); } } } else { @@ -222,7 +222,7 @@ public class GeneralInformationSection extends AbstractSection { * * @param node The peer node or null. */ - public void setupData(final IPeerModel node) { + public void setupData(final IPeerNode node) { // If the section is dirty, nothing is changed if (isDirty()) return; @@ -257,7 +257,7 @@ public class GeneralInformationSection extends AbstractSection { public void run() { // The section is handling the ID, the name and // the link state. Ignore other properties. - odc.setProperty(IPeerModelProperties.PROP_STATE, node.getProperty(IPeerModelProperties.PROP_STATE)); + odc.setProperty(IPeerNodeProperties.PROP_STATE, node.getProperty(IPeerNodeProperties.PROP_STATE)); odc.setProperty(IPeer.ATTR_ID, node.getPeer().getAttributes().get(IPeer.ATTR_ID)); odc.setProperty(IPeer.ATTR_NAME, node.getPeer().getAttributes().get(IPeer.ATTR_NAME)); // Initially, the working copy is a duplicate of the original data copy @@ -282,10 +282,10 @@ public class GeneralInformationSection extends AbstractSection { } if (linkState != null && linkStateImage != null) { - String state = wc.getStringProperty(IPeerModelProperties.PROP_STATE); + String state = wc.getStringProperty(IPeerNodeProperties.PROP_STATE); linkState.setText(Messages.getString("GeneralInformationSection_state_" + (state != null ? state.replace('-', '_') : "_1"))); //$NON-NLS-1$ //$NON-NLS-2$ - switch (wc.getIntProperty(IPeerModelProperties.PROP_STATE)) { + switch (wc.getIntProperty(IPeerNodeProperties.PROP_STATE)) { case 0: linkStateImage.setImage(UIPlugin.getImage(ImageConsts.GOLD_OVR)); break; @@ -324,7 +324,7 @@ public class GeneralInformationSection extends AbstractSection { * * @param node The peer node or null. */ - public void extractData(final IPeerModel node) { + public void extractData(final IPeerNode node) { // If no data is available, we are done if (node == null) { return; @@ -363,7 +363,7 @@ public class GeneralInformationSection extends AbstractSection { IPeer newPeer = oldPeer instanceof PeerRedirector ? new PeerRedirector(((PeerRedirector)oldPeer).getParent(), attributes) : new Peer(attributes); // Update the peer node instance (silently) boolean changed = node.setChangeEventsEnabled(false); - node.setProperty(IPeerModelProperties.PROP_INSTANCE, newPeer); + node.setProperty(IPeerNodeProperties.PROP_INSTANCE, newPeer); if (changed) node.setChangeEventsEnabled(true); } }); @@ -465,27 +465,8 @@ public class GeneralInformationSection extends AbstractSection { // Determine the input final Object input = getManagedForm().getInput(); - // The name control is enabled for static peers - if (nameControl != null) { - final AtomicBoolean isStatic = new AtomicBoolean(); - final AtomicBoolean isRemote = new AtomicBoolean(); - Runnable runnable = new Runnable() { - @Override - public void run() { - if (input instanceof IPeerModel) { - isStatic.set(((IPeerModel)input).isStatic()); - isRemote.set(((IPeerModel)input).isRemote()); - } - } - }; - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } - - SWTControlUtil.setEnabled(nameControl.getEditFieldControl(), isStatic.get() && !isRemote.get()); + if (input instanceof IPeerNode) { + SWTControlUtil.setEnabled(nameControl.getEditFieldControl(), ((IPeerNode)input).getConnectState() == IConnectable.STATE_DISCONNECTED); } } @@ -499,11 +480,11 @@ public class GeneralInformationSection extends AbstractSection { @Override public void run() { // Get all peer model objects - IPeerModel[] peers = Model.getModel().getPeers(); + IPeerNode[] peers = Model.getModel().getPeers(); // Loop them and find the ones which are of our handled types - for (IPeerModel peerModel : peers) { - if (peerModel.isStatic() && !peerModel.equals(od)) { - String name = peerModel.getPeer().getName(); + for (IPeerNode peerNode : peers) { + if (!peerNode.equals(od)) { + String name = peerNode.getPeer().getName(); Assert.isNotNull(name); if (!"".equals(name) && !usedNames.contains(name)) { //$NON-NLS-1$ usedNames.add(name.trim().toUpperCase()); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java index b660de602..3f2296a93 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java @@ -21,9 +21,9 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.ui.forms.parts.AbstractSection; import org.eclipse.tcf.te.ui.swt.DisplayUtil; @@ -43,7 +43,7 @@ public class ServicesSection extends AbstractSection { /* default */ Text remote; // Reference to the original data object - /* default */ IPeerModel od; + /* default */ IPeerNode od; // Reference to a copy of the original data /* default */ final IPropertiesContainer odc = new PropertiesContainer(); @@ -118,8 +118,8 @@ public class ServicesSection extends AbstractSection { if (getManagedForm().getContainer() instanceof AbstractEditorPage && !((AbstractEditorPage)getManagedForm().getContainer()).isDirty()) { Object node = ((AbstractEditorPage)getManagedForm().getContainer()).getEditorInputNode(); - if (node instanceof IPeerModel) { - setupData((IPeerModel)node); + if (node instanceof IPeerNode) { + setupData((IPeerNode)node); } } } @@ -136,7 +136,7 @@ public class ServicesSection extends AbstractSection { * * @param node The peer node or null. */ - public void setupData(final IPeerModel node) { + public void setupData(final IPeerNode node) { // Reset the services query triggered flag if we setup for a new peer model node if (od != node) servicesQueryTriggered = false; @@ -181,10 +181,10 @@ public class ServicesSection extends AbstractSection { public void run() { boolean fireNotification = fireRefreshTabs.get(); - String value = odc.getStringProperty(IPeerModelProperties.PROP_LOCAL_SERVICES); + String value = odc.getStringProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES); fireNotification |= value != null && !value.equals(SWTControlUtil.getText(local)); SWTControlUtil.setText(local, value != null ? value : ""); //$NON-NLS-1$ - value = odc.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES); + value = odc.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES); fireNotification |= value != null && !value.equals(SWTControlUtil.getText(remote)); SWTControlUtil.setText(remote, value != null ? value : ""); //$NON-NLS-1$ @@ -208,18 +208,18 @@ public class ServicesSection extends AbstractSection { public void run() { // Check if we have to run the query at all boolean doQuery = finForceQuery || - (!node.containsKey(IPeerModelProperties.PROP_REMOTE_SERVICES) - && !node.containsKey(IPeerModelProperties.PROP_LOCAL_SERVICES)); + (!node.containsKey(IPeerNodeProperties.PROP_REMOTE_SERVICES) + && !node.containsKey(IPeerNodeProperties.PROP_LOCAL_SERVICES)); if (doQuery) { - ILocatorModelPeerNodeQueryService service = node.getModel().getService(ILocatorModelPeerNodeQueryService.class); + IPeerModelQueryService service = node.getModel().getService(IPeerModelQueryService.class); if (service != null) { - service.queryServicesAsync(node, new ILocatorModelPeerNodeQueryService.DoneQueryServices() { + service.queryServicesAsync(node, new IPeerModelQueryService.DoneQueryServices() { @Override public void doneQueryServices(Throwable error) { // Copy over the service properties - odc.setProperty(IPeerModelProperties.PROP_REMOTE_SERVICES, node.getProperty(IPeerModelProperties.PROP_REMOTE_SERVICES)); - odc.setProperty(IPeerModelProperties.PROP_LOCAL_SERVICES, node.getProperty(IPeerModelProperties.PROP_LOCAL_SERVICES)); + odc.setProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES, node.getProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES)); + odc.setProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES, node.getProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES)); // Setup the data within the UI controls and fire the change notification fireRefreshTabs.set(true); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TcpTransportSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TcpTransportSection.java index 3a1963898..42bc893a7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TcpTransportSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TcpTransportSection.java @@ -14,7 +14,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.dialogs.IDialogSettings; @@ -27,15 +26,16 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.protocol.IChannel; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.core.nodes.interfaces.wire.IWireTypeNetwork; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.ITransportTypes; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.ui.controls.net.RemoteHostAddressControl; @@ -62,7 +62,7 @@ public class TcpTransportSection extends AbstractSection implements IDataExchang private boolean isAutoPort = false; // Reference to the original data object - protected IPeerModel od; + protected IPeerNode od; // Reference to a copy of the original data /* default */final IPropertiesContainer odc = new PropertiesContainer(); // Reference to the properties container representing the working copy for the section @@ -304,8 +304,8 @@ public class TcpTransportSection extends AbstractSection implements IDataExchang // Leave everything unchanged if the page is in dirty state if (getManagedForm().getContainer() instanceof AbstractEditorPage && !((AbstractEditorPage) getManagedForm().getContainer()).isDirty()) { Object node = ((AbstractEditorPage) getManagedForm().getContainer()).getEditorInputNode(); - if (node instanceof IPeerModel) { - setupData((IPeerModel) node); + if (node instanceof IPeerNode) { + setupData((IPeerNode) node); } } } @@ -354,7 +354,7 @@ public class TcpTransportSection extends AbstractSection implements IDataExchang * * @param node The peer node or null. */ - public void setupData(final IPeerModel node) { + public void setupData(final IPeerNode node) { // If the section is dirty, nothing is changed if (isDirty()) return; @@ -460,7 +460,7 @@ public class TcpTransportSection extends AbstractSection implements IDataExchang * * @param node The peer model node or null. */ - public void extractData(final IPeerModel node) { + public void extractData(final IPeerNode node) { // If no data is available, we are done if (node == null) { return; @@ -521,15 +521,15 @@ public class TcpTransportSection extends AbstractSection implements IDataExchang IPeer newPeer = oldPeer instanceof PeerRedirector ? new PeerRedirector(((PeerRedirector) oldPeer).getParent(), attributes) : new Peer(attributes); // Update the peer node instance (silently) boolean changed = node.setChangeEventsEnabled(false); - node.setProperty(IPeerModelProperties.PROP_INSTANCE, newPeer); + node.setProperty(IPeerNodeProperties.PROP_INSTANCE, newPeer); // As the transport changed, we have to reset the state back to "unknown" // and clear out the services and DNS markers - node.setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_UNKNOWN); + node.setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_UNKNOWN); node.setProperty("dns.name.transient", null); //$NON-NLS-1$ node.setProperty("dns.lastIP.transient", null); //$NON-NLS-1$ node.setProperty("dns.skip.transient", null); //$NON-NLS-1$ - ILocatorModelUpdateService service = node.getModel().getService(ILocatorModelUpdateService.class); + IPeerModelUpdateService service = node.getModel().getService(IPeerModelUpdateService.class); service.updatePeerServices(node, null, null); if (changed) { @@ -656,25 +656,9 @@ public class TcpTransportSection extends AbstractSection implements IDataExchang // Determine the input final Object input = od; // getManagedForm().getInput(); - // Determine if the peer is a static peer - final AtomicBoolean isStatic = new AtomicBoolean(); - final AtomicBoolean isRemote = new AtomicBoolean(); - Runnable runnable = new Runnable() { - @Override - public void run() { - if (input instanceof IPeerModel) { - isStatic.set(((IPeerModel) input).isStatic()); - isRemote.set(((IPeerModel) input).isRemote()); - } - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - - boolean enabled = !isReadOnly() && (input == null || (isStatic.get() && !isRemote.get())); - if (addressControl != null) addressControl.setEnabled(enabled); - if (portControl != null) portControl.setEnabled(enabled && !isAutoPort); + boolean enabled = !isReadOnly() && (!(input instanceof IPeerNode) || ((IPeerNode)input).getConnectState() == IConnectable.STATE_DISCONNECTED); + if (addressControl != null) addressControl.setEnabled(enabled); + if (portControl != null) portControl.setEnabled(enabled && !isAutoPort); } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java index 47972e8da..9c89a206a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.dialogs.IDialogSettings; @@ -27,14 +26,15 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.protocol.IChannel; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.tcf.core.Tcf; import org.eclipse.tcf.te.tcf.core.interfaces.ITransportTypes; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; import org.eclipse.tcf.te.tcf.ui.controls.CustomTransportPanel; import org.eclipse.tcf.te.tcf.ui.controls.PipeTransportPanel; @@ -61,7 +61,7 @@ public class TransportSection extends AbstractSection implements IDataExchangeNo /* default */TransportSectionTypePanelControl transportTypePanelControl = null; // Reference to the original data object - protected IPeerModel od; + protected IPeerNode od; // Reference to a copy of the original data /* default */final IPropertiesContainer odc = new PropertiesContainer(); // Reference to the properties container representing the working copy for the section @@ -237,8 +237,8 @@ public class TransportSection extends AbstractSection implements IDataExchangeNo // Leave everything unchanged if the page is in dirty state if (getManagedForm().getContainer() instanceof AbstractEditorPage && !((AbstractEditorPage) getManagedForm().getContainer()).isDirty()) { Object node = ((AbstractEditorPage) getManagedForm().getContainer()).getEditorInputNode(); - if (node instanceof IPeerModel) { - setupData((IPeerModel) node); + if (node instanceof IPeerNode) { + setupData((IPeerNode) node); } } } @@ -289,7 +289,7 @@ public class TransportSection extends AbstractSection implements IDataExchangeNo * * @param node The peer node or null. */ - public void setupData(final IPeerModel node) { + public void setupData(final IPeerNode node) { // If the section is dirty, nothing is changed if (isDirty()) return; @@ -402,7 +402,7 @@ public class TransportSection extends AbstractSection implements IDataExchangeNo * * @param node The GDB Remote configuration node or null. */ - public void extractData(final IPeerModel node) { + public void extractData(final IPeerNode node) { // If no data is available, we are done if (node == null) { return; @@ -465,16 +465,16 @@ public class TransportSection extends AbstractSection implements IDataExchangeNo .getParent(), attributes) : new Peer(attributes); // Update the peer node instance (silently) boolean changed = node.setChangeEventsEnabled(false); - node.setProperty(IPeerModelProperties.PROP_INSTANCE, newPeer); + node.setProperty(IPeerNodeProperties.PROP_INSTANCE, newPeer); // As the transport changed, we have to reset the state back to "unknown" // and clear out the services and DNS markers - node.setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_UNKNOWN); + node.setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_UNKNOWN); node.setProperty("dns.name.transient", null); //$NON-NLS-1$ node.setProperty("dns.lastIP.transient", null); //$NON-NLS-1$ node.setProperty("dns.skip.transient", null); //$NON-NLS-1$ - ILocatorModelUpdateService service = node.getModel() - .getService(ILocatorModelUpdateService.class); + IPeerModelUpdateService service = node.getModel() + .getService(IPeerModelUpdateService.class); service.updatePeerServices(node, null, null); if (changed) { @@ -605,25 +605,9 @@ public class TransportSection extends AbstractSection implements IDataExchangeNo // Determine the input final Object input = od; // getManagedForm().getInput(); - // Determine if the peer is a static peer - final AtomicBoolean isStatic = new AtomicBoolean(); - final AtomicBoolean isRemote = new AtomicBoolean(); - Runnable runnable = new Runnable() { - @Override - public void run() { - if (input instanceof IPeerModel) { - isStatic.set(((IPeerModel) input).isStatic()); - isRemote.set(((IPeerModel) input).isRemote()); - } - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - // The transport type control is enabled for static peers if (transportTypeControl != null) { - boolean enabled = !isReadOnly() && (input == null || (isStatic.get() && !isRemote.get())); + boolean enabled = !isReadOnly() && (!(input instanceof IPeerNode) || ((IPeerNode)input).getConnectState() == IConnectable.STATE_DISCONNECTED); SWTControlUtil.setEnabled(transportTypeControl.getEditFieldControl(), enabled && SWTControlUtil.getItemCount(transportTypeControl.getEditFieldControl()) > 1); if (transportTypePanelControl != null) { IWizardConfigurationPanel panel = transportTypePanelControl.getConfigurationPanel(transportTypeControl.getSelectedTransportType()); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java index ef48a1a81..62e9b4204 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java @@ -15,7 +15,7 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Filter implementation filtering peers not started by the current user. @@ -28,18 +28,14 @@ public class PeersByCurrentUserFilter extends ViewerFilter { */ @Override public boolean select(final Viewer viewer, final Object parentElement, final Object element) { - if (element instanceof IPeerModel) { + if (element instanceof IPeerNode) { final AtomicReference user = new AtomicReference(); Runnable runnable = new Runnable() { @Override public void run() { - IPeerModel peerModel = (IPeerModel)element; - if (!peerModel.isStatic()) { - user.set(peerModel.getPeer().getUserName()); - } else { - user.set(USERNAME); - } + IPeerNode peerNode = (IPeerNode)element; + user.set(peerNode.getPeer().getUserName()); } }; Assert.isTrue(!Protocol.isDispatchThread()); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/RedirectPeersFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/RedirectPeersFilter.java index 2bf6b848f..0f161ddb1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/RedirectPeersFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/RedirectPeersFilter.java @@ -1,48 +1,48 @@ -/******************************************************************************* - * Copyright (c) 2011, 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.ui.filter; - -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.ui.views.interfaces.IRoot; - -/** - * Filter implementation filtering redirected peers from the root level. - */ -public class RedirectPeersFilter extends ViewerFilter { - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - @Override - public boolean select(final Viewer viewer, final Object parentElement, final Object element) { - if (element instanceof IPeerModel && parentElement instanceof IRoot) { - final AtomicReference parent = new AtomicReference(); - Runnable runnable = new Runnable() { - @Override - public void run() { - parent.set(((IPeerModel)element).getParent(IPeerModel.class)); - } - }; - Assert.isTrue(!Protocol.isDispatchThread()); - Protocol.invokeAndWait(runnable); - - return parent.get() == null; - } - - return true; - } - -} +/******************************************************************************* + * Copyright (c) 2011, 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.ui.filter; + +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.ui.views.interfaces.IRoot; + +/** + * Filter implementation filtering redirected peers from the root level. + */ +public class RedirectPeersFilter extends ViewerFilter { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + @Override + public boolean select(final Viewer viewer, final Object parentElement, final Object element) { + if (element instanceof IPeerNode && parentElement instanceof IRoot) { + final AtomicReference parent = new AtomicReference(); + Runnable runnable = new Runnable() { + @Override + public void run() { + parent.set(((IPeerNode)element).getParent(IPeerNode.class)); + } + }; + Assert.isTrue(!Protocol.isDispatchThread()); + Protocol.invokeAndWait(runnable); + + return parent.get() == null; + } + + return true; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/UnreachablePeersFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/UnreachablePeersFilter.java index fe6708ab3..d1f122400 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/UnreachablePeersFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/UnreachablePeersFilter.java @@ -1,52 +1,52 @@ -/******************************************************************************* - * Copyright (c) 2011 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.ui.filter; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; - -/** - * Filter implementation filtering unreachable peers. - */ -public class UnreachablePeersFilter extends ViewerFilter { - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - - // Filter only elements of simulator IPeerModel - if (element instanceof IPeerModel) { - final IPeerModel peerModel = (IPeerModel)element; - - // Determine the current action of the peer model - final int[] state = new int[1]; - if (Protocol.isDispatchThread()) { - state[0] = peerModel.getIntProperty(IPeerModelProperties.PROP_STATE); - } else { - Protocol.invokeAndWait(new Runnable() { - @Override - public void run() { - state[0] = peerModel.getIntProperty(IPeerModelProperties.PROP_STATE); - } - }); - } - - return state[0] != IPeerModelProperties.STATE_NOT_REACHABLE && state[0] != IPeerModelProperties.STATE_ERROR; - } - - return true; - } - -} +/******************************************************************************* + * Copyright (c) 2011 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.ui.filter; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; + +/** + * Filter implementation filtering unreachable peers. + */ +public class UnreachablePeersFilter extends ViewerFilter { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { + + // Filter only elements of simulator IPeerNode + if (element instanceof IPeerNode) { + final IPeerNode peerNode = (IPeerNode)element; + + // Determine the current action of the peer model + final int[] state = new int[1]; + if (Protocol.isDispatchThread()) { + state[0] = peerNode.getIntProperty(IPeerNodeProperties.PROP_STATE); + } else { + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + state[0] = peerNode.getIntProperty(IPeerNodeProperties.PROP_STATE); + } + }); + } + + return state[0] != IPeerNodeProperties.STATE_NOT_REACHABLE && state[0] != IPeerNodeProperties.STATE_ERROR; + } + + return true; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerModelEditorHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerModelEditorHandlerDelegate.java deleted file mode 100644 index 25b329d69..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerModelEditorHandlerDelegate.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ - -package org.eclipse.tcf.te.tcf.ui.handler; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate; -import org.eclipse.tcf.te.ui.views.editor.EditorInput; -import org.eclipse.ui.IEditorInput; - -/** - * AbstractPeerModelEditorHandlerDelegate - */ -public abstract class AbstractPeerModelEditorHandlerDelegate implements IEditorHandlerDelegate { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate#getEditorInput(java.lang.Object) - */ - @Override - public IEditorInput getEditorInput(Object element) { - IPeerModel model = (IPeerModel)Platform.getAdapterManager().getAdapter(element, IPeerModel.class); - if (model == null && element instanceof IAdaptable) { - model = (IPeerModel)((IAdaptable)element).getAdapter(IPeerModel.class); - } - return new EditorInput(model != null ? model : element); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerNodeEditorHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerNodeEditorHandlerDelegate.java new file mode 100644 index 000000000..963f34125 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerNodeEditorHandlerDelegate.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2012, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.tcf.ui.handler; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate; +import org.eclipse.tcf.te.ui.views.editor.EditorInput; +import org.eclipse.ui.IEditorInput; + +/** + * AbstractPeerNodeEditorHandlerDelegate + */ +public abstract class AbstractPeerNodeEditorHandlerDelegate implements IEditorHandlerDelegate { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate#getEditorInput(java.lang.Object) + */ + @Override + public IEditorInput getEditorInput(Object element) { + IPeerNode model = (IPeerNode)Platform.getAdapterManager().getAdapter(element, IPeerNode.class); + if (model == null && element instanceof IAdaptable) { + model = (IPeerNode)((IAdaptable)element).getAdapter(IPeerNode.class); + } + return new EditorInput(model != null ? model : element); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java index 2c451a72f..d85fa1d91 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java @@ -13,7 +13,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.commands.AbstractHandler; @@ -40,8 +39,8 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.runtime.utils.StatusHelper; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.ui.nls.Messages; @@ -116,12 +115,12 @@ public class DeleteHandler extends AbstractHandler { if (selection instanceof ITreeSelection && !selection.isEmpty()) { // Assume the selection to be deletable canDelete = true; - // Iterate the selection. All elements must be of type IPeerModel + // Iterate the selection. All elements must be of type IPeerNode for (TreePath treePath : ((ITreeSelection)selection).getPaths()) { // Get the element Object element = treePath.getLastSegment(); // This handler will take care of peer model nodes only - if (!(element instanceof IPeerModel)) { + if (!(element instanceof IPeerNode)) { canDelete = false; break; } @@ -131,37 +130,6 @@ public class DeleteHandler extends AbstractHandler { IDeleteHandlerDelegate delegate = service != null ? service.getDelegate(element, IDeleteHandlerDelegate.class) : null; // If a delegate is available, ask the handler first if the given element is currently deletable if (delegate != null) canDelete = delegate.canDelete(treePath); - // If the element is still marked deletable, apply the default check too - if (canDelete) { - // Determine if the selected peer model is static - boolean isStatic = isStatic((IPeerModel)element); - // Determine if the selected peer model represents an agent - // started by the current user - boolean isStartedByCurrentUser = isStartedByCurrentUser((IPeerModel)element); - // Static nodes can be handled the one way or the other. - // For dynamic nodes, "delete" means "remove from ", - // and this works only if the parent category is not "Neighborhood". - if (!isStatic) { - // Determine the parent category of the current tree path - ICategory category = treePath.getFirstSegment() instanceof ICategory ? (ICategory)treePath.getFirstSegment() : null; - if (category != null) { - if (IUIConstants.ID_CAT_NEIGHBORHOOD.equals(category.getId())) { - canDelete = false; - break; - } - else if (IUIConstants.ID_CAT_MY_TARGETS.equals(category.getId())) { - if (isStartedByCurrentUser) { - canDelete = false; - break; - } - } - else if (!IUIConstants.ID_CAT_FAVORITES.equals(category.getId())) { - canDelete = false; - break; - } - } - } - } if (!canDelete) { break; @@ -172,64 +140,6 @@ public class DeleteHandler extends AbstractHandler { return canDelete; } - /** - * Determines if the given peer model node is a static node. - * - * @param node The peer model node. Must not be null. - * @return True if the node is static, false otherwise. - */ - private boolean isStatic(final IPeerModel node) { - Assert.isNotNull(node); - - final AtomicBoolean isStatic = new AtomicBoolean(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - isStatic.set(node.isStatic()); - } - }; - - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } - - return isStatic.get(); - } - - /** - * Determines if the given peer model node represents an agent started - * by the current user. - * - * @param node The peer model node. Must not be null. - * @return True if the node represents and agent started by the current user, - * false otherwise. - */ - private boolean isStartedByCurrentUser(final IPeerModel node) { - Assert.isNotNull(node); - - final AtomicReference username = new AtomicReference(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - username.set(node.getPeer().getUserName()); - } - }; - - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } - - return System.getProperty("user.name").equals(username.get()); //$NON-NLS-1$ - } - /** * Internal helper class to describe the delete operation to perform. */ @@ -238,7 +148,7 @@ public class DeleteHandler extends AbstractHandler { public enum TYPE { Remove, Unlink } // The element to operate on - public IPeerModel node; + public IPeerNode node; // The operation type to perform public TYPE type; // In case of an "unlink" operation, the parent category @@ -359,7 +269,7 @@ public class DeleteHandler extends AbstractHandler { Protocol.invokeLater(new Runnable() { @Override public void run() { - ILocatorModelRefreshService service = Model.getModel().getService(ILocatorModelRefreshService.class); + IPeerModelRefreshService service = Model.getModel().getService(IPeerModelRefreshService.class); // Refresh the model now (must be executed within the TCF dispatch thread) if (service != null) service.refresh(new Callback() { @Override @@ -391,22 +301,22 @@ public class DeleteHandler extends AbstractHandler { List operations = new ArrayList(); - // Iterate the selection. All elements must be of type IPeerModel + // Iterate the selection. All elements must be of type IPeerNode for (TreePath treePath : selection.getPaths()) { // Get the element Object element = treePath.getLastSegment(); - Assert.isTrue(element instanceof IPeerModel); - IPeerModel node = (IPeerModel)element; + Assert.isTrue(element instanceof IPeerNode); + IPeerNode node = (IPeerNode)element; - boolean isStatic = isStatic(node); ICategory category = treePath.getFirstSegment() instanceof ICategory ? (ICategory)treePath.getFirstSegment() : null; - if (category == null && isStatic) { + if (category == null) { Operation op = new Operation(); op.node = node; op.type = Operation.TYPE.Remove; operations.add(op); - } else if (category != null) { + } + else { // If the parent category is "Favorites", it is always // an "unlink" operation if (IUIConstants.ID_CAT_FAVORITES.equals(category.getId())) { @@ -423,11 +333,7 @@ public class DeleteHandler extends AbstractHandler { Operation op = new Operation(); op.node = node; - if (isStatic) { - op.type = Operation.TYPE.Remove; - } else { - op.type = Operation.TYPE.Unlink; - } + op.type = Operation.TYPE.Remove; op.parentCategory = category; operations.add(op); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RedirectHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RedirectHandler.java index 995e87b96..f46a4ab54 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RedirectHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RedirectHandler.java @@ -34,13 +34,13 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.runtime.utils.StatusHelper; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; -import org.eclipse.tcf.te.tcf.ui.dialogs.RedirectAgentSelectionDialog; +import org.eclipse.tcf.te.tcf.ui.dialogs.RedirectPeerSelectionDialog; import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.ui.swt.DisplayUtil; @@ -63,11 +63,11 @@ public class RedirectHandler extends AbstractHandler { if (selection instanceof IStructuredSelection && !selection.isEmpty()) { // Redirect is supporting single selection only Object candidate = ((IStructuredSelection)selection).getFirstElement(); - if (candidate instanceof IPeerModel) { - final IPeerModel peerModel = (IPeerModel)candidate; + if (candidate instanceof IPeerNode) { + final IPeerNode peerNode = (IPeerNode)candidate; // Create the agent selection dialog - RedirectAgentSelectionDialog dialog = new RedirectAgentSelectionDialog(HandlerUtil.getActiveShell(event), null) { + RedirectPeerSelectionDialog dialog = new RedirectPeerSelectionDialog(HandlerUtil.getActiveShell(event), null) { @Override protected void configureTableViewer(TableViewer viewer) { Assert.isNotNull(viewer); @@ -80,7 +80,7 @@ public class RedirectHandler extends AbstractHandler { filter.add(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { - if (peerModel.equals(element)) { + if (peerNode.equals(element)) { return false; } return true; @@ -97,13 +97,13 @@ public class RedirectHandler extends AbstractHandler { selection = dialog.getSelection(); if (selection instanceof IStructuredSelection && !selection.isEmpty()) { candidate = ((IStructuredSelection)selection).getFirstElement(); - if (candidate instanceof IPeerModel) { - final IPeerModel proxy = (IPeerModel)candidate; + if (candidate instanceof IPeerNode) { + final IPeerNode proxy = (IPeerNode)candidate; Protocol.invokeLater(new Runnable() { @Override public void run() { - redirect(peerModel, proxy); + redirect(peerNode, proxy); DisplayUtil.safeAsyncExec(new Runnable() { @Override @@ -111,7 +111,7 @@ public class RedirectHandler extends AbstractHandler { IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof CommonNavigator) { CommonNavigator navigator = (CommonNavigator)part; - navigator.selectReveal(new StructuredSelection(peerModel)); + navigator.selectReveal(new StructuredSelection(peerNode)); } } }); @@ -132,19 +132,19 @@ public class RedirectHandler extends AbstractHandler { *

* The method must be called from within the TCF dispatch thread. * - * @param peerModel The peer to redirect. Must not be null. + * @param peerNode The peer to redirect. Must not be null. * @param proxy The proxy. Must not be null */ - public void redirect(IPeerModel peerModel, IPeerModel proxy) { - Assert.isNotNull(peerModel); + public void redirect(IPeerNode peerNode, IPeerNode proxy) { + Assert.isNotNull(peerNode); Assert.isNotNull(proxy); Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ // Get the peer attributes Map attributes = new HashMap(); - attributes.putAll(peerModel.getPeer().getAttributes()); + attributes.putAll(peerNode.getPeer().getAttributes()); // Set the redirection - attributes.put(IPeerModelProperties.PROP_REDIRECT_PROXY, proxy.getPeerId()); + attributes.put(IPeerNodeProperties.PROP_REDIRECT_PROXY, proxy.getPeerId()); try { IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class); @@ -156,22 +156,22 @@ public class RedirectHandler extends AbstractHandler { // Create a peer redirector PeerRedirector redirector = new PeerRedirector(proxy.getPeer(), attributes); // And update the instance - peerModel.setProperty(IPeerModelProperties.PROP_INSTANCE, redirector); + peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, redirector); // Associate proxy (parent) and peer model (child) - peerModel.setParent(proxy); - Model.getModel().getService(ILocatorModelUpdateService.class).addChild(peerModel); + peerNode.setParent(proxy); + Model.getModel().getService(IPeerModelUpdateService.class).addChild(peerNode); // Trigger a refresh of the locator model in a later dispatch cycle Protocol.invokeLater(new Runnable() { @Override public void run() { - Model.getModel().getService(ILocatorModelRefreshService.class).refresh(null); + Model.getModel().getService(IPeerModelRefreshService.class).refresh(null); } }); } catch (IOException e) { String template = NLS.bind(Messages.RedirectHandler_error_redirectFailed, Messages.PossibleCause); - StatusHandlerUtil.handleStatus(StatusHelper.getStatus(e), peerModel, template, + StatusHandlerUtil.handleStatus(StatusHelper.getStatus(e), peerNode, template, Messages.RedirectHandler_error_title, IContextHelpIds.MESSAGE_REDIRECT_FAILED, this, null); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RefreshHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RefreshHandler.java index 2fc20540a..bbc12e44a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RefreshHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RefreshHandler.java @@ -27,9 +27,9 @@ import org.eclipse.tcf.te.runtime.callback.Callback; import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.tcf.core.async.CallbackInvocationDelegate; import org.eclipse.tcf.te.tcf.locator.ScannerRunnable; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.ui.views.ViewsUtil; import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; import org.eclipse.ui.handlers.HandlerUtil; @@ -72,18 +72,18 @@ public class RefreshHandler extends AbstractHandler { // The selection must be a structured selection and must not be empty if (selection instanceof IStructuredSelection && !selection.isEmpty()) { // The list of locator model instances to refresh - List locatorToRefresh = new ArrayList(); - List peerToRefresh = new ArrayList(); + List locatorToRefresh = new ArrayList(); + List peerToRefresh = new ArrayList(); // Iterate the selection and determine the model instances Iterator iterator = ((IStructuredSelection)selection).iterator(); while (iterator.hasNext()) { Object element = iterator.next(); - Assert.isTrue(element instanceof IPeerModel); - IPeerModel node = (IPeerModel)element; + Assert.isTrue(element instanceof IPeerNode); + IPeerNode node = (IPeerNode)element; // Get the associated locator model of the node - ILocatorModel model = (ILocatorModel)node.getAdapter(ILocatorModel.class); + IPeerModel model = (IPeerModel)node.getAdapter(IPeerModel.class); Assert.isNotNull(model); // If not yet in the list, add it if (!locatorToRefresh.contains(model)) { @@ -97,14 +97,14 @@ public class RefreshHandler extends AbstractHandler { // Trigger an refresh on all determined models and wait for the // refresh to complete. Once completed, fire the parent callback. AsyncCallbackCollector collector = new AsyncCallbackCollector(callback, new CallbackInvocationDelegate()); - for (ILocatorModel model : locatorToRefresh) { - final ILocatorModel finModel = model; + for (IPeerModel model : locatorToRefresh) { + final IPeerModel finModel = model; final ICallback innerCallback = new AsyncCallbackCollector.SimpleCollectorCallback(collector); Runnable runnable = new Runnable() { @Override public void run() { - finModel.getService(ILocatorModelRefreshService.class).refresh(new Callback() { + finModel.getService(IPeerModelRefreshService.class).refresh(new Callback() { @Override protected void internalDone(Object caller, IStatus status) { innerCallback.done(this, Status.OK_STATUS); @@ -115,8 +115,8 @@ public class RefreshHandler extends AbstractHandler { Protocol.invokeLater(runnable); } - for (IPeerModel model : peerToRefresh) { - final IPeerModel finModel = model; + for (IPeerNode model : peerToRefresh) { + final IPeerNode finModel = model; final ICallback innerCallback = new AsyncCallbackCollector.SimpleCollectorCallback(collector); Runnable runnable = new Runnable() { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RenameHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RenameHandler.java index cdb86621f..3a7be0ccf 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RenameHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/RenameHandler.java @@ -38,10 +38,10 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.runtime.utils.StatusHelper; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; @@ -103,8 +103,8 @@ public class RenameHandler extends AbstractHandler { Iterator iterator = ((IStructuredSelection)selection).iterator(); while (iterator.hasNext()) { Object element = iterator.next(); - Assert.isTrue(element instanceof IPeerModel); - final IPeerModel node = (IPeerModel)element; + Assert.isTrue(element instanceof IPeerNode); + final IPeerNode node = (IPeerNode)element; RenameDialog dialog = createRenameDialog(shell, node); int ok = dialog.open(); @@ -135,7 +135,7 @@ public class RenameHandler extends AbstractHandler { IPeer newPeer = oldPeer instanceof PeerRedirector ? new PeerRedirector(((PeerRedirector)oldPeer).getParent(), attributes) : new Peer(attributes); // Update the peer node instance (silently) boolean changed = node.setChangeEventsEnabled(false); - node.setProperty(IPeerModelProperties.PROP_INSTANCE, newPeer); + node.setProperty(IPeerNodeProperties.PROP_INSTANCE, newPeer); if (changed) { node.setChangeEventsEnabled(true); } @@ -174,7 +174,7 @@ public class RenameHandler extends AbstractHandler { Protocol.invokeLater(new Runnable() { @Override public void run() { - final ILocatorModelRefreshService service = Model.getModel().getService(ILocatorModelRefreshService.class); + final IPeerModelRefreshService service = Model.getModel().getService(IPeerModelRefreshService.class); // Refresh the model now (must be executed within the TCF dispatch thread) if (service != null) { service.refresh(new Callback() { @@ -204,7 +204,7 @@ public class RenameHandler extends AbstractHandler { * * @return The renaming dialog. */ - private RenameDialog createRenameDialog(final Shell shell, final IPeerModel node) { + private RenameDialog createRenameDialog(final Shell shell, final IPeerNode node) { Assert.isNotNull(node); final AtomicReference name = new AtomicReference(); @@ -215,17 +215,15 @@ public class RenameHandler extends AbstractHandler { public void run() { name.set(node.getPeer().getName()); - ILocatorModel model = Model.getModel(); + IPeerModel model = Model.getModel(); Assert.isNotNull(model); - IPeerModel[] peers = model.getPeers(); - for (IPeerModel peer : peers) { - if (peer.isStatic()) { + IPeerNode[] peers = model.getPeers(); + for (IPeerNode peer : peers) { String name = peer.getPeer().getName(); Assert.isNotNull(name); if (!"".equals(name) && !usedNames.contains(name)) { //$NON-NLS-1$ usedNames.add(name.trim().toUpperCase()); } - } } } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ResetRedirectHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ResetRedirectHandler.java index 754d5d94e..c1229abf8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ResetRedirectHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ResetRedirectHandler.java @@ -27,10 +27,10 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; import org.eclipse.tcf.te.runtime.utils.StatusHelper; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds; import org.eclipse.tcf.te.tcf.ui.nls.Messages; @@ -51,13 +51,13 @@ public class ResetRedirectHandler extends AbstractHandler { if (selection instanceof IStructuredSelection && !selection.isEmpty()) { // Redirect is supporting single selection only Object candidate = ((IStructuredSelection)selection).getFirstElement(); - if (candidate instanceof IPeerModel) { - final IPeerModel peerModel = (IPeerModel)candidate; + if (candidate instanceof IPeerNode) { + final IPeerNode peerNode = (IPeerNode)candidate; Protocol.invokeLater(new Runnable() { @Override public void run() { - resetRedirect(peerModel); + resetRedirect(peerNode); } }); } @@ -71,19 +71,19 @@ public class ResetRedirectHandler extends AbstractHandler { *

* The method must be called from within the TCF dispatch thread. * - * @param peerModel The peer to reset. Must not be null. + * @param peerNode The peer to reset. Must not be null. */ - public void resetRedirect(IPeerModel peerModel) { - Assert.isNotNull(peerModel); + public void resetRedirect(IPeerNode peerNode) { + Assert.isNotNull(peerNode); Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ // Get the peer attributes Map attributes = new HashMap(); - attributes.putAll(peerModel.getPeer().getAttributes()); + attributes.putAll(peerNode.getPeer().getAttributes()); // Redirection set? - if (attributes.get(IPeerModelProperties.PROP_REDIRECT_PROXY) != null) { + if (attributes.get(IPeerNodeProperties.PROP_REDIRECT_PROXY) != null) { // Remove the redirection - attributes.remove(IPeerModelProperties.PROP_REDIRECT_PROXY); + attributes.remove(IPeerNodeProperties.PROP_REDIRECT_PROXY); try { // Save it @@ -96,22 +96,22 @@ public class ResetRedirectHandler extends AbstractHandler { uRIPersistenceService.write(peer, null); // And update the instance - peerModel.setProperty(IPeerModelProperties.PROP_INSTANCE, peer); + peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer); // Reset proxy (parent) and peer model (child) association - Model.getModel().getService(ILocatorModelUpdateService.class).removeChild(peerModel); - peerModel.setParent(null); + Model.getModel().getService(IPeerModelUpdateService.class).removeChild(peerNode); + peerNode.setParent(null); // Trigger a refresh of the locator model in a later dispatch cycle Protocol.invokeLater(new Runnable() { @Override public void run() { - Model.getModel().getService(ILocatorModelRefreshService.class).refresh(null); + Model.getModel().getService(IPeerModelRefreshService.class).refresh(null); } }); } catch (IOException e) { String template = NLS.bind(Messages.ResetRedirectHandler_error_resetRedirectFailed, Messages.PossibleCause); - StatusHandlerUtil.handleStatus(StatusHelper.getStatus(e), peerModel, template, + StatusHandlerUtil.handleStatus(StatusHelper.getStatus(e), peerNode, template, Messages.ResetRedirectHandler_error_title, IContextHelpIds.MESSAGE_RESET_REDIRECT_FAILED, this, null); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java index 3d62cd087..b53aaa320 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java @@ -30,7 +30,7 @@ import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IDebugService; import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.steps.StartDebuggerStep.IDelegate; import org.eclipse.tcf.te.ui.async.UICallbackInvocationDelegate; import org.eclipse.ui.IEditorInput; @@ -78,8 +78,8 @@ public class StartDebugCommandHandler extends AbstractHandler { Iterator iterator = ((IStructuredSelection)selection).iterator(); while (iterator.hasNext()) { final Object element = iterator.next(); - if (element instanceof IPeerModel) { - startDebugger((IPeerModel)element, new AsyncCallbackCollector.SimpleCollectorCallback(collector)); + if (element instanceof IPeerNode) { + startDebugger((IPeerNode)element, new AsyncCallbackCollector.SimpleCollectorCallback(collector)); } } @@ -93,26 +93,26 @@ public class StartDebugCommandHandler extends AbstractHandler { /** * Starts the debugger for the given peer model node. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @param callback The callback. Must not be null. */ - public void startDebugger(final IPeerModel peerModel, final ICallback callback) { - Assert.isNotNull(peerModel); + public void startDebugger(final IPeerNode peerNode, final ICallback callback) { + Assert.isNotNull(peerNode); Assert.isNotNull(callback); - IDebugService dbgService = ServiceManager.getInstance().getService(peerModel, IDebugService.class, false); + IDebugService dbgService = ServiceManager.getInstance().getService(peerNode, IDebugService.class, false); if (dbgService != null) { final IProgressMonitor monitor = new NullProgressMonitor(); IPropertiesContainer props = new PropertiesContainer(); - dbgService.attach(peerModel, props, monitor, new Callback() { + dbgService.attach(peerNode, props, monitor, new Callback() { @Override protected void internalDone(Object caller, IStatus status) { // Check if there is a delegate registered - IDelegateService service = ServiceManager.getInstance().getService(peerModel, IDelegateService.class, false); - IDelegate delegate = service != null ? service.getDelegate(peerModel, IDelegate.class) : null; + IDelegateService service = ServiceManager.getInstance().getService(peerNode, IDelegateService.class, false); + IDelegate delegate = service != null ? service.getDelegate(peerNode, IDelegate.class) : null; if (delegate != null) { - delegate.postAttachDebugger(peerModel, monitor, callback); + delegate.postAttachDebugger(peerNode, monitor, callback); } else { callback.done(caller, status); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/help/IContextHelpIds.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/help/IContextHelpIds.java index ce19cfe2a..4869fb75b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/help/IContextHelpIds.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/help/IContextHelpIds.java @@ -45,7 +45,7 @@ public interface IContextHelpIds { /** * TCF agent selection dialog. */ - public final static String AGENT_SELECTION_DIALOG = PREFIX + "AgentSelectionDialog"; //$NON-NLS-1$ + public final static String AGENT_SELECTION_DIALOG = PREFIX + "PeerSelectionDialog"; //$NON-NLS-1$ // ***** Message dialog boxes ***** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java index 072d2142f..f52a2153d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java @@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.ui.internal; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; import org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler; import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode; @@ -39,8 +39,8 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester return ((NewWizardNode)receiver).getWizardId().equals(expectedValue); } - if ("isValidSimulatorConfig".equals(property) && receiver instanceof IPeerModel && expectedValue instanceof Boolean) { //$NON-NLS-1$ - SimulatorUtils.Result simulator = SimulatorUtils.getSimulatorService((IPeerModel)receiver); + if ("isValidSimulatorConfig".equals(property) && receiver instanceof IPeerNode && expectedValue instanceof Boolean) { //$NON-NLS-1$ + SimulatorUtils.Result simulator = SimulatorUtils.getSimulatorService((IPeerNode)receiver); boolean valid = simulator != null && simulator.service.isValidConfig(receiver, simulator.settings); return ((Boolean)expectedValue).booleanValue() == valid; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java index 232c654eb..4aaea8277 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java @@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.ui.internal.adapters; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.views.editor.EditorInput; import org.eclipse.tcf.te.ui.views.interfaces.IEditorSaveAsAdapter; import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable; @@ -32,7 +32,7 @@ public class AdapterFactory implements IAdapterFactory { ILabelProvider.class, IPersistableElement.class, ICategorizable.class, - IPeerModel.class, + IPeerNode.class, IEditorSaveAsAdapter.class }; @@ -41,12 +41,12 @@ public class AdapterFactory implements IAdapterFactory { */ @Override public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adaptableObject instanceof IPeerModel) { + if (adaptableObject instanceof IPeerNode) { if (ILabelProvider.class.equals(adapterType)) { return labelProvider; } if (IPersistableElement.class.equals(adapterType)) { - return new PersistablePeerModel((IPeerModel)adaptableObject); + return new PersistablePeerNode((IPeerNode)adaptableObject); } if (ICategorizable.class.equals(adapterType)) { return new CategorizableAdapter(adaptableObject); @@ -55,7 +55,7 @@ public class AdapterFactory implements IAdapterFactory { } if (adaptableObject instanceof EditorInput) { - if (IPeerModel.class.equals(adapterType)) { + if (IPeerNode.class.equals(adapterType)) { return ((EditorInput)adaptableObject).getAdapter(adapterType); } if (IEditorSaveAsAdapter.class.equals(adapterType)) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/CategorizableAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/CategorizableAdapter.java index 5470f8023..783e3ab78 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/CategorizableAdapter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/CategorizableAdapter.java @@ -9,11 +9,8 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.ui.internal.adapters; -import java.util.concurrent.atomic.AtomicBoolean; - import org.eclipse.core.runtime.Assert; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.views.Managers; import org.eclipse.tcf.te.ui.views.interfaces.ICategory; import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; @@ -41,8 +38,8 @@ public class CategorizableAdapter implements ICategorizable { */ @Override public String getId() { - if (element instanceof IPeerModel) { - return ((IPeerModel)element).getPeerId(); + if (element instanceof IPeerNode) { + return ((IPeerNode)element).getPeerId(); } return null; } @@ -55,7 +52,7 @@ public class CategorizableAdapter implements ICategorizable { Assert.isNotNull(operation); Assert.isNotNull(category); - if (element instanceof IPeerModel) { + if (element instanceof IPeerNode) { // ADD: Parent and destination category are the same -> not valid if (OPERATION.ADD.equals(operation) && category.equals(parentCategory)) { return false; @@ -63,26 +60,6 @@ public class CategorizableAdapter implements ICategorizable { // ALL: Static peer's cannot be removed from or added to "My Targets" if (IUIConstants.ID_CAT_MY_TARGETS.equals(category.getId())) { - final AtomicBoolean isStatic = new AtomicBoolean(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - isStatic.set(((IPeerModel)element).isStatic()); - } - }; - - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } - - if (isStatic.get()) { - return false; - } - return true; } @@ -103,7 +80,7 @@ public class CategorizableAdapter implements ICategorizable { Assert.isNotNull(operation); Assert.isNotNull(category); - if (element instanceof IPeerModel) { + if (element instanceof IPeerNode) { // ADD: element belongs to category -> not enabled if (OPERATION.ADD.equals(operation) && Managers.getCategoryManager().belongsTo(category.getId(), getId())) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/EditorSaveAsAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/EditorSaveAsAdapter.java index 50e5425b8..849638109 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/EditorSaveAsAdapter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/EditorSaveAsAdapter.java @@ -32,9 +32,9 @@ import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodePropert import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.ui.dialogs.RenameDialog; @@ -60,8 +60,8 @@ public class EditorSaveAsAdapter implements IEditorSaveAsAdapter { */ @Override public boolean isSaveAsAllowed(IEditorInput input) { - IPeerModel peerModel = (IPeerModel)input.getAdapter(IPeerModel.class); - if (peerModel != null) return peerModel.isStatic(); + IPeerNode peerNode = (IPeerNode)input.getAdapter(IPeerNode.class); + if (peerNode != null) return true; return false; } @@ -71,7 +71,7 @@ public class EditorSaveAsAdapter implements IEditorSaveAsAdapter { */ @Override public Object doSaveAs(IEditorInput input) { - IPeerModel model = (IPeerModel)input.getAdapter(IPeerModel.class); + IPeerNode model = (IPeerNode)input.getAdapter(IPeerNode.class); if (model != null) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); @@ -103,12 +103,12 @@ public class EditorSaveAsAdapter implements IEditorSaveAsAdapter { } persistenceService.write(new Peer(attrs), null); - final AtomicReference newPeer = new AtomicReference(); + final AtomicReference newPeer = new AtomicReference(); final Callback cb = new Callback() { @Override protected void internalDone(Object caller, IStatus status) { // Get the peer model node from the model and select it in the tree - IPeerModel peerNode = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(attrs.get(IPeer.ATTR_ID)); + IPeerNode peerNode = Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(attrs.get(IPeer.ATTR_ID)); newPeer.set(peerNode); if (peerNode != null) { // Refresh the viewer @@ -125,7 +125,7 @@ public class EditorSaveAsAdapter implements IEditorSaveAsAdapter { Protocol.invokeLater(new Runnable() { @Override public void run() { - ILocatorModelRefreshService service = Model.getModel().getService(ILocatorModelRefreshService.class); + IPeerModelRefreshService service = Model.getModel().getService(IPeerModelRefreshService.class); // Refresh the model now (must be executed within the TCF dispatch thread) if (service != null) { service.refresh(cb); @@ -150,16 +150,14 @@ public class EditorSaveAsAdapter implements IEditorSaveAsAdapter { @Override public void run() { // Get all peer model objects - IPeerModel[] peers = Model.getModel().getPeers(); + IPeerNode[] peers = Model.getModel().getPeers(); // Loop them and find the ones which are of our handled types - for (IPeerModel peerModel : peers) { - if (peerModel.isStatic()) { - String name = peerModel.getPeer().getName(); + for (IPeerNode peerNode : peers) { + String name = peerNode.getPeer().getName(); Assert.isNotNull(name); if (!"".equals(name) && !usedNames.contains(name)) { //$NON-NLS-1$ usedNames.add(name.trim().toUpperCase()); } - } } } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PeerModelFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PeerModelFactory.java deleted file mode 100644 index 64b3b90f3..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PeerModelFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.ui.internal.adapters; - -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; -import org.eclipse.tcf.te.tcf.locator.model.Model; -import org.eclipse.tcf.te.ui.views.editor.EditorInput; -import org.eclipse.ui.IElementFactory; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.internal.part.NullEditorInput; - -/** - * The element factory to create an peer model editor input from a memento which is read - * from an external persistent storage and holds a peer id. - */ -@SuppressWarnings("restriction") -public class PeerModelFactory implements IElementFactory { - - /* (non-Javadoc) - * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento) - */ - @Override - public IAdaptable createElement(IMemento memento) { - final AtomicReference node = new AtomicReference(); - final String peerId = memento.getString("peerId"); //$NON-NLS-1$ - if (peerId != null) { - Runnable runnable = new Runnable() { - @Override - public void run() { - node.set(Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId)); - } - }; - - Assert.isTrue(!Protocol.isDispatchThread()); - Protocol.invokeAndWait(runnable); - - // If the node is null, this might mean that the peer to restore is a dynamically discovered peer. - // In this case, we have to wait a little bit to give the locator service the chance to sync. - if (node.get() == null) { - // Sleep shortly - try { Thread.sleep(300); } catch (InterruptedException e) {} - - // Refresh and try again to query the node - Runnable runnable2 = new Runnable() { - @Override - public void run() { - Model.getModel().getService(ILocatorModelRefreshService.class).refresh(null); - node.set(Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId)); - } - }; - - Protocol.invokeAndWait(runnable2); - } - - if (node.get() != null) { - ILocatorModel model = node.get().getModel(); - ILocatorModelPeerNodeQueryService queryService = model.getService(ILocatorModelPeerNodeQueryService.class); - queryService.queryRemoteServices(node.get()); - } - } - - return node.get() != null ? new EditorInput(node.get()) : new NullEditorInput(); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PeerNodeFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PeerNodeFactory.java new file mode 100644 index 000000000..6275b7643 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PeerNodeFactory.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2012, 2013 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.ui.internal.adapters; + +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.model.Model; +import org.eclipse.tcf.te.ui.views.editor.EditorInput; +import org.eclipse.ui.IElementFactory; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.internal.part.NullEditorInput; + +/** + * The element factory to create an peer model editor input from a memento which is read + * from an external persistent storage and holds a peer id. + */ +@SuppressWarnings("restriction") +public class PeerNodeFactory implements IElementFactory { + + /* (non-Javadoc) + * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento) + */ + @Override + public IAdaptable createElement(IMemento memento) { + final AtomicReference node = new AtomicReference(); + final String peerId = memento.getString("peerId"); //$NON-NLS-1$ + if (peerId != null) { + Runnable runnable = new Runnable() { + @Override + public void run() { + node.set(Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(peerId)); + } + }; + + Assert.isTrue(!Protocol.isDispatchThread()); + Protocol.invokeAndWait(runnable); + + // If the node is null, this might mean that the peer to restore is a dynamically discovered peer. + // In this case, we have to wait a little bit to give the locator service the chance to sync. + if (node.get() == null) { + // Sleep shortly + try { Thread.sleep(300); } catch (InterruptedException e) {} + + // Refresh and try again to query the node + Runnable runnable2 = new Runnable() { + @Override + public void run() { + Model.getModel().getService(IPeerModelRefreshService.class).refresh(null); + node.set(Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(peerId)); + } + }; + + Protocol.invokeAndWait(runnable2); + } + + if (node.get() != null) { + IPeerModel model = node.get().getModel(); + IPeerModelQueryService queryService = model.getService(IPeerModelQueryService.class); + queryService.queryRemoteServices(node.get()); + } + } + + return node.get() != null ? new EditorInput(node.get()) : new NullEditorInput(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PersistablePeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PersistablePeerModel.java deleted file mode 100644 index 82d155f55..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PersistablePeerModel.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.ui.internal.adapters; - -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IPersistableElement; - -/** - * The persistable element implementation for an IPeerModel. - */ -public class PersistablePeerModel implements IPersistableElement { - // The peer model to be persisted. - private IPeerModel peerModel; - private boolean isStatic; - - /** - * Constructor - */ - public PersistablePeerModel(IPeerModel peerModel) { - this.peerModel = peerModel; - isStatic = peerModel.isStatic(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento) - */ - @Override - public void saveState(IMemento memento) { - if (isStatic) { - memento.putString("peerId", peerModel.getPeerId()); //$NON-NLS-1$ - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IPersistableElement#getFactoryId() - */ - @Override - public String getFactoryId() { - if (isStatic) { - return "org.eclipse.tcf.te.ui.views.peerFactory"; //$NON-NLS-1$ - } - return null; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PersistablePeerNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PersistablePeerNode.java new file mode 100644 index 000000000..78749b345 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/PersistablePeerNode.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.ui.internal.adapters; + +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IPersistableElement; + +/** + * The persistable element implementation for an IPeerNode. + */ +public class PersistablePeerNode implements IPersistableElement { + // The peer model to be persisted. + private IPeerNode peerNode; + + /** + * Constructor + */ + public PersistablePeerNode(IPeerNode peerNode) { + this.peerNode = peerNode; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento) + */ + @Override + public void saveState(IMemento memento) { + memento.putString("peerId", peerNode.getPeerId()); //$NON-NLS-1$ + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IPersistableElement#getFactoryId() + */ + @Override + public String getFactoryId() { + return "org.eclipse.tcf.te.ui.views.peerFactory"; //$NON-NLS-1$ + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java index 8b22e38a3..159847634 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java @@ -25,11 +25,11 @@ import org.eclipse.tcf.te.runtime.events.EventManager; import org.eclipse.tcf.te.runtime.persistence.history.HistoryManager; import org.eclipse.tcf.te.runtime.services.AbstractService; import org.eclipse.tcf.te.tcf.core.interfaces.IPeerType; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; @@ -54,8 +54,8 @@ public class DefaultContextService extends AbstractService implements IDefaultCo * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService#getCandidates(java.lang.Object, org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService.IContextFilter) */ @Override - public IPeerModel[] getCandidates(Object currentSelection, IContextFilter filter) { - List candidates = new ArrayList(); + public IPeerNode[] getCandidates(Object currentSelection, IContextFilter filter) { + List candidates = new ArrayList(); // add given selection first if (currentSelection instanceof IStructuredSelection) { @@ -71,26 +71,26 @@ public class DefaultContextService extends AbstractService implements IDefaultCo // add system management selection addCandidates(getPartSelection(PART_ID_TE_VIEW), filter, candidates); - return candidates.toArray(new IPeerModel[candidates.size()]); + return candidates.toArray(new IPeerNode[candidates.size()]); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService#setDefaultContext(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService#setDefaultContext(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) */ @Override - public void setDefaultContext(final IPeerModel peerModel) { - if (peerModel != null) { - HistoryManager.getInstance().add(getClass().getName(), peerModel.getPeerId()); - EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_ADDED, peerModel, peerModel)); + public void setDefaultContext(final IPeerNode peerNode) { + if (peerNode != null) { + HistoryManager.getInstance().add(getClass().getName(), peerNode.getPeerId()); + EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_ADDED, peerNode, peerNode)); final AtomicReference type = new AtomicReference(); Protocol.invokeAndWait(new Runnable() { @Override public void run() { - type.set(peerModel.getPeer().getAttributes().get((IPeerModelProperties.PROP_TYPE))); + type.set(peerNode.getPeer().getAttributes().get((IPeerNodeProperties.PROP_TYPE))); } }); - HistoryManager.getInstance().add(type.get() != null ? type.get() : IPeerType.TYPE_GENERIC, peerModel.getPeerId()); + HistoryManager.getInstance().add(type.get() != null ? type.get() : IPeerType.TYPE_GENERIC, peerNode.getPeerId()); } else { HistoryManager.getInstance().clear(getClass().getName()); @@ -102,11 +102,11 @@ public class DefaultContextService extends AbstractService implements IDefaultCo * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService#getDefaultContext(org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService.IContextFilter) */ @Override - public IPeerModel getDefaultContext(IContextFilter filter) { + public IPeerNode getDefaultContext(IContextFilter filter) { for (String peerId : HistoryManager.getInstance().getHistory(getClass().getName())) { - IPeerModel peerModel = addCandidate(getPeerModel(peerId), filter, null); - if (peerModel != null) { - return peerModel; + IPeerNode peerNode = addCandidate(getPeerModel(peerId), filter, null); + if (peerNode != null) { + return peerNode; } } @@ -114,52 +114,52 @@ public class DefaultContextService extends AbstractService implements IDefaultCo } - private IPeerModel addCandidate(IPeerModel peerModel, IContextFilter filter, List candidates) { - if (peerModel != null && (filter == null || filter.select(peerModel))) { - if (candidates != null && !candidates.contains(peerModel)) { - candidates.add(peerModel); + private IPeerNode addCandidate(IPeerNode peerNode, IContextFilter filter, List candidates) { + if (peerNode != null && (filter == null || filter.select(peerNode))) { + if (candidates != null && !candidates.contains(peerNode)) { + candidates.add(peerNode); } - return peerModel; + return peerNode; } return null; } - private void addCandidates(IStructuredSelection selection, IContextFilter filter, List candidates) { + private void addCandidates(IStructuredSelection selection, IContextFilter filter, List candidates) { if (selection != null) { Iterator it = selection.iterator(); while (it.hasNext()) { - addCandidate((IPeerModel)Platform.getAdapterManager().getAdapter(it.next(), IPeerModel.class), filter, candidates); + addCandidate((IPeerNode)Platform.getAdapterManager().getAdapter(it.next(), IPeerNode.class), filter, candidates); } } } - private void addCandidates(IPeerModel[] peerModels, IContextFilter filter, List candidates) { - for (IPeerModel peerModel : peerModels) { - addCandidate(peerModel, filter, candidates); + private void addCandidates(IPeerNode[] peerModels, IContextFilter filter, List candidates) { + for (IPeerNode peerNode : peerModels) { + addCandidate(peerNode, filter, candidates); } } - private IPeerModel[] getDefaultSelections(IContextFilter filter) { - List candidates = new ArrayList(); + private IPeerNode[] getDefaultSelections(IContextFilter filter) { + List candidates = new ArrayList(); for (String peerId : HistoryManager.getInstance().getHistory(getClass().getName())) { addCandidate(getPeerModel(peerId), filter, candidates); } - return candidates.toArray(new IPeerModel[candidates.size()]); + return candidates.toArray(new IPeerNode[candidates.size()]); } - private IPeerModel getPeerModel(final String peerId) { + private IPeerNode getPeerModel(final String peerId) { if (peerId != null) { - final AtomicReference peerModel = new AtomicReference(); + final AtomicReference peerNode = new AtomicReference(); Runnable runnable = new Runnable() { @Override public void run() { - ILocatorModel model = Model.getModel(); + IPeerModel model = Model.getModel(); Assert.isNotNull(model); - peerModel.set(model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId)); + peerNode.set(model.getService(IPeerModelLookupService.class).lkupPeerModelById(peerId)); } }; @@ -170,7 +170,7 @@ public class DefaultContextService extends AbstractService implements IDefaultCo Protocol.invokeAndWait(runnable); } - return peerModel.get(); + return peerNode.get(); } return null; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java index 9c6d99210..f7d27346d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java @@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.forms.CustomFormToolkit; import org.eclipse.tcf.te.ui.tables.TableViewerComparator; import org.eclipse.tcf.te.ui.tables.properties.NodePropertiesTableControl; @@ -32,7 +32,7 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; */ public class PeerGeneralSection extends AbstractPropertySection { // The peer to be displayed. - private IPeerModel peer; + private IPeerNode peer; // The table control to display the properties. private NodePropertiesTableControl tableControl; // The form toolkit @@ -90,9 +90,9 @@ public class PeerGeneralSection extends AbstractPropertySection { super.setInput(part, selection); Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); - this.peer = (IPeerModel)Platform.getAdapterManager().getAdapter(input, IPeerModel.class); - // Assert.isTrue(input instanceof IPeerModel); - // this.peer = (IPeerModel) input; + this.peer = (IPeerNode)Platform.getAdapterManager().getAdapter(input, IPeerNode.class); + // Assert.isTrue(input instanceof IPeerNode); + // this.peer = (IPeerNode) input; } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java index 8d42bebd0..3f26b714b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java @@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.interfaces.services.INodePropertiesTableFilterUIDelegate; import org.eclipse.tcf.te.ui.tables.properties.NodePropertiesTableTableNode; import org.eclipse.tcf.te.ui.views.extensions.LabelProviderDelegateExtensionPointManager; @@ -65,7 +65,7 @@ public class PeerGeneralSectionContentProvider implements IStructuredContentProv public Object[] getElements(final Object inputElement) { List nodes = new ArrayList(); - if (inputElement instanceof IPeerModel) { + if (inputElement instanceof IPeerNode) { // Get the associated label provider IUIService service = ServiceManager.getInstance().getService(inputElement, IUIService.class); ILabelProvider provider = service != null ? service.getDelegate(inputElement, ILabelProvider.class) : null; @@ -74,12 +74,12 @@ public class PeerGeneralSectionContentProvider implements IStructuredContentProv final Map properties = new HashMap(); // And get all native properties of the peer if (Protocol.isDispatchThread()) { - properties.putAll(((IPeerModel)inputElement).getPeer().getAttributes()); + properties.putAll(((IPeerNode)inputElement).getPeer().getAttributes()); } else { Protocol.invokeAndWait(new Runnable() { @Override public void run() { - properties.putAll(((IPeerModel)inputElement).getPeer().getAttributes()); + properties.putAll(((IPeerNode)inputElement).getPeer().getAttributes()); } }); } @@ -145,10 +145,10 @@ public class PeerGeneralSectionContentProvider implements IStructuredContentProv } // If the input is a peer model node, set it directly - if (newInput instanceof IPeerModel) element = newInput; + if (newInput instanceof IPeerNode) element = newInput; // Determine the section header text - if (element instanceof IPeerModel) { + if (element instanceof IPeerNode) { sectionTitle = NLS.bind(org.eclipse.tcf.te.ui.nls.Messages.NodePropertiesTableControl_section_title, "Peer"); //$NON-NLS-1$ } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionFilter.java index e1709f7ee..2d0209f2d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionFilter.java @@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.ui.internal.tabbed; import org.eclipse.jface.viewers.IFilter; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * Peer model node general section filter implementation. @@ -23,7 +23,7 @@ public class PeerGeneralSectionFilter implements IFilter { */ @Override public boolean select(Object element) { - return element instanceof IPeerModel; + return element instanceof IPeerNode; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java index 0aea57a77..4690431d8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java @@ -28,12 +28,12 @@ import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil; import org.eclipse.tcf.te.tcf.locator.ScannerRunnable; import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerRedirector; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin; import org.eclipse.tcf.te.tcf.ui.internal.preferences.IPreferenceKeys; @@ -102,13 +102,13 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent /** * Determines if the given peer model node is a value-add. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @return True if the peer model node is a value-add, false otherwise. */ - /* default */ final boolean isValueAdd(IPeerModel peerModel) { - Assert.isNotNull(peerModel); + /* default */ final boolean isValueAdd(IPeerNode peerNode) { + Assert.isNotNull(peerNode); - String value = peerModel.getPeer().getAttributes().get("ValueAdd"); //$NON-NLS-1$ + String value = peerNode.getPeer().getAttributes().get("ValueAdd"); //$NON-NLS-1$ boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$ return isValueAdd; @@ -117,22 +117,22 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent /** * Determines if the given peer model node is filtered from the view completely. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. * @return True if filtered, false otherwise. */ - /* default */ final boolean isFiltered(IPeerModel peerModel) { - Assert.isNotNull(peerModel); + /* default */ final boolean isFiltered(IPeerNode peerNode) { + Assert.isNotNull(peerNode); boolean filtered = false; boolean hideValueAdds = CoreBundleActivator.getScopedPreferences().getBoolean(org.eclipse.tcf.te.tcf.locator.interfaces.preferences.IPreferenceKeys.PREF_HIDE_VALUEADDS); - filtered |= isValueAdd(peerModel) && hideValueAdds; + filtered |= isValueAdd(peerNode) && hideValueAdds; if (!showInvisible) { - filtered |= !peerModel.isVisible(); + filtered |= !peerNode.isVisible(); } - filtered |= peerModel.getPeer().getName() != null - && peerModel.getPeer().getName().endsWith("Command Server"); //$NON-NLS-1$ + filtered |= peerNode.getPeer().getName() != null + && peerNode.getPeer().getName().endsWith("Command Server"); //$NON-NLS-1$ return filtered; } @@ -169,13 +169,13 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent } // If it is the locator model, get the peers - if (parentElement instanceof ILocatorModel) { - final ILocatorModel model = (ILocatorModel)parentElement; - final IPeerModel[] peers = model.getPeers(); - final List candidates = new ArrayList(); + if (parentElement instanceof IPeerModel) { + final IPeerModel model = (IPeerModel)parentElement; + final IPeerNode[] peers = model.getPeers(); + final List candidates = new ArrayList(); if (IUIConstants.ID_CAT_FAVORITES.equals(catID)) { - for (IPeerModel peer : peers) { + for (IPeerNode peer : peers) { ICategorizable categorizable = (ICategorizable)peer.getAdapter(ICategorizable.class); if (categorizable == null) { categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(peer, ICategorizable.class); @@ -189,7 +189,7 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent } } else if (IUIConstants.ID_CAT_MY_TARGETS.equals(catID)) { - for (IPeerModel peer : peers) { + for (IPeerNode peer : peers) { // Check for filtered nodes (Value-add's and Proxies) if (isFiltered(peer)) { continue; @@ -201,8 +201,6 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent } Assert.isNotNull(categorizable); - boolean isStatic = peer.isStatic(); - // Static peers, or if launched by current user -> add automatically to "My Targets" boolean startedByCurrentUser = System.getProperty("user.name").equals(peer.getPeer().getUserName()); //$NON-NLS-1$ if (!startedByCurrentUser) { @@ -213,7 +211,7 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent } boolean isMyTargets = Managers.getCategoryManager().belongsTo(catID, categorizable.getId()); - if (!isMyTargets && (isStatic || startedByCurrentUser)) { + if (!isMyTargets && startedByCurrentUser) { // "Value-add's" are not saved to the category persistence automatically Managers.getCategoryManager().addTransient(catID, categorizable.getId()); isMyTargets = true; @@ -225,42 +223,40 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent } } else if (IUIConstants.ID_CAT_NEIGHBORHOOD.equals(catID)) { - for (IPeerModel peer : peers) { - // Check for filtered nodes (Value-add's and Proxies) - if (isFiltered(peer)) { - continue; - } - - ICategorizable categorizable = (ICategorizable)peer.getAdapter(ICategorizable.class); - if (categorizable == null) { - categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(peer, ICategorizable.class); - } - Assert.isNotNull(categorizable); - - boolean isStatic = peer.isStatic(); - - boolean startedByCurrentUser = System.getProperty("user.name").equals(peer.getPeer().getUserName()); //$NON-NLS-1$ - if (startedByCurrentUser) { - // If the "My Targets" category is not visible, ignore the startedByCurrentUser flag - if (myTargetsCat != null && !myTargetsCat.isEnabled()) { - startedByCurrentUser = false; - } - } - - boolean isNeighborhood = Managers.getCategoryManager().belongsTo(catID, categorizable.getId()); - if (!isNeighborhood && !isStatic && !startedByCurrentUser) { - // "Neighborhood" is always transient - Managers.getCategoryManager().addTransient(catID, categorizable.getId()); - isNeighborhood = true; - } - - if (isNeighborhood && !candidates.contains(peer)) { - candidates.add(peer); - } - } +// for (IPeerNode peer : peers) { +// // Check for filtered nodes (Value-add's and Proxies) +// if (isFiltered(peer)) { +// continue; +// } +// +// ICategorizable categorizable = (ICategorizable)peer.getAdapter(ICategorizable.class); +// if (categorizable == null) { +// categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(peer, ICategorizable.class); +// } +// Assert.isNotNull(categorizable); +// +// boolean startedByCurrentUser = System.getProperty("user.name").equals(peer.getPeer().getUserName()); //$NON-NLS-1$ +// if (startedByCurrentUser) { +// // If the "My Targets" category is not visible, ignore the startedByCurrentUser flag +// if (myTargetsCat != null && !myTargetsCat.isEnabled()) { +// startedByCurrentUser = false; +// } +// } +// +// boolean isNeighborhood = Managers.getCategoryManager().belongsTo(catID, categorizable.getId()); +// if (!isNeighborhood && !isStatic && !startedByCurrentUser) { +// // "Neighborhood" is always transient +// Managers.getCategoryManager().addTransient(catID, categorizable.getId()); +// isNeighborhood = true; +// } +// +// if (isNeighborhood && !candidates.contains(peer)) { +// candidates.add(peer); +// } +// } } else if (catID != null) { - for (IPeerModel peer : peers) { + for (IPeerNode peer : peers) { ICategorizable categorizable = (ICategorizable)peer.getAdapter(ICategorizable.class); if (categorizable == null) { categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(peer, ICategorizable.class); @@ -275,7 +271,7 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent } } else { - for (IPeerModel peer : peers) { + for (IPeerNode peer : peers) { // Check for filtered nodes (Value-add's and Proxies) if (isFiltered(peer)) { continue; @@ -286,12 +282,12 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent } } - children = candidates.toArray(new IPeerModel[candidates.size()]); + children = candidates.toArray(new IPeerNode[candidates.size()]); } // If it is a peer model itself, get the child peers - else if (parentElement instanceof IPeerModel) { - String parentPeerId = ((IPeerModel)parentElement).getPeerId(); - List candidates = Model.getModel().getChildren(parentPeerId); + else if (parentElement instanceof IPeerNode) { + String parentPeerId = ((IPeerNode)parentElement).getPeerId(); + List candidates = Model.getModel().getChildren(parentPeerId); if (candidates != null && candidates.size() > 0) { PeerRedirectorGroupNode rootNode = roots.get(parentPeerId); if (rootNode == null) { @@ -306,15 +302,15 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent // If it is a remote peer discover root node, return the children // for the associated peer id. else if (parentElement instanceof PeerRedirectorGroupNode) { - List candidates = Model.getModel().getChildren(((PeerRedirectorGroupNode)parentElement).peerId); + List candidates = Model.getModel().getChildren(((PeerRedirectorGroupNode)parentElement).peerId); if (candidates != null && candidates.size() > 0) { // Mark all candidates to be included in the scan process and // schedule an scan asynchronously - for (final IPeerModel candidate: candidates) { + for (final IPeerNode candidate: candidates) { Protocol.invokeLater(new Runnable() { @Override public void run() { - candidate.setProperty(IPeerModelProperties.PROP_SCANNER_EXCLUDE, false); + candidate.setProperty(IPeerNodeProperties.PROP_SCANNER_EXCLUDE, false); ScannerRunnable runnable = new ScannerRunnable(null, candidate); runnable.run(); @@ -344,10 +340,10 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent @Override public Object getParent(final Object element) { // If it is a peer model node, return the parent locator model - if (element instanceof IPeerModel) { + if (element instanceof IPeerNode) { // If it is a peer redirector, return the parent remote peer discover root node - if (((IPeerModel)element).getPeer() instanceof IPeerRedirector) { - IPeer parentPeer = ((IPeerRedirector)((IPeerModel)element).getPeer()).getParent(); + if (((IPeerNode)element).getPeer() instanceof IPeerRedirector) { + IPeer parentPeer = ((IPeerRedirector)((IPeerNode)element).getPeer()).getParent(); String parentPeerId = parentPeer.getID(); if (!roots.containsKey(parentPeerId)) { roots.put(parentPeer.getID(), new PeerRedirectorGroupNode(parentPeerId)); @@ -357,21 +353,21 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent // Determine the parent category node ICategory category = null; - String[] categoryIds = Managers.getCategoryManager().getCategoryIds(((IPeerModel)element).getPeerId()); + String[] categoryIds = Managers.getCategoryManager().getCategoryIds(((IPeerNode)element).getPeerId()); // If we have more than one, take the first one as parent category. // To get all parents, the getParents(Object) method must be called if (categoryIds != null && categoryIds.length > 0) { category = CategoriesExtensionPointManager.getInstance().getCategory(categoryIds[0], false); } - return category != null ? category : ((IPeerModel)element).getModel(); + return category != null ? category : ((IPeerNode)element).getModel(); } else if (element instanceof PeerRedirectorGroupNode) { // Return the parent peer model node - final AtomicReference parent = new AtomicReference(); + final AtomicReference parent = new AtomicReference(); final Runnable runnable = new Runnable() { @Override public void run() { - parent.set(Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(((PeerRedirectorGroupNode)element).peerId)); + parent.set(Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(((PeerRedirectorGroupNode)element).peerId)); } }; @@ -402,8 +398,8 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent // is consuming only the last segment. List pathes = new ArrayList(); - if (element instanceof IPeerModel) { - if (Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, ((IPeerModel)element).getPeerId())) { + if (element instanceof IPeerNode) { + if (Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, ((IPeerNode)element).getPeerId())) { // Get the "Favorites" category ICategory favCategory = CategoriesExtensionPointManager.getInstance().getCategory(IUIConstants.ID_CAT_FAVORITES, false); if (favCategory != null) { @@ -484,7 +480,7 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent */ @Override public void inputChanged(final Viewer viewer, Object oldInput, Object newInput) { - final ILocatorModel model = Model.getModel(); + final IPeerModel model = Model.getModel(); // Create and attach the model listener if not yet done if (modelListener == null && model != null && viewer instanceof CommonViewer) { @@ -509,7 +505,7 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent Protocol.invokeLater(new Runnable() { @Override public void run() { - model.getService(ILocatorModelRefreshService.class).refresh(null); + model.getService(IPeerModelRefreshService.class).refresh(null); } }); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ModelListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ModelListener.java index a6ee0b8ec..269bcc313 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ModelListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ModelListener.java @@ -15,8 +15,8 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IAdapterService; import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter; import org.eclipse.tcf.te.ui.views.editor.EditorInput; import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; @@ -32,7 +32,7 @@ import org.eclipse.ui.navigator.CommonViewer; * TCF locator model listener implementation. */ public class ModelListener extends ModelAdapter { - private final ILocatorModel parentModel; + private final IPeerModel parentModel; /* default */ final CommonViewer viewer; /** @@ -41,7 +41,7 @@ public class ModelListener extends ModelAdapter { * @param parent The parent locator model. Must not be null. * @param viewer The common viewer instance. Must not be null. */ - public ModelListener(ILocatorModel parent, CommonViewer viewer) { + public ModelListener(IPeerModel parent, CommonViewer viewer) { Assert.isNotNull(parent); Assert.isNotNull(viewer); @@ -50,10 +50,10 @@ public class ModelListener extends ModelAdapter { } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, boolean) + * @see org.eclipse.tcf.te.tcf.locator.listener.ModelAdapter#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean) */ @Override - public void locatorModelChanged(final ILocatorModel model, final IPeerModel peerModel, final boolean added) { + public void locatorModelChanged(final IPeerModel model, final IPeerNode peerNode, final boolean added) { if (parentModel.equals(model)) { // Locator model changed -> refresh the tree Tree tree = viewer.getTree(); @@ -69,17 +69,17 @@ public class ModelListener extends ModelAdapter { }); } - if (peerModel != null) { + if (peerNode != null) { // Check if the peer model node can be adapted to IModelListener. - IAdapterService service = ServiceManager.getInstance().getService(peerModel, IAdapterService.class); - IModelListener listener = service != null ? service.getAdapter(peerModel, IModelListener.class) : null; + IAdapterService service = ServiceManager.getInstance().getService(peerNode, IAdapterService.class); + IModelListener listener = service != null ? service.getAdapter(peerNode, IModelListener.class) : null; // If yes -> Invoke the adapted model listener instance if (listener != null) { - listener.locatorModelChanged(model, peerModel, added); + listener.locatorModelChanged(model, peerNode, added); } // If no -> Default behavior for dynamic discovered peers is to close the editor (if any). // For static peers, leave the editor untouched. - else if (!added && !peerModel.isStatic()) { + else if (!added) { Display display = PlatformUI.getWorkbench().getDisplay(); if (display != null && !display.isDisposed()) { display.asyncExec(new Runnable() { @@ -91,7 +91,7 @@ public class ModelListener extends ModelAdapter { // Get the active page IWorkbenchPage page = window.getActivePage(); // Create the editor input object - IEditorInput input = new EditorInput(peerModel); + IEditorInput input = new EditorInput(peerNode); // Lookup the editors matching the editor input IEditorReference[] editors = page.findEditors(input, IUIConstants.ID_EDITOR, IWorkbenchPage.MATCH_INPUT); if (editors != null && editors.length > 0) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java index 8ca09120c..bac4216d5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java @@ -11,7 +11,6 @@ package org.eclipse.tcf.te.tcf.ui.navigator; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.core.runtime.Assert; @@ -22,8 +21,8 @@ import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.services.interfaces.delegates.ILabelProviderDelegate; import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin; import org.eclipse.tcf.te.tcf.ui.internal.ImageConsts; @@ -42,7 +41,7 @@ public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDe */ @Override public String getText(final Object element) { - if (element instanceof IPeerModel || element instanceof IPeer) { + if (element instanceof IPeerNode || element instanceof IPeer) { StringBuilder builder = new StringBuilder(); // Copy the peer node and peer attributes @@ -51,9 +50,9 @@ public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDe Runnable runnable = new Runnable() { @Override public void run() { - if (element instanceof IPeerModel) { - attrs.putAll(((IPeerModel)element).getProperties()); - attrs.putAll(((IPeerModel)element).getPeer().getAttributes()); + if (element instanceof IPeerNode) { + attrs.putAll(((IPeerNode)element).getProperties()); + attrs.putAll(((IPeerNode)element).getPeer().getAttributes()); } else if (element instanceof IPeer) { attrs.putAll(((IPeer)element).getAttributes()); @@ -123,7 +122,7 @@ public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDe Runnable runnable = new Runnable() { @Override public void run() { - count.set(Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelByName(label).length); + count.set(Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelByName(label).length); } }; @@ -141,30 +140,8 @@ public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDe */ @Override public Image getImage(final Object element) { - if (element instanceof IPeerModel || element instanceof IPeer) { - final AtomicBoolean isStatic = new AtomicBoolean(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - if (element instanceof IPeerModel) { - isStatic.set(((IPeerModel)element).isStatic()); - } - else if (element instanceof IPeer) { - String value = ((IPeer)element).getAttributes().get("static.transient"); //$NON-NLS-1$ - isStatic.set(value != null && Boolean.parseBoolean(value.trim())); - } - } - }; - - if (Protocol.isDispatchThread()) { - runnable.run(); - } - else { - Protocol.invokeAndWait(runnable); - } - - return isStatic.get() ? UIPlugin.getImage(ImageConsts.PEER) : UIPlugin.getImage(ImageConsts.PEER_DISCOVERED); + if (element instanceof IPeerNode || element instanceof IPeer) { + return UIPlugin.getImage(ImageConsts.PEER); } if (element instanceof PeerRedirectorGroupNode) { return UIPlugin.getImage(ImageConsts.DISCOVERY_ROOT); @@ -180,11 +157,11 @@ public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDe public Image decorateImage(Image image, Object element) { Image decoratedImage = image; - if (image != null && element instanceof IPeerModel) { + if (image != null && element instanceof IPeerNode) { AbstractImageDescriptor descriptor = new PeerImageDescriptor( UIPlugin.getDefault().getImageRegistry(), image, - (IPeerModel)element); + (IPeerNode)element); decoratedImage = UIPlugin.getSharedImage(descriptor); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/TreeViewerListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/TreeViewerListener.java index 308633a42..e9de64f33 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/TreeViewerListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/TreeViewerListener.java @@ -16,8 +16,8 @@ import org.eclipse.jface.viewers.ITreeViewerListener; import org.eclipse.jface.viewers.TreeExpansionEvent; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.interfaces.IDisposable; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.navigator.nodes.PeerRedirectorGroupNode; import org.eclipse.ui.navigator.CommonViewer; @@ -52,13 +52,13 @@ public class TreeViewerListener implements ITreeViewerListener, IDisposable { @Override public void treeCollapsed(TreeExpansionEvent event) { if (event.getElement() instanceof PeerRedirectorGroupNode) { - final List candidates = Model.getModel().getChildren(((PeerRedirectorGroupNode)event.getElement()).peerId); + final List candidates = Model.getModel().getChildren(((PeerRedirectorGroupNode)event.getElement()).peerId); if (candidates != null && candidates.size() > 0) { Protocol.invokeLater(new Runnable() { @Override public void run() { // Mark all candidates to be excluded from the scan process - for (final IPeerModel candidate: candidates) { + for (final IPeerNode candidate: candidates) { markExcluded(candidate); } } @@ -70,17 +70,17 @@ public class TreeViewerListener implements ITreeViewerListener, IDisposable { /** * Mark the given peer model node and it's child nodes to be excluded from the scanner. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. */ - /* default */ void markExcluded(IPeerModel peerModel) { + /* default */ void markExcluded(IPeerNode peerNode) { Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - Assert.isNotNull(peerModel); + Assert.isNotNull(peerNode); - peerModel.setProperty(IPeerModelProperties.PROP_SCANNER_EXCLUDE, true); + peerNode.setProperty(IPeerNodeProperties.PROP_SCANNER_EXCLUDE, true); - List candidates = Model.getModel().getChildren(peerModel.getPeerId()); + List candidates = Model.getModel().getChildren(peerNode.getPeerId()); if (candidates != null && candidates.size() > 0) { - for (final IPeerModel candidate: candidates) { + for (final IPeerNode candidate: candidates) { markExcluded(candidate); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java index 9ba4385ee..4a697b99f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java @@ -35,9 +35,9 @@ import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodePropert import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.ui.views.Managers; import org.eclipse.tcf.te.ui.views.interfaces.ICategory; @@ -80,7 +80,7 @@ public class CommonDnD { * @return true if it is draggable. */ private static boolean isDraggableObject(Object object) { - return object instanceof IPeerModel; + return object instanceof IPeerNode; } /** @@ -120,9 +120,9 @@ public class CommonDnD { if (target instanceof ICategory) { ICategory category = (ICategory) target; - if (element instanceof IPeerModel && category.getId().equals(parentCategory.getId()) && ((IPeerModel)element).isStatic()) { + if (element instanceof IPeerNode && category.getId().equals(parentCategory.getId())) { List usedNames = getUsedNames(); - Map attrs = new HashMap(((IPeerModel)element).getPeer().getAttributes()); + Map attrs = new HashMap(((IPeerNode)element).getPeer().getAttributes()); attrs.put(IPeer.ATTR_ID, UUID.randomUUID().toString()); attrs.remove(IPersistableNodeProperties.PROPERTY_URI); int i = 0; @@ -178,7 +178,7 @@ public class CommonDnD { final Object finalElement = elementToSelect; final IPeer finalNewPeer = (elementToSelect instanceof IPeer) ? (IPeer)elementToSelect : null; // Trigger a refresh of the model to read in the newly created static peer - final ILocatorModelRefreshService service = Model.getModel().getService(ILocatorModelRefreshService.class); + final IPeerModelRefreshService service = Model.getModel().getService(IPeerModelRefreshService.class); if (service != null) { Runnable runnable = new Runnable() { @Override @@ -186,14 +186,14 @@ public class CommonDnD { service.refresh(new Callback() { @Override protected void internalDone(Object caller, org.eclipse.core.runtime.IStatus status) { - IPeerModel peerModel = null; + IPeerNode peerNode = null; if (finalNewPeer != null) { - ILocatorModelLookupService service = Model.getModel().getService(ILocatorModelLookupService.class); + IPeerModelLookupService service = Model.getModel().getService(IPeerModelLookupService.class); if (service != null) { - peerModel = service.lkupPeerModelById(finalNewPeer.getID()); + peerNode = service.lkupPeerModelById(finalNewPeer.getID()); } } - refresh(cNav, finalCat, peerModel != null ? peerModel : finalElement); + refresh(cNav, finalCat, peerNode != null ? peerNode : finalElement); } }); @@ -305,7 +305,7 @@ public class CommonDnD { if (target instanceof ICategory) { ICategory category = (ICategory) target; - if (!link && element instanceof IPeerModel && category.getId().equals(parentCategory.getId()) && ((IPeerModel)element).isStatic()) { + if (!link && element instanceof IPeerNode && category.getId().equals(parentCategory.getId())) { overrideOperation = DND.DROP_COPY; copy = true; } @@ -380,16 +380,14 @@ public class CommonDnD { @Override public void run() { // Get all peer model objects - IPeerModel[] peers = Model.getModel().getPeers(); + IPeerNode[] peers = Model.getModel().getPeers(); // Loop them and find the ones which are of our handled types - for (IPeerModel peerModel : peers) { - if (peerModel.isStatic()) { - String name = peerModel.getPeer().getName(); + for (IPeerNode peerNode : peers) { + String name = peerNode.getPeer().getName(); Assert.isNotNull(name); if (!"".equals(name) && !usedNames.contains(name)) { //$NON-NLS-1$ usedNames.add(name.trim().toUpperCase()); } - } } } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/events/EventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/events/EventListener.java index 33cc59e4e..15a813289 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/events/EventListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/events/EventListener.java @@ -14,7 +14,7 @@ import java.util.EventObject; import org.eclipse.tcf.te.runtime.events.ChangeEvent; import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.ui.views.events.AbstractEventListener; /** @@ -34,7 +34,7 @@ public class EventListener extends AbstractEventListener { // Property changes for the model refreshes the parent peer // node. The runtime model is not visible by itself. if (source instanceof IModel) { - IPeerModel node = (IPeerModel)((IModel)source).getAdapter(IPeerModel.class); + IPeerNode node = (IPeerNode)((IModel)source).getAdapter(IPeerNode.class); refresh(node, false); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/filter/GenericFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/filter/GenericFilter.java index c33a9afcd..07517dfff 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/filter/GenericFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/filter/GenericFilter.java @@ -16,8 +16,8 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.tcf.core.interfaces.IPeerType; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.ui.navigator.nodes.PeerRedirectorGroupNode; import org.eclipse.tcf.te.ui.views.interfaces.ICategory; import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; @@ -34,13 +34,13 @@ public class GenericFilter extends ViewerFilter { public boolean select(Viewer viewer, Object parentElement, final Object element) { boolean visible = true; - if (element instanceof IPeerModel) { + if (element instanceof IPeerNode) { final AtomicReference type = new AtomicReference(); Runnable runnable = new Runnable() { @Override public void run() { - type.set(((IPeerModel)element).getPeer().getAttributes().get(IPeerModelProperties.PROP_TYPE)); + type.set(((IPeerNode)element).getPeer().getAttributes().get(IPeerNodeProperties.PROP_TYPE)); } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/images/PeerImageDescriptor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/images/PeerImageDescriptor.java index 9264647d0..33cdbb3b1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/images/PeerImageDescriptor.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/images/PeerImageDescriptor.java @@ -15,7 +15,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.core.interfaces.IConnectable; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.ui.internal.ImageConsts; import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor; @@ -35,7 +35,7 @@ public class PeerImageDescriptor extends AbstractImageDescriptor { /** * Constructor. */ - public PeerImageDescriptor(final ImageRegistry registry, final Image baseImage, final IPeerModel node) { + public PeerImageDescriptor(final ImageRegistry registry, final Image baseImage, final IPeerNode node) { super(registry); this.baseImage = baseImage; @@ -62,11 +62,11 @@ public class PeerImageDescriptor extends AbstractImageDescriptor { * * @param node The peer model. Must not be null. */ - protected void initialize(IPeerModel node) { + protected void initialize(IPeerNode node) { Assert.isNotNull(node); Assert.isTrue(Protocol.isDispatchThread()); - connectState = node instanceof IConnectable ? ((IConnectable)node).getConnectState() : IConnectable.STATE_UNKNOWN; + connectState = node.getConnectState(); } /** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java index dab9ab671..95712e6a2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java @@ -27,8 +27,8 @@ import org.eclipse.tcf.te.runtime.persistence.PersistenceManager; import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; @@ -46,18 +46,18 @@ public abstract class AbstractContextSelectorSection extends org.eclipse.tcf.te. final IModelListener modelListener = new IModelListener() { @Override - public void locatorModelDisposed(ILocatorModel model) { + public void locatorModelDisposed(IPeerModel model) { refreshSelectorControl(); } @Override - public void locatorModelChanged(ILocatorModel model, IPeerModel peerModel, boolean added) { + public void locatorModelChanged(IPeerModel model, IPeerNode peerNode, boolean added) { refreshSelectorControl(); } }; final IEventListener eventListener = new IEventListener() { @Override public void eventFired(EventObject event) { - if (event.getSource() instanceof IPeer || event.getSource() instanceof IPeerModel) { + if (event.getSource() instanceof IPeer || event.getSource() instanceof IPeerNode) { refreshSelectorControl(); } } @@ -159,14 +159,14 @@ public abstract class AbstractContextSelectorSection extends org.eclipse.tcf.te. try { if (encoded != null && encoded.trim().length() > 0) { IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class); - Object[] input = delegate.readList(IPeerModel.class, encoded); + Object[] input = delegate.readList(IPeerNode.class, encoded); List peers = new ArrayList(); for (Object object : input) { if (object instanceof IModelNode) { peers.add((IModelNode)object); } } - return peers.toArray(new IPeerModel[peers.size()]); + return peers.toArray(new IPeerNode[peers.size()]); } } catch (Exception e) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java index 44e43bc68..fdfdc6a79 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java @@ -33,11 +33,11 @@ import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; import org.eclipse.tcf.te.tcf.ui.controls.SimulatorTypeSelectionControl; -import org.eclipse.tcf.te.tcf.ui.dialogs.AgentSelectionDialog; +import org.eclipse.tcf.te.tcf.ui.dialogs.PeerSelectionDialog; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl; import org.eclipse.tcf.te.ui.forms.parts.AbstractSection; @@ -59,7 +59,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID /* default */ SimulatorTypeSelectionControl simulator; // Reference to the original data object - /* default */ IPeerModel od; + /* default */ IPeerNode od; // Reference to a copy of the original data /* default */ final IPropertiesContainer odc = new PropertiesContainer(); // Reference to the properties container representing the working copy for the section @@ -68,7 +68,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID protected static final int SELECTION_REAL = 0; protected static final int SELECTION_SIM = 1; - protected IPeerModel selectedTarget = null; + protected IPeer selectedPeer = null; /** * Constructor. @@ -153,13 +153,13 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID if (target.isLabelControlSelected()) { onSelectionChanged(SELECTION_REAL); if (!isUpdating()) { - onTargetChanged(false, true, selectedTarget, selectedTarget); + onPeerChanged(false, true, selectedPeer, selectedPeer); } } } @Override protected void onButtonControlSelected() { - AgentSelectionDialog dialog = new AgentSelectionDialog(null) { + PeerSelectionDialog dialog = new PeerSelectionDialog(null) { @Override protected boolean supportsMultiSelection() { return false; @@ -169,8 +169,8 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID viewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, final Object element) { - if (element instanceof IPeerModel && !(element instanceof IConnectable)) { - final IPeer peer = ((IPeerModel)element).getPeer(); + if (element instanceof IPeer) { + final IPeer peer = (IPeer)element; final AtomicBoolean isValueAdd = new AtomicBoolean(); final AtomicBoolean isCLI = new AtomicBoolean(); Protocol.invokeAndWait(new Runnable() { @@ -198,11 +198,10 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID if (dialog.open() == Window.OK) { // Get the selected proxy from the dialog ISelection selection = dialog.getSelection(); - if (selection instanceof IStructuredSelection && !selection.isEmpty() && ((IStructuredSelection)selection).getFirstElement() instanceof IPeerModel) { - IPeerModel oldPeerModel = selectedTarget; - selectedTarget = (IPeerModel)((IStructuredSelection)selection).getFirstElement(); - setEditFieldControlText(selectedTarget.getName()); - onTargetChanged(isLabelControlSelected(), isLabelControlSelected(), oldPeerModel, selectedTarget); + if (selection instanceof IStructuredSelection && !selection.isEmpty() && ((IStructuredSelection)selection).getFirstElement() instanceof IPeer) { + IPeer oldPeer = selectedPeer; + selectedPeer = (IPeer)((IStructuredSelection)selection).getFirstElement(); + onPeerChanged(isLabelControlSelected(), isLabelControlSelected(), oldPeer, selectedPeer); } } @@ -279,14 +278,14 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID } /** - * Called on target enabled and selected peer model changed. + * Called on target enabled and selected peer changed. * * @param oldEnabled The old target enabled action. * @param newEnabled The new target enabled action. - * @param oldPeerModel The new selected peer model. - * @param newPeerModel The old selected peer model. + * @param oldPeer The new selected peer. + * @param newPeer The old selected peer. */ - protected void onTargetChanged(boolean oldEnabled, boolean newEnabled, IPeerModel oldPeerModel, IPeerModel newPeerModel) { + protected void onPeerChanged(boolean oldEnabled, boolean newEnabled, IPeer oldPeer, IPeer newPeer) { } /** @@ -302,8 +301,8 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID if (getManagedForm().getContainer() instanceof AbstractEditorPage && !((AbstractEditorPage)getManagedForm().getContainer()).isDirty()) { Object node = ((AbstractEditorPage)getManagedForm().getContainer()).getEditorInputNode(); - if (node instanceof IPeerModel) { - setupData((IPeerModel)node); + if (node instanceof IPeerNode) { + setupData((IPeerNode)node); } } } else { @@ -323,16 +322,16 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID // Initialize the simulator simulator selection control if (simulator != null) { simulator.initialize(od); - simulator.setSelectedSimulatorId(data.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE)); - simulator.setSimulatorConfig(data.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES)); - simulator.setLabelControlSelection(data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED)); + simulator.setSelectedSimulatorId(data.getStringProperty(IPeerNodeProperties.PROP_SIM_TYPE)); + simulator.setSimulatorConfig(data.getStringProperty(IPeerNodeProperties.PROP_SIM_PROPERTIES)); + simulator.setLabelControlSelection(data.getBooleanProperty(IPeerNodeProperties.PROP_SIM_ENABLED)); } if (target != null) { - target.setLabelControlSelection(!data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED)); + target.setLabelControlSelection(!data.getBooleanProperty(IPeerNodeProperties.PROP_SIM_ENABLED)); } - onSelectionChanged(data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED) ? SELECTION_SIM : SELECTION_REAL); + onSelectionChanged(data.getBooleanProperty(IPeerNodeProperties.PROP_SIM_ENABLED) ? SELECTION_SIM : SELECTION_REAL); // Mark the control update as completed now setIsUpdating(false); @@ -349,7 +348,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID * * @param node The peer model node or null. */ - public void setupData(final IPeerModel node) { + public void setupData(final IPeerNode node) { // If the section is dirty, nothing is changed if (isDirty()) { return; @@ -388,9 +387,9 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID public void run() { // The section is handling the simulator related properties // Ignore other properties. - odc.setProperty(IPeerModelProperties.PROP_SIM_ENABLED, node.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_ENABLED)); - odc.setProperty(IPeerModelProperties.PROP_SIM_PROPERTIES, node.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_PROPERTIES)); - odc.setProperty(IPeerModelProperties.PROP_SIM_TYPE, node.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_TYPE)); + odc.setProperty(IPeerNodeProperties.PROP_SIM_ENABLED, node.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_ENABLED)); + odc.setProperty(IPeerNodeProperties.PROP_SIM_PROPERTIES, node.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_PROPERTIES)); + odc.setProperty(IPeerNodeProperties.PROP_SIM_TYPE, node.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_TYPE)); // Initially, the working copy is a duplicate of the original data copy wc.setProperties(odc.getProperties()); } @@ -422,14 +421,14 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID // Extract the widget data into the working copy if (target != null) { - data.setProperty(IPeerModelProperties.PROP_SIM_ENABLED, false); - data.setProperty(IPeerModelProperties.PROP_TARGET, target.getEditFieldControlText()); + data.setProperty(IPeerNodeProperties.PROP_SIM_ENABLED, false); + data.setProperty(IPeerNodeProperties.PROP_TARGET, target.getEditFieldControlText()); } if (simulator != null) { - data.setProperty(IPeerModelProperties.PROP_SIM_ENABLED, simulator.isLabelControlSelected()); - data.setProperty(IPeerModelProperties.PROP_SIM_TYPE, simulator.getSelectedSimulatorId()); - data.setProperty(IPeerModelProperties.PROP_SIM_PROPERTIES, simulator.getSimulatorConfig()); + data.setProperty(IPeerNodeProperties.PROP_SIM_ENABLED, simulator.isLabelControlSelected()); + data.setProperty(IPeerNodeProperties.PROP_SIM_TYPE, simulator.getSelectedSimulatorId()); + data.setProperty(IPeerNodeProperties.PROP_SIM_PROPERTIES, simulator.getSimulatorConfig()); } } @@ -441,7 +440,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID * * @param node The peer node or null. */ - public void extractData(final IPeerModel node) { + public void extractData(final IPeerNode node) { // If no data is available, we are done if (node == null) { return; @@ -460,9 +459,9 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID Protocol.invokeAndWait(new Runnable() { @Override public void run() { - boolean isSimEnabled = wc.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED); - String configs = wc.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES); - String type = wc.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE); + boolean isSimEnabled = wc.getBooleanProperty(IPeerNodeProperties.PROP_SIM_ENABLED); + String configs = wc.getStringProperty(IPeerNodeProperties.PROP_SIM_PROPERTIES); + String type = wc.getStringProperty(IPeerNodeProperties.PROP_SIM_TYPE); // To update the peer attributes, the peer needs to be recreated IPeer oldPeer = node.getPeer(); @@ -470,26 +469,26 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID Map attributes = new HashMap(oldPeer.getAttributes()); // Update the data if (isSimEnabled) { - attributes.put(IPeerModelProperties.PROP_SIM_ENABLED, Boolean.toString(isSimEnabled)); + attributes.put(IPeerNodeProperties.PROP_SIM_ENABLED, Boolean.toString(isSimEnabled)); } else { - attributes.remove(IPeerModelProperties.PROP_SIM_ENABLED); + attributes.remove(IPeerNodeProperties.PROP_SIM_ENABLED); } if (configs != null) { - attributes.put(IPeerModelProperties.PROP_SIM_PROPERTIES, configs); + attributes.put(IPeerNodeProperties.PROP_SIM_PROPERTIES, configs); } else { - attributes.remove(IPeerModelProperties.PROP_SIM_PROPERTIES); + attributes.remove(IPeerNodeProperties.PROP_SIM_PROPERTIES); } if (type != null) { - attributes.put(IPeerModelProperties.PROP_SIM_TYPE, type); + attributes.put(IPeerNodeProperties.PROP_SIM_TYPE, type); } else { - attributes.remove(IPeerModelProperties.PROP_SIM_TYPE); + attributes.remove(IPeerNodeProperties.PROP_SIM_TYPE); } // And merge it to the peer model node if (oldPeer instanceof TransientPeer && !(oldPeer instanceof PeerRedirector || oldPeer instanceof Peer)) { // Create a peer object IPeer newPeer = new Peer(attributes); // Update the peer instance - node.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties.PROP_INSTANCE, newPeer); + node.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties.PROP_INSTANCE, newPeer); } else { if (oldPeer instanceof PeerRedirector) { ((PeerRedirector)oldPeer).updateAttributes(attributes); @@ -539,7 +538,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID } // Extract the data into the peer model node - extractData((IPeerModel)getManagedForm().getInput()); + extractData((IPeerNode)getManagedForm().getInput()); } /** @@ -557,12 +556,12 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID // Compare the data if (simulator != null) { - boolean oldEnabled = odc.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED); + boolean oldEnabled = odc.getBooleanProperty(IPeerNodeProperties.PROP_SIM_ENABLED); isDirty |= (oldEnabled != simulator.isLabelControlSelected()); if (simulator.isLabelControlSelected()) { String newType = simulator.getSelectedSimulatorId(); - String oldType = odc.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE); + String oldType = odc.getStringProperty(IPeerNodeProperties.PROP_SIM_TYPE); if (newType == null || "".equals(newType)) { //$NON-NLS-1$ isDirty |= oldType != null && !"".equals(oldType); //$NON-NLS-1$ } else { @@ -570,7 +569,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID } String newConfig = simulator.getSimulatorConfig(); - String oldConfig = odc.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES); + String oldConfig = odc.getStringProperty(IPeerNodeProperties.PROP_SIM_PROPERTIES); if (newConfig == null || "".equals(newConfig)) { //$NON-NLS-1$ isDirty |= oldConfig != null && !"".equals(oldConfig); //$NON-NLS-1$ } @@ -604,7 +603,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID * Updates the control enablement. */ protected void updateEnablement() { - boolean enabled = od instanceof IConnectable && ((IConnectable)od).getConnectState() == IConnectable.STATE_DISCONNECTED; + boolean enabled = od == null || od.getConnectState() == IConnectable.STATE_DISCONNECTED; if (target != null) { SWTControlUtil.setEnabled(target.getEditFieldControl(), target.isLabelControlSelected() && enabled); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java index ca3da3f88..bf0ba822d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java @@ -28,8 +28,8 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.forms.widgets.ExpandableComposite; @@ -51,7 +51,7 @@ public abstract class BaseTitledSection extends AbstractPropertySection implemen protected IPropertyChangeProvider viewerInput; // The input node. - protected IPeerModelProvider provider; + protected IPeerNodeProvider provider; /* * (non-Javadoc) @@ -66,13 +66,13 @@ public abstract class BaseTitledSection extends AbstractPropertySection implemen Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); - IPeerModelProvider provider = input instanceof IPeerModelProvider ? (IPeerModelProvider) input : null; - if (provider == null) provider = input instanceof IAdaptable ? (IPeerModelProvider)((IAdaptable)input).getAdapter(IPeerModelProvider.class) : null; - if (provider == null) provider = (IPeerModelProvider)Platform.getAdapterManager().getAdapter(input, IPeerModelProvider.class); + IPeerNodeProvider provider = input instanceof IPeerNodeProvider ? (IPeerNodeProvider) input : null; + if (provider == null) provider = input instanceof IAdaptable ? (IPeerNodeProvider)((IAdaptable)input).getAdapter(IPeerNodeProvider.class) : null; + if (provider == null) provider = (IPeerNodeProvider)Platform.getAdapterManager().getAdapter(input, IPeerNodeProvider.class); if (provider != null) { this.provider = provider; - IPeerModel peerNode = getPeerModel(provider); + IPeerNode peerNode = getPeerModel(provider); this.viewerInput = (IPropertyChangeProvider) peerNode.getAdapter(IPropertyChangeProvider.class); if (this.viewerInput != null) { this.viewerInput.addPropertyChangeListener(this); @@ -90,7 +90,7 @@ public abstract class BaseTitledSection extends AbstractPropertySection implemen * @param provider * @return */ - protected IPeerModel getPeerModel(IPeerModelProvider provider) { + protected IPeerNode getPeerModel(IPeerNodeProvider provider) { Assert.isNotNull(provider); return provider.getPeerModel(); } @@ -100,7 +100,7 @@ public abstract class BaseTitledSection extends AbstractPropertySection implemen * * @param input The input node. */ - protected void updateInput(IPeerModelProvider input) { + protected void updateInput(IPeerNodeProvider input) { } /* diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java index 4d4fd155f..87fc856c4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java @@ -22,8 +22,8 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService; import org.eclipse.tcf.te.runtime.stepper.job.StepperJob; import org.eclipse.tcf.te.runtime.utils.StatusHelper; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin; import org.eclipse.tcf.te.tcf.ui.wizards.pages.AbstractConfigWizardPage; @@ -61,11 +61,11 @@ public abstract class AbstractConfigWizard extends NewTargetWizard { protected abstract AbstractConfigWizardPage getConfigWizardPage(); /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.wizards.NewTargetWizard#postPerformFinish(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel) + * @see org.eclipse.tcf.te.tcf.ui.wizards.NewTargetWizard#postPerformFinish(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) */ @Override - protected void postPerformFinish(final IPeerModel peerModel) { - Assert.isNotNull(peerModel); + protected void postPerformFinish(final IPeerNode peerNode) { + Assert.isNotNull(peerNode); // Determine if or if not to auto-connect the created connection. boolean autoConnect = true; @@ -84,25 +84,25 @@ public abstract class AbstractConfigWizard extends NewTargetWizard { Protocol.invokeAndWait(new Runnable() { @Override public void run() { - connect.set(Boolean.parseBoolean(peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_AUTO_CONNECT))); + connect.set(Boolean.parseBoolean(peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_AUTO_CONNECT))); } }); if (connect.get()) { - IService[] services = ServiceManager.getInstance().getServices(peerModel, IStepperOperationService.class, false); + IService[] services = ServiceManager.getInstance().getServices(peerNode, IStepperOperationService.class, false); IStepperOperationService stepperOperationService = null; for (IService service : services) { - if (service instanceof IStepperOperationService && ((IStepperOperationService)service).isHandledOperation(peerModel, IStepperServiceOperations.CONNECT)) { + if (service instanceof IStepperOperationService && ((IStepperOperationService)service).isHandledOperation(peerNode, IStepperServiceOperations.CONNECT)) { stepperOperationService = (IStepperOperationService)service; break; } } if (stepperOperationService != null) { - String stepGroupId = stepperOperationService.getStepGroupId(peerModel, IStepperServiceOperations.CONNECT); - IStepContext stepContext = stepperOperationService.getStepContext(peerModel, IStepperServiceOperations.CONNECT); - String name = stepperOperationService.getStepGroupName(peerModel, IStepperServiceOperations.CONNECT); - IPropertiesContainer data = stepperOperationService.getStepData(peerModel, IStepperServiceOperations.CONNECT); - boolean enabled = stepperOperationService.isEnabled(peerModel, IStepperServiceOperations.CONNECT); + String stepGroupId = stepperOperationService.getStepGroupId(peerNode, IStepperServiceOperations.CONNECT); + IStepContext stepContext = stepperOperationService.getStepContext(peerNode, IStepperServiceOperations.CONNECT); + String name = stepperOperationService.getStepGroupName(peerNode, IStepperServiceOperations.CONNECT); + IPropertiesContainer data = stepperOperationService.getStepData(peerNode, IStepperServiceOperations.CONNECT); + boolean enabled = stepperOperationService.isEnabled(peerNode, IStepperServiceOperations.CONNECT); if (enabled && stepGroupId != null && stepContext != null) { try { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java index 376701571..c9d4250ff 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java @@ -33,9 +33,9 @@ import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.tcf.ui.wizards.pages.NewTargetWizardPage; @@ -128,13 +128,13 @@ public class NewTargetWizard extends AbstractWizard implements INewWizard { Protocol.invokeLater(new Runnable() { @Override public void run() { - ILocatorModelRefreshService service = Model.getModel().getService(ILocatorModelRefreshService.class); + IPeerModelRefreshService service = Model.getModel().getService(IPeerModelRefreshService.class); // Refresh the model now (must be executed within the TCF dispatch thread) if (service != null) service.refresh(new Callback() { @Override protected void internalDone(Object caller, IStatus status) { // Get the peer model node from the model and select it in the tree - final IPeerModel peerNode = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(attrs.get(IPeer.ATTR_ID)); + final IPeerNode peerNode = Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(attrs.get(IPeer.ATTR_ID)); if (peerNode != null) { // Refresh the viewer ViewsUtil.refresh(IUIConstants.ID_EXPLORER); @@ -183,9 +183,9 @@ public class NewTargetWizard extends AbstractWizard implements INewWizard { *

* Note: The method is called from within the UI thread. * - * @param peerModel The peer model node. Must not be null. + * @param peerNode The peer model node. Must not be null. */ - protected void postPerformFinish(IPeerModel peerModel) { + protected void postPerformFinish(IPeerNode peerNode) { // Do nothing } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java index 4a5bf06cb..bc3096301 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java @@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.controls.PeerNameControl; import org.eclipse.tcf.te.tcf.ui.nls.Messages; @@ -310,16 +310,14 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i @Override public void run() { // Get all peer model objects - IPeerModel[] peers = Model.getModel().getPeers(); + IPeerNode[] peers = Model.getModel().getPeers(); // Loop them and find the ones which are of our handled types - for (IPeerModel peerModel : peers) { - if (peerModel.isStatic()) { - String name = peerModel.getPeer().getName(); + for (IPeerNode peerNode : peers) { + String name = peerNode.getPeer().getName(); Assert.isNotNull(name); if (!"".equals(name) && !usedNames.contains(name)) { //$NON-NLS-1$ usedNames.add(name.trim().toUpperCase()); } - } } } }; @@ -434,11 +432,11 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i } if (isAutoStartDebugger()) { - peerAttributes.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties.PROP_AUTO_START_DEBUGGER, true); + peerAttributes.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties.PROP_AUTO_START_DEBUGGER, true); } if (isAutoConnect()) { - peerAttributes.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties.PROP_AUTO_CONNECT, true); + peerAttributes.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties.PROP_AUTO_CONNECT, true); } if (selectorSection != null) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/NewTargetWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/NewTargetWizardPage.java index 67bf46944..42583508c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/NewTargetWizardPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/NewTargetWizardPage.java @@ -28,7 +28,7 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.tcf.core.interfaces.ITransportTypes; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.controls.CustomTransportPanel; import org.eclipse.tcf.te.tcf.ui.controls.PeerAttributesTablePart; @@ -454,16 +454,14 @@ public class NewTargetWizardPage extends AbstractValidatingWizardPage implements @Override public void run() { // Get all peer model objects - IPeerModel[] peers = Model.getModel().getPeers(); + IPeerNode[] peers = Model.getModel().getPeers(); // Loop them and find the ones which are of our handled types - for (IPeerModel peerModel : peers) { - if (peerModel.isStatic()) { - String name = peerModel.getPeer().getName(); + for (IPeerNode peerNode : peers) { + String name = peerNode.getPeer().getName(); Assert.isNotNull(name); if (!"".equals(name) && !usedNames.contains(name)) { //$NON-NLS-1$ usedNames.add(name.trim().toUpperCase()); } - } } } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java index 35acdc10e..998465d72 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java @@ -51,8 +51,8 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; @@ -100,13 +100,13 @@ public class PeerExportWizardPage extends WizardPage { createPeersGroup(composite); createDestinationGroup(composite); - List elements = new ArrayList(); + List elements = new ArrayList(); Iterator it = fSelection.iterator(); while (it.hasNext()) { Object element = it.next(); - IPeerModel peerModel = (IPeerModel)Platform.getAdapterManager().getAdapter(element, IPeerModel.class); - if (peerModel != null) { - elements.add((IPeerModel)element); + IPeerNode peerNode = (IPeerNode)Platform.getAdapterManager().getAdapter(element, IPeerNode.class); + if (peerNode != null) { + elements.add((IPeerNode)element); } } fViewer.setCheckedElements(elements.toArray()); @@ -141,14 +141,10 @@ public class PeerExportWizardPage extends WizardPage { } @Override public Object[] getElements(Object inputElement) { - List elements = new ArrayList(); - for (IPeerModel peerModel : ((ILocatorModel)inputElement).getPeers()) { - if (peerModel.isStatic()) { - elements.add(peerModel); - } - + if (inputElement instanceof IPeerModel) { + return ((IPeerModel)inputElement).getPeers(); } - return elements.toArray(); + return new Object[0]; } @Override public Object[] getChildren(TreePath parentPath) { @@ -287,7 +283,7 @@ public class PeerExportWizardPage extends WizardPage { Object[] elements = fViewer.getCheckedElements(); boolean selected = false; for (Object element : elements) { - if(element instanceof IPeerModel) { + if(element instanceof IPeerNode) { selected = true; break; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java index 8fc219182..946c2d673 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java @@ -56,10 +56,10 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.tcf.core.interfaces.IImportPersistenceService; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.nls.Messages; import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider; @@ -336,7 +336,7 @@ public class PeerImportWizardPage extends WizardPage { UIJob importjob = new UIJob(getContainer().getShell().getDisplay(), Messages.PeerImportWizard_title) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { - final ILocatorModel model = Model.getModel(); + final IPeerModel model = Model.getModel(); final IProgressMonitor finalMonitor; if (monitor == null) { finalMonitor = new NullProgressMonitor(); @@ -349,25 +349,19 @@ public class PeerImportWizardPage extends WizardPage { int toggleResult = -1; for (final Object config : configs) { if (config instanceof IPeer) { - final AtomicReference peerModel = new AtomicReference(); + final AtomicReference peerNode = new AtomicReference(); Protocol.invokeAndWait(new Runnable() { @Override public void run() { - peerModel.set(model.getService(ILocatorModelLookupService.class).lkupPeerModelById(((IPeer)config).getID())); - if (peerModel.get() == null) { - for (IPeerModel peer : model.getPeers()) { - if (peer.isStatic()) { + peerNode.set(model.getService(IPeerModelLookupService.class).lkupPeerModelById(((IPeer)config).getID())); + if (peerNode.get() == null) { + for (IPeerNode peer : model.getPeers()) { String name = peer.getPeer().getName(); if (name.equalsIgnoreCase(((IPeer)config).getName())) { - peerModel.set(peer); + peerNode.set(peer); break; } - } } - - } - if (peerModel.get() != null && !peerModel.get().isStatic()) { - peerModel.set(null); } } }); @@ -376,11 +370,11 @@ public class PeerImportWizardPage extends WizardPage { if (service == null) { service = ServiceManager.getInstance().getService(IURIPersistenceService.class); } - if (peerModel.get() != null) { + if (peerNode.get() != null) { if (!toggleState || toggleResult < 0) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( getShell(), null, - NLS.bind(Messages.PeerImportWizardPage_overwriteDialog_message, peerModel.get().getName()), + NLS.bind(Messages.PeerImportWizardPage_overwriteDialog_message, peerNode.get().getName()), Messages.PeerImportWizardPage_overwriteDialogToggle_message, toggleState, null, null); toggleState = dialog.getToggleState(); toggleResult = dialog.getReturnCode(); @@ -389,7 +383,7 @@ public class PeerImportWizardPage extends WizardPage { continue; } try { - service.delete(peerModel.get().getPeer(), null); + service.delete(peerNode.get().getPeer(), null); } catch (IOException e) { } @@ -413,7 +407,7 @@ public class PeerImportWizardPage extends WizardPage { Protocol.invokeLater(new Runnable() { @Override public void run() { - model.getService(ILocatorModelRefreshService.class).refresh(null); + model.getService(IPeerModelRefreshService.class).refresh(null); } }); finalMonitor.done(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java index ba8b90af6..e526eb525 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java @@ -22,9 +22,9 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.model.factory.Factory; import org.eclipse.tcf.te.runtime.utils.Host; import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tests.CoreTestCase; @@ -39,7 +39,7 @@ public class TcfTestCase extends CoreTestCase { // The peer instance protected IPeer peer; // The peer model instance - protected IPeerModel peerModel; + protected IPeerNode peerNode; /* (non-Javadoc) * @see org.eclipse.tcf.te.tests.CoreTestCase#setUp() @@ -57,7 +57,7 @@ public class TcfTestCase extends CoreTestCase { protected void tearDown() throws Exception { if (launcher != null) launcher.dispose(); peer = null; - peerModel = null; + peerNode = null; super.tearDown(); } @@ -158,7 +158,7 @@ public class TcfTestCase extends CoreTestCase { final Map attrs = new HashMap((Map)object); // Lookup the corresponding peer object - final ILocatorModel model = Model.getModel(); + final IPeerModel model = Model.getModel(); assertNotNull("Failed to access locator model instance.", model); //$NON-NLS-1$ // The expected peer id is "::" @@ -170,17 +170,17 @@ public class TcfTestCase extends CoreTestCase { assertNotNull("Unexpected return value 'null'.", ip); //$NON-NLS-1$ final String id = transport + ":" + ip + ":" + port; //$NON-NLS-1$ //$NON-NLS-2$ - final AtomicReference node = new AtomicReference(); + final AtomicReference node = new AtomicReference(); Runnable runnable = new Runnable() { @Override public void run() { - node.set(model.getService(ILocatorModelLookupService.class).lkupPeerModelById(id)); + node.set(model.getService(IPeerModelLookupService.class).lkupPeerModelById(id)); // If the peer model is not found by id, try the agent id as fallback. if (node.get() == null) { String agentID = attrs.get(IPeer.ATTR_AGENT_ID); assertNotNull("Unexpected return value 'null'.", agentID); //$NON-NLS-1$ - IPeerModel[] candidates = model.getService(ILocatorModelLookupService.class).lkupPeerModelByAgentId(agentID); + IPeerNode[] candidates = model.getService(IPeerModelLookupService.class).lkupPeerModelByAgentId(agentID); if (candidates != null && candidates.length > 0) node.set(candidates[0]); } } @@ -193,10 +193,10 @@ public class TcfTestCase extends CoreTestCase { attrs.put(IPeer.ATTR_ID, id); attrs.put(IPeer.ATTR_IP_HOST, ip); peer = new TransientPeer(attrs); - peerModel = Factory.getInstance().newInstance(IPeerModel.class, new Object[] { model, peer }); + peerNode = Factory.getInstance().newInstance(IPeerNode.class, new Object[] { model, peer }); } else { - peerModel = node.get(); - peer = peerModel.getPeer(); + peerNode = node.get(); + peer = peerNode.getPeer(); } assertNotNull("Failed to determine the peer to use for the tests.", peer); //$NON-NLS-1$ } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/FSPeerTestCase.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/FSPeerTestCase.java index a8e44dd3f..e0b7b7748 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/FSPeerTestCase.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/FSPeerTestCase.java @@ -1,179 +1,179 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tests.tcf.filesystem; - -import java.io.File; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.tcf.protocol.IChannel; -import org.eclipse.tcf.protocol.IToken; -import org.eclipse.tcf.services.IFileSystem; -import org.eclipse.tcf.services.IFileSystem.DoneStat; -import org.eclipse.tcf.services.IFileSystem.FileAttrs; -import org.eclipse.tcf.services.IFileSystem.FileSystemException; -import org.eclipse.tcf.te.tcf.core.Tcf; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.NullOpExecutor; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreateFile; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreateFolder; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpParsePath; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRefresh; -import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation; -import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tests.tcf.TcfTestCase; - -public class FSPeerTestCase extends TcfTestCase { - - protected FSTreeNode testRoot; - protected FSTreeNode testFolder; - protected FSTreeNode testFile; - protected FSTreeNode test1Folder; - protected FSTreeNode test1File; - protected FSTreeNode test11Folder; - protected FSTreeNode test11File; - protected FSTreeNode test12Folder; - protected FSTreeNode test12File; - protected FSTreeNode test2Folder; - protected FSTreeNode test2File; - protected FSTreeNode test21Folder; - protected FSTreeNode test21File; - protected FSTreeNode test22Folder; - protected FSTreeNode test22File; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - assertNotNull(peerModel); - assertNotNull(peer); - - OpParsePath parser = new OpParsePath(peerModel, getTestRoot()); - new NullOpExecutor().execute(parser); - testRoot = parser.getResult(); - if(testRoot == null) { - File file = new File(getTestRoot()); - if (!file.exists()) { - file.mkdirs(); - } - parser = new OpParsePath(peerModel, getTestRoot()); - new NullOpExecutor().execute(parser); - testRoot = parser.getResult(); - } - - String path = getTestRoot() + getPathSep() + getTestPath(); - testFolder = prepareFolder(path, getTestPath(), testRoot); - testFile = prepareFile(path + getPathSep() + "test.txt", "test.txt", testFolder); //$NON-NLS-1$ //$NON-NLS-2$ - test1Folder = prepareFolder(path + getPathSep() + "test1", "test1", testFolder); //$NON-NLS-1$ //$NON-NLS-2$ - String path1 = path + getPathSep() + "test1"; //$NON-NLS-1$ - test1File = prepareFile(path1 + getPathSep() + "test1.txt", "test1.txt", test1Folder); //$NON-NLS-1$ //$NON-NLS-2$ - test11Folder = prepareFolder(path1 + getPathSep() + "test11", "test11", test1Folder); //$NON-NLS-1$ //$NON-NLS-2$ - String path11 = path1 + getPathSep() + "test11"; //$NON-NLS-1$ - test11File = prepareFile(path11 + getPathSep() + "test11.txt", "test11.txt", test11Folder); //$NON-NLS-1$ //$NON-NLS-2$ - test12Folder = prepareFolder(path1 + getPathSep() + "test12", "test12", test1Folder); //$NON-NLS-1$ //$NON-NLS-2$ - String path12 = path1 + getPathSep() + "test12"; //$NON-NLS-1$ - test12File = prepareFile(path12 + getPathSep() + "test12.txt", "test12.txt", test12Folder); //$NON-NLS-1$ //$NON-NLS-2$ - test2Folder = prepareFolder(path + getPathSep() + "test2", "test2", testFolder); //$NON-NLS-1$ //$NON-NLS-2$ - String path2 = path + getPathSep() + "test2"; //$NON-NLS-1$ - test2File = prepareFolder(path2 + getPathSep() + "test2.txt", "test2.txt", test2Folder); //$NON-NLS-1$ //$NON-NLS-2$ - test21Folder = prepareFolder(path2 + getPathSep() + "test21", "test21", test2Folder); //$NON-NLS-1$ //$NON-NLS-2$ - String path21 = path2 + getPathSep() + "test21"; //$NON-NLS-1$ - test21File = prepareFile(path21 + getPathSep() + "test21.txt", "test21.txt", test21Folder); //$NON-NLS-1$ //$NON-NLS-2$ - test22Folder = prepareFolder(path2 + getPathSep() + "test22", "test22", test2Folder); //$NON-NLS-1$ //$NON-NLS-2$ - String path22 = path2 + getPathSep() + "test22"; //$NON-NLS-1$ - test22File = prepareFile(path22 + getPathSep() + "test22.txt", "test22.txt", test22Folder); //$NON-NLS-1$ //$NON-NLS-2$ - } - - protected FSTreeNode prepareFolder(String folderPath, String folderName, FSTreeNode parentFolder) throws Exception { - printDebugMessage("Prepare folder " + folderPath); //$NON-NLS-1$ - FSTreeNode testFolder = getFSNode(folderPath); - if (testFolder == null) { - OpCreateFolder fs = new OpCreateFolder(parentFolder, folderName); - fs.run(new NullProgressMonitor()); - testFolder = getFSNode(folderPath); - } - return testFolder; - } - - protected boolean pathExists(String path) { - IChannel channel = null; - try { - channel = Operation.openChannel(peer); - if (channel != null) { - IFileSystem service = Operation.getBlockingFileSystem(channel); - if (service != null) { - final boolean[] exists = new boolean[1]; - service.lstat(path, new DoneStat() { - @Override - public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) { - exists[0] = error == null; - } - }); - return exists[0]; - } - } - } - catch (Exception e) { - } - finally { - if (channel != null) Tcf.getChannelManager().closeChannel(channel); - } - return false; - } - - protected FSTreeNode getFSNode(String path) { - OpParsePath parser = new OpParsePath(peerModel, path); - new NullOpExecutor().execute(parser); - FSTreeNode node = parser.getResult(); - if (node == null) { - OpRefresh refresh = new OpRefresh(testRoot); - try { - refresh.run(new NullProgressMonitor()); - } catch (Exception e) {} - - parser = new OpParsePath(peerModel, path); - new NullOpExecutor().execute(parser); - node = parser.getResult(); - } - return node; - } - - protected FSTreeNode prepareFile(String filePath, String fileName, FSTreeNode parentFolder) throws Exception { - printDebugMessage("Prepare file " + filePath); //$NON-NLS-1$ - FSTreeNode testFile = getFSNode(filePath); - if (testFile == null) { - OpCreateFile fs = new OpCreateFile(parentFolder, fileName); - fs.run(new NullProgressMonitor()); - testFile = getFSNode(filePath); - } - return testFile; - } - - protected String getTestPath() { - return "test"; //$NON-NLS-1$ - } - - private String rootDir; - - protected String getTestRoot() { - if (rootDir == null) { - String wdir = System.getProperty("user.home"); //$NON-NLS-1$ - if (wdir == null) wdir = System.getProperty("user.dir"); //$NON-NLS-1$ - rootDir = wdir + getPathSep() + "tmp_test_root"; //$NON-NLS-1$ - File file = new File(rootDir); - if (!file.exists()) { - file.mkdirs(); - } - } - return rootDir; - } - - protected String getPathSep() { - return File.separator; - } -} +/******************************************************************************* + * Copyright (c) 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tests.tcf.filesystem; + +import java.io.File; + +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.services.IFileSystem; +import org.eclipse.tcf.services.IFileSystem.DoneStat; +import org.eclipse.tcf.services.IFileSystem.FileAttrs; +import org.eclipse.tcf.services.IFileSystem.FileSystemException; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.NullOpExecutor; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreateFile; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreateFolder; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpParsePath; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRefresh; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tests.tcf.TcfTestCase; + +public class FSPeerTestCase extends TcfTestCase { + + protected FSTreeNode testRoot; + protected FSTreeNode testFolder; + protected FSTreeNode testFile; + protected FSTreeNode test1Folder; + protected FSTreeNode test1File; + protected FSTreeNode test11Folder; + protected FSTreeNode test11File; + protected FSTreeNode test12Folder; + protected FSTreeNode test12File; + protected FSTreeNode test2Folder; + protected FSTreeNode test2File; + protected FSTreeNode test21Folder; + protected FSTreeNode test21File; + protected FSTreeNode test22Folder; + protected FSTreeNode test22File; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + assertNotNull(peerNode); + assertNotNull(peer); + + OpParsePath parser = new OpParsePath(peerNode, getTestRoot()); + new NullOpExecutor().execute(parser); + testRoot = parser.getResult(); + if(testRoot == null) { + File file = new File(getTestRoot()); + if (!file.exists()) { + file.mkdirs(); + } + parser = new OpParsePath(peerNode, getTestRoot()); + new NullOpExecutor().execute(parser); + testRoot = parser.getResult(); + } + + String path = getTestRoot() + getPathSep() + getTestPath(); + testFolder = prepareFolder(path, getTestPath(), testRoot); + testFile = prepareFile(path + getPathSep() + "test.txt", "test.txt", testFolder); //$NON-NLS-1$ //$NON-NLS-2$ + test1Folder = prepareFolder(path + getPathSep() + "test1", "test1", testFolder); //$NON-NLS-1$ //$NON-NLS-2$ + String path1 = path + getPathSep() + "test1"; //$NON-NLS-1$ + test1File = prepareFile(path1 + getPathSep() + "test1.txt", "test1.txt", test1Folder); //$NON-NLS-1$ //$NON-NLS-2$ + test11Folder = prepareFolder(path1 + getPathSep() + "test11", "test11", test1Folder); //$NON-NLS-1$ //$NON-NLS-2$ + String path11 = path1 + getPathSep() + "test11"; //$NON-NLS-1$ + test11File = prepareFile(path11 + getPathSep() + "test11.txt", "test11.txt", test11Folder); //$NON-NLS-1$ //$NON-NLS-2$ + test12Folder = prepareFolder(path1 + getPathSep() + "test12", "test12", test1Folder); //$NON-NLS-1$ //$NON-NLS-2$ + String path12 = path1 + getPathSep() + "test12"; //$NON-NLS-1$ + test12File = prepareFile(path12 + getPathSep() + "test12.txt", "test12.txt", test12Folder); //$NON-NLS-1$ //$NON-NLS-2$ + test2Folder = prepareFolder(path + getPathSep() + "test2", "test2", testFolder); //$NON-NLS-1$ //$NON-NLS-2$ + String path2 = path + getPathSep() + "test2"; //$NON-NLS-1$ + test2File = prepareFolder(path2 + getPathSep() + "test2.txt", "test2.txt", test2Folder); //$NON-NLS-1$ //$NON-NLS-2$ + test21Folder = prepareFolder(path2 + getPathSep() + "test21", "test21", test2Folder); //$NON-NLS-1$ //$NON-NLS-2$ + String path21 = path2 + getPathSep() + "test21"; //$NON-NLS-1$ + test21File = prepareFile(path21 + getPathSep() + "test21.txt", "test21.txt", test21Folder); //$NON-NLS-1$ //$NON-NLS-2$ + test22Folder = prepareFolder(path2 + getPathSep() + "test22", "test22", test2Folder); //$NON-NLS-1$ //$NON-NLS-2$ + String path22 = path2 + getPathSep() + "test22"; //$NON-NLS-1$ + test22File = prepareFile(path22 + getPathSep() + "test22.txt", "test22.txt", test22Folder); //$NON-NLS-1$ //$NON-NLS-2$ + } + + protected FSTreeNode prepareFolder(String folderPath, String folderName, FSTreeNode parentFolder) throws Exception { + printDebugMessage("Prepare folder " + folderPath); //$NON-NLS-1$ + FSTreeNode testFolder = getFSNode(folderPath); + if (testFolder == null) { + OpCreateFolder fs = new OpCreateFolder(parentFolder, folderName); + fs.run(new NullProgressMonitor()); + testFolder = getFSNode(folderPath); + } + return testFolder; + } + + protected boolean pathExists(String path) { + IChannel channel = null; + try { + channel = Operation.openChannel(peer); + if (channel != null) { + IFileSystem service = Operation.getBlockingFileSystem(channel); + if (service != null) { + final boolean[] exists = new boolean[1]; + service.lstat(path, new DoneStat() { + @Override + public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) { + exists[0] = error == null; + } + }); + return exists[0]; + } + } + } + catch (Exception e) { + } + finally { + if (channel != null) Tcf.getChannelManager().closeChannel(channel); + } + return false; + } + + protected FSTreeNode getFSNode(String path) { + OpParsePath parser = new OpParsePath(peerNode, path); + new NullOpExecutor().execute(parser); + FSTreeNode node = parser.getResult(); + if (node == null) { + OpRefresh refresh = new OpRefresh(testRoot); + try { + refresh.run(new NullProgressMonitor()); + } catch (Exception e) {} + + parser = new OpParsePath(peerNode, path); + new NullOpExecutor().execute(parser); + node = parser.getResult(); + } + return node; + } + + protected FSTreeNode prepareFile(String filePath, String fileName, FSTreeNode parentFolder) throws Exception { + printDebugMessage("Prepare file " + filePath); //$NON-NLS-1$ + FSTreeNode testFile = getFSNode(filePath); + if (testFile == null) { + OpCreateFile fs = new OpCreateFile(parentFolder, fileName); + fs.run(new NullProgressMonitor()); + testFile = getFSNode(filePath); + } + return testFile; + } + + protected String getTestPath() { + return "test"; //$NON-NLS-1$ + } + + private String rootDir; + + protected String getTestRoot() { + if (rootDir == null) { + String wdir = System.getProperty("user.home"); //$NON-NLS-1$ + if (wdir == null) wdir = System.getProperty("user.dir"); //$NON-NLS-1$ + rootDir = wdir + getPathSep() + "tmp_test_root"; //$NON-NLS-1$ + File file = new File(rootDir); + if (!file.exists()) { + file.mkdirs(); + } + } + return rootDir; + } + + protected String getPathSep() { + return File.separator; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/AdaptersTests.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/AdaptersTests.java index a8405cae9..a8519e44b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/AdaptersTests.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/AdaptersTests.java @@ -1,24 +1,24 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tests.tcf.filesystem.adapters; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AdaptersTests { - public static Test suite() { - TestSuite suite = new TestSuite("File System: Adapters Tests"); //$NON-NLS-1$ - suite.addTestSuite(FSTreeNodeAdapterFactoryTest.class); - suite.addTestSuite(NodeStateFilterTest.class); - suite.addTestSuite(PeerModelViewerInputTest.class); - suite.addTestSuite(ViewerInputAdapterFactoryTest.class); - return suite; - } -} +/******************************************************************************* + * Copyright (c) 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tests.tcf.filesystem.adapters; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AdaptersTests { + public static Test suite() { + TestSuite suite = new TestSuite("File System: Adapters Tests"); //$NON-NLS-1$ + suite.addTestSuite(FSTreeNodeAdapterFactoryTest.class); + suite.addTestSuite(NodeStateFilterTest.class); + suite.addTestSuite(PeerNodeViewerInputTest.class); + suite.addTestSuite(ViewerInputAdapterFactoryTest.class); + return suite; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/PeerModelViewerInputTest.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/PeerModelViewerInputTest.java deleted file mode 100644 index 5f92880cf..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/PeerModelViewerInputTest.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tests.tcf.filesystem.adapters; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.tcf.te.core.interfaces.IViewerInput; -import org.eclipse.tcf.te.tests.tcf.filesystem.FSPeerTestCase; - -public class PeerModelViewerInputTest extends FSPeerTestCase { - public void testViewerInputId() { - IViewerInput input = (IViewerInput) Platform.getAdapterManager().getAdapter(peerModel, IViewerInput.class); - assertNotNull(input); - String id = input.getInputId(); - assertEquals(peerModel.getPeerId(), id); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/PeerNodeViewerInputTest.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/PeerNodeViewerInputTest.java new file mode 100644 index 000000000..b1fee22d8 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/PeerNodeViewerInputTest.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tests.tcf.filesystem.adapters; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.tcf.te.core.interfaces.IViewerInput; +import org.eclipse.tcf.te.tests.tcf.filesystem.FSPeerTestCase; + +public class PeerNodeViewerInputTest extends FSPeerTestCase { + public void testViewerInputId() { + IViewerInput input = (IViewerInput) Platform.getAdapterManager().getAdapter(peerNode, IViewerInput.class); + assertNotNull(input); + String id = input.getInputId(); + assertEquals(peerNode.getPeerId(), id); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/ViewerInputAdapterFactoryTest.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/ViewerInputAdapterFactoryTest.java index b73a13f56..0a1de01ce 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/ViewerInputAdapterFactoryTest.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/ViewerInputAdapterFactoryTest.java @@ -1,21 +1,21 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tcf.te.tests.tcf.filesystem.adapters; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.tcf.te.core.interfaces.IViewerInput; -import org.eclipse.tcf.te.tests.tcf.filesystem.FSPeerTestCase; - -public class ViewerInputAdapterFactoryTest extends FSPeerTestCase { - public void testViewerInputAdapter() { - IViewerInput input = (IViewerInput) Platform.getAdapterManager().getAdapter(peerModel, IViewerInput.class); - assertNotNull(input); - } -} +/******************************************************************************* + * Copyright (c) 2012 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tests.tcf.filesystem.adapters; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.tcf.te.core.interfaces.IViewerInput; +import org.eclipse.tcf.te.tests.tcf.filesystem.FSPeerTestCase; + +public class ViewerInputAdapterFactoryTest extends FSPeerTestCase { + public void testViewerInputAdapter() { + IViewerInput input = (IViewerInput) Platform.getAdapterManager().getAdapter(peerNode, IViewerInput.class); + assertNotNull(input); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/testers/TargetPropertyTesterTest.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/testers/TargetPropertyTesterTest.java index 898ada6fd..474663d60 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/testers/TargetPropertyTesterTest.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/testers/TargetPropertyTesterTest.java @@ -1,27 +1,27 @@ -/******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying