Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2015-04-15 05:51:11 -0400
committerUwe Stieber2015-04-22 00:50:01 -0400
commitc9fdfa571f4f1c1f0342826c6876959070218ae2 (patch)
treea73ccddfe1c6a63c046049624f014ef9f8a7682d
parentfe3749f028190d5a67e2dc3e2aba609e111eb799 (diff)
downloadorg.eclipse.tcf-c9fdfa571f4f1c1f0342826c6876959070218ae2.tar.gz
org.eclipse.tcf-c9fdfa571f4f1c1f0342826c6876959070218ae2.tar.xz
org.eclipse.tcf-c9fdfa571f4f1c1f0342826c6876959070218ae2.zip
Bug 464665: Introduce API between te.tcf.filesystem.core and ui
Change-Id: I5ec26fc8708a7110565a64478d7097f6ee366be2 Signed-off-by: Markus Schorn <markus.schorn@windriver.com>
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/dnd/CommonDnD.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/.settings/org.eclipse.jdt.core.prefs20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/META-INF/MANIFEST.MF7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java46
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IResultOperation.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/callbacks/CallbackTests.java)18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNode.java152
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNodeBase.java148
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNodeWorkingCopy.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IUserAccount.java24
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java637
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNodeBase.java97
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNodeWorkingCopy.java246
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/CallbackBase.java35
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpen.java82
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpenChannel.java93
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneReadDir.java96
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneRoots.java64
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneOpenChannel.java88
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneStat.java111
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/AbstractOperation.java239
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/IOpExecutor.java28
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/JobExecutor.java100
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/NullOpExecutor.java79
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java65
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheUpdate.java76
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpClipboard.java113
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java85
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java393
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java184
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java93
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java76
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java366
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java228
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java375
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpOutStreamOp.java98
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java161
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java379
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefreshRoots.java77
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java120
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpStreamOp.java74
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java127
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java594
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java167
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java618
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/TCFResult.java134
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/TargetPropertyTester.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfInputStream.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java36
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java78
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java98
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/StatusHelper.java29
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java342
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java681
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java171
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java209
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/UserAccount.java95
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java35
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties78
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/Operation.java108
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.jdt.core.prefs21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml140
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSNavigatorContentProvider.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSTreeViewerSorter.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java86
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/TreeContentProvider.java25
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSFolderSelectionDialog.java61
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSOpenFileDialog.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/HiddenFilesViewerFilter.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/SystemFilesViewerFilter.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeFactory.java48
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeLoader.java49
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PersistableNode.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java48
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellModifier.java29
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellValidator.java28
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeComparator.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeLabelProvider.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/CacheFileImageUpdater.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/DefaultImageProvider.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementComparator.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementLabelProvider.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeNodeComparator.java37
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileExtBasedImageUpdater.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeComparator.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeLabelProvider.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageProvider.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageUpdateAdapter.java21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/LabelProviderUpdateDaemon.java72
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ModificationTimeComparator.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ModificationTimeLabelProvider.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/SizeComparator.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/SizeLabelProvider.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/WindowsImageProvider.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/compare/EditableSharedDocumentAdapter.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/compare/LocalFileSaveable.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/compare/LocalTypedElement.java24
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/compare/MergeEditorInput.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/compare/MergeInput.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/compare/MergeTypedElement.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/compare/RemoteTypedElement.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/decorators/PhantomDecorator.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java310
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragAdapterAssistant.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropAdapterAssistant.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/CommitHandler.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/CopyFilesHandler.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/CutFilesHandler.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/DeleteHandler.java30
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/MergeHandler.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/MoveCopyCallback.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/MoveFilesHandler.java19
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/OpenFileHandler.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/OpenWithContribution.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/OpenWithMenu.java88
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/PasteFilesHandler.java52
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/RefreshHandler.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/RefreshViewerHandler.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/RenameCallback.java46
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/RenameFilesHandler.java30
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/UpdateHandler.java21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/operations/FsClipboard.java78
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/operations/UiExecutor.java111
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/pages/FSExplorerEditorPage.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/pages/FSExplorerEventListener.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/properties/AdvancedAttributesDialog.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/properties/GeneralInformationPage.java129
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSGeneralSearchable.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSModifiedSearchable.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSSizeSearchable.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeMatcher.java37
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFileSection.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java19
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/FileFilter.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/FolderFilter.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxFilter.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/LinuxPermissionsSection.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesCESection.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsAttributesSection.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFileFilter.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFilter.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderAISection.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/WindowsFolderFilter.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/testers/ClipboardPropertyTester.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/FolderValidator.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NameValidator.java57
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewFileWizard.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewFolderWizard.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizard.java59
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/NewNodeWizardPage.java30
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetPatternFilter.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/wizards/TargetSelectionPage.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TECDSFMainTab.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/CoreTestCase.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/suites/AllFileSystemTests.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/FSPeerTestCase.java41
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/callbacks/QueryChildrenCallbackTest.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/dnd/CommonDnDTest.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/operations/FSCopyTests.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/operations/FSCreateFileTests.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/operations/FSCreateFolderTests.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/operations/FSMoveTests.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/operations/FSRefreshTests.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/operations/FSRenameTests.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/operations/FSUploadTest.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/operations/OperationTestBase.java35
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/utils/ContentTypeHelperTest.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/utils/StateManagerTest.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/utils/UtilsTestBase.java9
192 files changed, 5259 insertions, 6934 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/dnd/CommonDnD.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/dnd/CommonDnD.java
index d9cfe5505..257a521bc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/dnd/CommonDnD.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/viewer/dnd/CommonDnD.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -219,11 +219,8 @@ public class CommonDnD {
}
valid = allow;
- if (dropAdapter != null) {
- if (!valid) {
- dropAdapter.overrideOperation(DND.DROP_NONE);
- }
- else if (overrideOperation > -1) {
+ if (dropAdapter != null && valid) {
+ if (overrideOperation > -1) {
dropAdapter.overrideOperation(overrideOperation);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/.settings/org.eclipse.jdt.core.prefs b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/.settings/org.eclipse.jdt.core.prefs
index e01c0c0cb..43aff52a3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/.settings/org.eclipse.jdt.core.prefs
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,10 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
@@ -13,6 +19,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
@@ -26,7 +33,9 @@ org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
@@ -35,12 +44,18 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warni
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
@@ -50,10 +65,12 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
@@ -72,6 +89,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.6
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/META-INF/MANIFEST.MF
index 1b97b748e..ea1a529e2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/META-INF/MANIFEST.MF
@@ -25,13 +25,12 @@ Export-Package: org.eclipse.tcf.te.tcf.filesystem.core.activator;x-internal:=tru
org.eclipse.tcf.te.tcf.filesystem.core.interfaces,
org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime,
org.eclipse.tcf.te.tcf.filesystem.core.interfaces.steps,
- org.eclipse.tcf.te.tcf.filesystem.core.internal;x-internal:=true,
- org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks;x-friends:="org.eclipse.tcf.te.tests",
+ org.eclipse.tcf.te.tcf.filesystem.core.internal;x-friends:="org.eclipse.tcf.te.tests",
org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions;x-friends:="org.eclipse.tcf.te.tcf.filesystem.ui,org.eclipse.tcf.te.tests",
- org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;x-friends:="org.eclipse.tcf.te.tcf.filesystem.ui,org.eclipse.tcf.te.tests",
+ org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;x-friends:="org.eclipse.tcf.te.tests",
org.eclipse.tcf.te.tcf.filesystem.core.internal.testers;x-friends:="org.eclipse.tcf.te.tests",
org.eclipse.tcf.te.tcf.filesystem.core.internal.url;x-friends:="org.eclipse.tcf.te.tests",
- org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;x-friends:="org.eclipse.tcf.te.tcf.filesystem.ui,org.eclipse.tcf.te.tests",
+ org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;x-friends:="org.eclipse.tcf.te.tests",
org.eclipse.tcf.te.tcf.filesystem.core.model,
org.eclipse.tcf.te.tcf.filesystem.core.nls;x-internal:=true,
org.eclipse.tcf.te.tcf.filesystem.core.services,
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 5f982e785..7c1588ca0 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
@@ -39,7 +39,7 @@
id="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode"
namespace="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode"
properties="isFile,isDirectory,isBinaryFile,isReadable,isWritable,isExecutable,isRoot,isReadOnly,isHidden,isWindows,testParent,getCacheState,isSystemRoot"
- type="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ type="org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode">
</propertyTester>
<propertyTester
class="org.eclipse.tcf.te.tcf.filesystem.core.internal.testers.TargetPropertyTester"
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java
index 99a5a4ed1..341b0c0ea 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -9,9 +9,9 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.interfaces;
-import java.lang.reflect.InvocationTargetException;
-
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
/**
* A class that implement this interface represents an file system operation,
@@ -24,38 +24,24 @@ public interface IOperation {
*/
public static final String MD_ALG = "MD5"; //$NON-NLS-1$
- /**
- * Runs this operation. Progress should be reported to the given progress monitor.
- * A request to cancel the operation should be honored and acknowledged
- * by throwing <code>InterruptedException</code>.
- *
- * @param monitor the progress monitor to use to display progress and receive
- * requests for cancellation
- * @exception InvocationTargetException if the run method must propagate a checked exception,
- * it should wrap it inside an <code>InvocationTargetException</code>; runtime exceptions are automatically
- * wrapped in an <code>InvocationTargetException</code> by the calling context
- * @exception InterruptedException if the operation detects a request to cancel,
- * using <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing
- * <code>InterruptedException</code>
- *
+ /**
+ * Returns the name of the operation
+ */
+ public String getName();
+
+ /**
+ * Runs this operation.
*/
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException;
+ public IStatus run(IProgressMonitor monitor);
/**
- * Get the operation's name. This name will be used as the task name of
- * the given monitor.
- *
- * @see IProgressMonitor#beginTask(String, int)
- * @return The name of the operation.
+ * Runs the operation in a job and calls the callback after the job has been
+ * completed or cancelled.
*/
- public String getName();
+ public void runInJob(ICallback callback);
/**
- * Get the total amount of work which will used by the progress
- * monitor to set the total work.
- *
- * @see IProgressMonitor#beginTask(String, int)
- * @return The total amount of work or UNKNOWN if it is in-determinant
+ * Runs the operation in a job with user interaction set to true
*/
- public int getTotalWork();
+ public void runInUserJob(ICallback object);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/callbacks/CallbackTests.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IResultOperation.java
index bb68040c2..e83ef896b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/callbacks/CallbackTests.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IResultOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -7,15 +7,13 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.tests.tcf.filesystem.callbacks;
+package org.eclipse.tcf.te.tcf.filesystem.core.interfaces;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-public class CallbackTests {
- public static Test suite() {
- TestSuite suite = new TestSuite("File System: Callback Tests"); //$NON-NLS-1$
- suite.addTestSuite(QueryChildrenCallbackTest.class);
- return suite;
- }
+/**
+ * A class that implement this interface represents an file system operation,
+ * which is an abstract of the action operated over files/folders.
+ */
+public interface IResultOperation<T> extends IOperation {
+ T getResult();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java
index f333e54f3..3142cb1ea 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/IWindowsFileAttributes.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -12,7 +12,6 @@ package org.eclipse.tcf.te.tcf.filesystem.core.interfaces;
/**
* Windows specific file system attribute definitions.
*
- * @see <nop>Windows File Attribute Constants for more details.
*/
public interface IWindowsFileAttributes {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNode.java
new file mode 100644
index 000000000..fdd01d1a6
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNode.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+
+public interface IFSTreeNode extends IFSTreeNodeBase, IAdaptable {
+ /**
+ * Returns the runtime model this node belongs to
+ */
+ IRuntimeModel getRuntimeModel();
+
+ /**
+ * Returns the peer node this node belongs to
+ */
+ IPeerNode getPeerNode();
+
+ /**
+ * Returns the parent node, or <code>null</code>
+ */
+ IFSTreeNode getParent();
+
+ /**
+ * Returns the children of this node, may be <code>null</code> in case the children
+ * have not been queried.
+ */
+ IFSTreeNode[] getChildren();
+
+ /**
+ * Returns an URL for this node
+ */
+ URL getLocationURL();
+
+ /**
+ * Returns an URI for this node
+ */
+ URI getLocationURI();
+
+ /**
+ * Return the last refresh time
+ */
+ long getLastRefresh();
+
+ /**
+ * Returns the current known cache state of this node.
+ */
+ CacheState getCacheState();
+
+ /**
+ * Returns the location of the local cache file, does not actually create the cache.
+ */
+ File getCacheFile();
+
+ /**
+ * Returns the preferred editor ID or <code>null</code>.
+ */
+ String getPreferredEditorID();
+
+ /**
+ * Stores a preferred editor id
+ */
+ void setPreferredEditorID(String editorID);
+
+ /**
+ * Returns the content type of the file, or <code>null</code> if not applicable
+ */
+ IContentType getContentType();
+
+ /**
+ * Checks whether the file is binary.
+ */
+ boolean isBinaryFile();
+
+ /**
+ * Checks whether this node is an ancestor of the argument
+ */
+ boolean isAncestorOf(IFSTreeNode target);
+
+ /**
+ * Returns an operation for refreshing the node
+ */
+ IOperation operationRefresh(boolean recursive);
+
+ /**
+ * Returns an operation for renaming the node
+ */
+ IOperation operationRename(String newName);
+
+ /**
+ * Returns an operation for uploading the content of the given file to the remote file
+ * represented by this node.
+ */
+ IOperation operationUploadContent(File srcFile);
+
+ /**
+ * Returns an operation to delete the remote file.
+ */
+ IOperation operationDelete(IConfirmCallback readonlyCallback);
+
+ /**
+ * Returns an operation for downloading the remote file to the given output stream
+ * @param output stream receiving the content of the remote file, or <code>null</code> for
+ * downloading it to the local cache.
+ */
+ IOperation operationDownload(OutputStream output);
+
+ /**
+ * Returns an operation for uploading the given files into this remote directory
+ */
+ IOperation operationDropFiles(List<String> files, IConfirmCallback confirmCallback);
+
+ /**
+ * Returns an operation for moving the given remote files into this remote directory
+ */
+ IOperation operationDropMove(List<IFSTreeNode> nodes, IConfirmCallback confirmCallback);
+
+ /**
+ * Returns an operation for copying the given remote files into this remote directory
+ */
+ IOperation operationDropCopy(List<IFSTreeNode> nodes, boolean cpPerm, boolean cpOwn, IConfirmCallback moveCopyCallback);
+
+ /**
+ * Returns an operation for creating a new remote file
+ */
+ IResultOperation<? extends IFSTreeNode> operationNewFile(String name);
+
+ /**
+ * Returns an operation for creating a new remote folder
+ */
+ IResultOperation<? extends IFSTreeNode> operationNewFolder(String name);
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNodeBase.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNodeBase.java
new file mode 100644
index 000000000..1d274a2b4
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNodeBase.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime;
+
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IWindowsFileAttributes;
+
+public interface IFSTreeNodeBase {
+ enum Type {
+ FILE_SYSTEM, ROOT, DIRECTORY_OR_FILE
+ }
+
+ /**
+ * Returns the name of the tree node.
+ */
+ String getName();
+
+ /**
+ * Returns the type of the tree node.
+ */
+ Type getType();
+
+ /**
+ * Returns the location of the file on the remote system
+ */
+ String getLocation();
+
+ /**
+ * Returns a label for the type of the file or directory
+ */
+ String getFileTypeLabel();
+
+ /**
+ * Returns information about the user account under which the remote agent accesses
+ * the file system
+ */
+ IUserAccount getUserAccount();
+
+ /**
+ * Creates a working copy for the purpose of changing permissions
+ */
+ IFSTreeNodeWorkingCopy createWorkingCopy();
+
+ /**
+ * Returns whether this node represents the entire file system
+ */
+ boolean isFileSystem();
+
+ /**
+ * Returns whether this node represents a root directory like a disk
+ */
+ boolean isRootDirectory();
+
+ /**
+ * Returns whether this node represents a directory. Root directories are
+ * also considered to be directories.
+ */
+ boolean isDirectory();
+
+ /**
+ * Returns whether this node represents a file.
+ */
+ boolean isFile();
+
+ /**
+ * Returns the time of the last access
+ */
+ long getAccessTime();
+
+ /**
+ * Returns the time of the last modification
+ */
+ long getModificationTime();
+
+ /**
+ * Returns the size of the file or <code>0</code>, if not applicable.
+ */
+ long getSize();
+
+ /**
+ * Returns whether the file is marked as read only (Windows feature)
+ */
+ boolean isReadOnly();
+
+ /**
+ * Checks whether the agent has read permissions for the file
+ */
+ boolean isReadable();
+
+ /**
+ * Checks whether the agent has write permissions for the file
+ */
+ boolean isWritable();
+
+ /**
+ * Checks whether the agent has execute permissions for the file
+ */
+ boolean isExecutable();
+
+ /**
+ * Checks whether the file is marked as a system file (Windows feature)
+ */
+ boolean isSystemFile();
+
+ /**
+ * Checks whether the file is marked as a hidden file (Windows feature)
+ */
+ boolean isHidden();
+
+ /**
+ * Checks whether the agent is the owner of the file
+ */
+ boolean isAgentOwner();
+
+ /**
+ * Checks whether the node represents a windows file entity
+ */
+ boolean isWindowsNode();
+
+ /**
+ * Checks for the given permissions.
+ * @param bit a combination of IFileSystem.S_ values
+ */
+ boolean getPermission(int bit);
+
+ /**
+ * Checks for the given windows attribute.
+ * @param attribute a combination of attributes defined at {@link IWindowsFileAttributes}
+ */
+ boolean getWin32Attr(int attribute);
+
+ /**
+ * Returns the user id for this file
+ */
+ int getUID();
+
+ /**
+ * Returns the group id for this file
+ */
+ int getGID();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNodeWorkingCopy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNodeWorkingCopy.java
new file mode 100644
index 000000000..b8b1cbdbc
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNodeWorkingCopy.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime;
+
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IWindowsFileAttributes;
+
+
+public interface IFSTreeNodeWorkingCopy extends IFSTreeNodeBase {
+
+ /**
+ * Sets the write permission depending on whether the agent is owner, group member or
+ * neither.
+ */
+ void setWritable(boolean value);
+
+ /**
+ * Sets a permission as defined in {@link IFileSystem}
+ */
+ void setPermission(int bit, boolean value);
+
+ /**
+ * Changes the read only attribute (windows feature)
+ */
+ void setReadOnly(boolean value);
+
+ /**
+ * Changes the hidden attribute (windows feature)
+ */
+ void setHidden(boolean selection);
+
+ /**
+ * Sets a windows attribute as defined in {@link IWindowsFileAttributes}.
+ */
+ void setWin32Attr(int bit, boolean value);
+
+ /**
+ * Checks whether the working copy is dirty with respect to the original node
+ */
+ boolean isDirty();
+
+ /**
+ * Returns an operation for applying the changes
+ */
+ IOperation operationCommit();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java
index c89068eb4..ad93b6418 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014, 2015 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
@@ -9,8 +9,9 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider;
@@ -19,10 +20,18 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider;
*/
public interface IRuntimeModel extends IModel, IPeerNodeProvider {
+ /**
+ * Returns the channel of this runtime model
+ */
+ public IChannel getChannel();
+
+ /**
+ * Returns the root node of this model.
+ */
+ public IFSTreeNode getRoot();
+
/**
- * Get the root node of the peer model.
- *
- * @return The root node.
+ * Returns an operation for restoring nodes from a path
*/
- public FSTreeNode getRoot();
+ public IResultOperation<IFSTreeNode> operationRestoreFromPath(String path);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IUserAccount.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IUserAccount.java
new file mode 100644
index 000000000..d2e4ba820
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IUserAccount.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime;
+
+public interface IUserAccount {
+
+ /**
+ * Returns the effective user id of the remote agent
+ */
+ int getEUID();
+
+ /**
+ * Returns the effective group id of the remote agent
+ */
+ int getEGID();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java
new file mode 100644
index 000000000..62310a511
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java
@@ -0,0 +1,637 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2015 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
+ * William Chen (Wind River) - [345384] Provide property pages for remote file system nodes
+ * William Chen (Wind River) - [352302]Opening a file in an editor depending on
+ * the client's permissions.
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.internal;
+
+import static java.util.Collections.singletonList;
+
+import java.beans.PropertyChangeEvent;
+import java.io.File;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.services.IFileSystem.FileAttrs;
+import org.eclipse.tcf.te.core.interfaces.IFilterable;
+import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
+import org.eclipse.tcf.te.core.interfaces.IViewerInput;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNodeWorkingCopy;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCopy;
+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.OpDelete;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDownload;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpMove;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRefresh;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRename;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpUpload;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.testers.TargetPropertyTester;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLStreamHandlerService;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.ContentTypeHelper;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.RuntimeModel;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+
+/**
+ * Representation of a file system tree node.
+ * <p>
+ * <b>Note:</b> Node construction and child list access is limited to the TCF
+ * event dispatch thread.
+ */
+@SuppressWarnings("deprecation")
+public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, IFSTreeNode, org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode {
+ private static final QualifiedName EDITOR_KEY = new QualifiedName("org.eclipse.ui.internal.registry.ResourceEditorRegistry", "EditorProperty");//$NON-NLS-2$//$NON-NLS-1$
+ static final String KEY_WIN32_ATTRS = "Win32Attrs"; //$NON-NLS-1$
+ private static final Comparator<FSTreeNode> CMP_WIN = new Comparator<FSTreeNode>() {
+ @Override
+ public int compare(FSTreeNode o1, FSTreeNode o2) {
+ return o1.getName().compareToIgnoreCase(o2.getName());
+ }
+ };
+ private static final Comparator<FSTreeNode> CMP_UNIX = new Comparator<FSTreeNode>() {
+ @Override
+ public int compare(FSTreeNode o1, FSTreeNode o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ };
+
+
+ private FSTreeNode fParent;
+ private String fName;
+
+ private Type fType;
+ private IFileSystem.FileAttrs fAttributes;
+
+ private FSTreeNode[] fChildren = null;
+
+ private final RuntimeModel fRuntimeModel;
+ private final boolean fWindowsNode;
+ private long fRefreshTime;
+
+
+ public FSTreeNode(RuntimeModel runtimeModel, String name) {
+ fRuntimeModel = runtimeModel;
+ fParent = null;
+ fName = name;
+ fAttributes = null;
+ fType = Type.FILE_SYSTEM;
+ fWindowsNode = isWindowsNode(getPeerNode());
+ Assert.isTrue(Protocol.isDispatchThread());
+ }
+
+ private boolean isWindowsNode(IPeerNode peerNode) {
+ String osname = TargetPropertyTester.getOSName(peerNode);
+ if (osname != null){
+ return osname.startsWith("Windows"); //$NON-NLS-1$
+ }
+ return false;
+ }
+
+ public FSTreeNode(FSTreeNode parent, String name, boolean isRootDir, IFileSystem.FileAttrs attribs) {
+ fRuntimeModel = parent.getRuntimeModel();
+ fWindowsNode = parent.isWindowsNode() || (isRootDir && name.endsWith("\\")); //$NON-NLS-1$
+ fParent = parent;
+ fName = name;
+ fAttributes = attribs;
+ if (isRootDir) {
+ fType = Type.ROOT;
+ } else {
+ fType = Type.DIRECTORY_OR_FILE;
+ }
+ Assert.isTrue(Protocol.isDispatchThread());
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + ": name=" + fName; //$NON-NLS-1$
+ }
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ if(IViewerInput.class.equals(adapter)) {
+ return getPeerNode().getAdapter(IViewerInput.class);
+ }
+ if(IPropertyChangeProvider.class.equals(adapter)) {
+ return getPeerNode().getAdapter(adapter);
+ }
+ return super.getAdapter(adapter);
+ }
+
+ @Override
+ public RuntimeModel getRuntimeModel() {
+ return fRuntimeModel;
+ }
+
+ @Override
+ public IPeerNode getPeerNode() {
+ return fRuntimeModel.getPeerNode();
+ }
+
+ @Override
+ public UserAccount getUserAccount() {
+ return fRuntimeModel.getUserAccount();
+ }
+
+ @Override
+ public Type getType() {
+ return fType;
+ }
+
+ @Override
+ public boolean isWindowsNode() {
+ return fWindowsNode;
+ }
+
+ @Override
+ public boolean isFile() {
+ return fAttributes != null && fAttributes.isFile();
+ }
+
+ @Override
+ public boolean isDirectory() {
+ switch(fType) {
+ case FILE_SYSTEM:
+ return false;
+ case ROOT:
+ return true;
+ case DIRECTORY_OR_FILE:
+ return fAttributes == null || fAttributes.isDirectory();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isRootDirectory() {
+ return fType == Type.ROOT;
+ }
+
+ public FileAttrs getAttributes() {
+ return fAttributes;
+ }
+
+ @Override
+ protected int getWin32Attrs() {
+ final FileAttrs attribs = fAttributes;
+ if (attribs != null && attribs.attributes != null) {
+ Object val = attribs.attributes.get(KEY_WIN32_ATTRS);
+ if (val instanceof Integer) {
+ return ((Integer) val).intValue();
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ protected int getPermissions() {
+ final FileAttrs attribs = fAttributes;
+ if (attribs != null) {
+ return attribs.permissions;
+ }
+ return 0;
+ }
+
+ @Override
+ public String getLocation() {
+ return getLocation(false);
+ }
+
+ public String getLocation(boolean forceSlashes) {
+ return getLocation(isWindowsNode() && !forceSlashes ? '\\' : '/', false);
+ }
+
+ private String getLocation(char separator, boolean encodeName) {
+ String name = getName();
+ if (fType == Type.ROOT) {
+ if (isWindowsNode() && name.charAt(name.length()-1) != separator) {
+ return name.substring(0, name.length()-1) + separator;
+ }
+ return name;
+ }
+ if (fParent == null)
+ return name;
+
+
+ String pLoc = fParent.getLocation(separator, encodeName);
+ if (pLoc.length() == 0)
+ return name;
+
+ if (encodeName) {
+ try {
+ name = URLEncoder.encode(getName(), "UTF-8"); //$NON-NLS-1$
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ char lastChar = pLoc.charAt(pLoc.length()-1);
+ if (lastChar != separator)
+ return pLoc + separator + name;
+
+ return pLoc + name;
+ }
+
+ /**
+ * Get the URL of the file or folder. The URL's format is created in the
+ * following way: tcf:/<TCF_AGENT_ID>/remote/path/to/the/resource... See
+ * {@link TcfURLConnection#TcfURLConnection(URL)}
+ *
+ * @see TcfURLStreamHandlerService#parseURL(URL, String, int, int)
+ * @see #getLocationURI()
+ * @return The URL of the file/folder.
+ */
+ @Override
+ public URL getLocationURL() {
+ try {
+ String id = getPeerNode().getPeerId();
+ String path = getLocation(true);
+ String location = TcfURLConnection.PROTOCOL_SCHEMA + ":/" + id + (path.startsWith("/") ? path : "/" + path); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return new URL(location);
+ } catch (MalformedURLException e) {
+ assert false;
+ return null;
+ }
+ }
+
+ /**
+ * Get the URI of the file or folder. The URI's format is created in the
+ * following way: tcf:/<TCF_AGENT_ID>/remote/path/to/the/resource...
+ *
+ * @return The URI of the file/folder.
+ */
+ @Override
+ public URI getLocationURI() {
+ try {
+ String id = getPeerNode().getPeerId();
+ String path = getLocation('/', true);
+ String location = TcfURLConnection.PROTOCOL_SCHEMA + ":/" + id + (path.startsWith("/") ? path : "/" + path); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return new URI(location);
+ }
+ catch (URISyntaxException e) {
+ assert false;
+ return null;
+ }
+ }
+
+ /**
+ * Get the type label of the file for displaying purpose.
+ *
+ * @return The type label text.
+ */
+ @Override
+ public String getFileTypeLabel() {
+ switch (fType) {
+ case FILE_SYSTEM:
+ return Messages.FSTreeNodeContentProvider_rootNodeLabel;
+ case ROOT:
+ return Messages.FSTreeNode_TypeLocalDisk;
+ case DIRECTORY_OR_FILE:
+ break;
+ }
+
+ if (isDirectory())
+ return Messages.FSTreeNode_TypeFileFolder;
+
+ if (isSystemFile()) {
+ return Messages.FSTreeNode_TypeSystemFile;
+ }
+ IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(getName());
+ if (contentType != null) {
+ return contentType.getName();
+ }
+ int lastDot = getName().lastIndexOf("."); //$NON-NLS-1$
+ if (lastDot == -1) {
+ return Messages.FSTreeNode_TypeUnknownFile;
+ }
+ return getName().substring(lastDot + 1).toUpperCase() + " " + Messages.FSTreeNode_TypeFile; //$NON-NLS-1$
+ }
+
+
+ /**
+ * Get the local file's state of the specified tree node. The local file must exist
+ * before calling this method to get its state.
+ *
+ * @return The tree node's latest cache state.
+ */
+ @Override
+ public CacheState getCacheState() {
+ File file = CacheManager.getCacheFile(this);
+ if (!file.exists()) {
+ return CacheState.consistent;
+ }
+ FileState digest = PersistenceManager.getInstance().getFileDigest(this);
+ return digest.getCacheState();
+ }
+
+ @Override
+ public FSTreeNode getParent() {
+ return fParent;
+ }
+
+ @Override
+ public String getName() {
+ return fName;
+ }
+
+ @Override
+ public IFSTreeNodeWorkingCopy createWorkingCopy() {
+ return new FSTreeNodeWorkingCopy(this);
+ }
+
+ @Override
+ public boolean isFileSystem() {
+ return fType == Type.FILE_SYSTEM;
+ }
+
+ @Override
+ public long getAccessTime() {
+ if (fAttributes != null)
+ return fAttributes.atime;
+ return 0;
+ }
+
+ @Override
+ public long getModificationTime() {
+ if (fAttributes != null)
+ return fAttributes.mtime;
+ return 0;
+ }
+
+ @Override
+ public long getSize() {
+ if (fAttributes != null)
+ return fAttributes.size;
+ return 0;
+ }
+
+ @Override
+ public int getUID() {
+ if (fAttributes != null)
+ return fAttributes.uid;
+ return 0;
+ }
+
+ @Override
+ public int getGID() {
+ if (fAttributes != null)
+ return fAttributes.gid;
+ return 0;
+ }
+
+ @Override
+ public boolean isAncestorOf(IFSTreeNode node) {
+ while (node != null) {
+ if ((node = node.getParent()) == this)
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public File getCacheFile() {
+ return CacheManager.getCacheFile(this);
+ }
+
+ @Override
+ public String getPreferredEditorID() {
+ return PersistenceManager.getInstance().getPersistentProperties(this).get(EDITOR_KEY);
+ }
+
+ @Override
+ public void setPreferredEditorID(String editorID) {
+ PersistenceManager.getInstance().getPersistentProperties(this).put(EDITOR_KEY, editorID);
+ }
+
+ @Override
+ public IContentType getContentType() {
+ return ContentTypeHelper.getContentType(this);
+ }
+
+ @Override
+ public boolean isBinaryFile() {
+ return ContentTypeHelper.isBinaryFile(this);
+ }
+
+ @Override
+ public FSTreeNode[] getChildren() {
+ return fChildren;
+ }
+
+ @Override
+ public IOperation operationRefresh(boolean recursive) {
+ return new OpRefresh(this, recursive);
+ }
+
+
+ @Override
+ public IOperation operationRename(String newName) {
+ return new OpRename(this, newName);
+ }
+
+ @Override
+ public IOperation operationUploadContent(File srcFile) {
+ if (srcFile == null)
+ srcFile = getCacheFile();
+
+ OpUpload upload = new OpUpload(null);
+ upload.addUpload(srcFile, this);
+ return upload;
+ }
+
+ @Override
+ public IOperation operationDelete(IConfirmCallback readonlyCallback) {
+ return new OpDelete(singletonList(this), readonlyCallback);
+ }
+
+ @Override
+ public IOperation operationDownload(OutputStream output) {
+ return new OpDownload(this, output);
+ }
+
+ @Override
+ public IOperation operationDropFiles(List<String> files, IConfirmCallback confirmCallback) {
+ OpUpload upload = new OpUpload(confirmCallback);
+ for (String file : files) {
+ upload.addDrop(new File(file), this);
+ }
+ return upload;
+ }
+
+ @Override
+ public IOperation operationDropMove(List<IFSTreeNode> nodes, IConfirmCallback confirmCallback) {
+ return new OpMove(nodes, this, confirmCallback);
+ }
+
+ @Override
+ public IOperation operationDropCopy(List<IFSTreeNode> nodes, boolean cpPerm, boolean cpOwn,
+ IConfirmCallback moveCopyCallback) {
+ return new OpCopy(nodes, this, cpPerm, cpOwn, moveCopyCallback);
+ }
+
+ @Override
+ public IResultOperation<IFSTreeNode> operationNewFile(String name) {
+ return new OpCreateFile(this, name);
+ }
+
+ @Override
+ public IResultOperation<IFSTreeNode> operationNewFolder(String name) {
+ return new OpCreateFolder(this, name);
+ }
+
+ public void changeParent(FSTreeNode newParent) {
+ fParent = newParent;
+ }
+
+ public void changeName(String newName) {
+ fName = newName;
+ }
+
+ public FSTreeNode findChild(String name) {
+ return binarySearch(fChildren, name);
+ }
+
+ public void addNode(FSTreeNode newNode, boolean notify) {
+ final FSTreeNode[] children = fChildren;
+ if (children == null) {
+ setChildren(new FSTreeNode[] {newNode}, notify);
+ } else {
+ int ip = Arrays.binarySearch(children, newNode, getComparator());
+ if (ip >= 0) {
+ children[ip] = newNode;
+ } else {
+ ip = -ip - 1;
+ FSTreeNode[] newChildren = new FSTreeNode[children.length+1];
+ System.arraycopy(children, 0, newChildren, 0, ip);
+ newChildren[ip] = newNode;
+ System.arraycopy(children, ip, newChildren, ip+1, children.length-ip);
+ setChildren(newChildren, notify);
+ }
+ }
+ }
+
+ public void removeNode(FSTreeNode node, boolean notify) {
+ final FSTreeNode[] children = fChildren;
+ if (children == null)
+ return;
+
+ int ip = Arrays.binarySearch(children, node, getComparator());
+ if (ip < 0 || children[ip] != node)
+ return;
+
+ FSTreeNode[] newChildren = new FSTreeNode[children.length-1];
+ System.arraycopy(children, 0, newChildren, 0, ip);
+ System.arraycopy(children, ip+1, newChildren, ip, children.length-ip-1);
+ setChildren(newChildren, notify);
+ }
+
+ public void setContent(FSTreeNode[] children, boolean notify) {
+ final Comparator<FSTreeNode> comparator = getComparator();
+ Arrays.sort(children, comparator);
+ if (fChildren != null) {
+ int j = 0;
+ for (int i=0; i<children.length; i++) {
+ FSTreeNode node = children[i];
+ for (; j<fChildren.length; j++) {
+ FSTreeNode old = fChildren[j];
+ int cmp = comparator.compare(old, node);
+ if (cmp == 0) {
+ old.setAttributes(node.fAttributes, false);
+ children[i] = old;
+ j++;
+ break;
+ } else if (cmp > 0) {
+ break;
+ }
+ }
+ }
+ }
+ fRefreshTime = System.currentTimeMillis();
+ setChildren(children, notify);
+ }
+
+ private Comparator<FSTreeNode> getComparator() {
+ return isWindowsNode() ? CMP_WIN : CMP_UNIX;
+ }
+
+ private void setChildren(FSTreeNode[] children, boolean notify) {
+ Assert.isTrue(Protocol.isDispatchThread());
+ FSTreeNode[] oldChildren = fChildren;
+ fChildren = children;
+ if (notify) {
+ notifyChange("children", oldChildren, children); //$NON-NLS-1$
+ }
+ }
+
+ public void setAttributes(FileAttrs attrs, boolean notify) {
+ FileAttrs oldAttrs = fAttributes;
+ fAttributes = attrs;
+ if (attrs.isFile())
+ fRefreshTime = System.currentTimeMillis();
+ if (notify) {
+ notifyChange("attributes", oldAttrs, attrs); //$NON-NLS-1$
+ }
+ }
+
+ public void notifyChange() {
+ notifyChange("children", null, null); //$NON-NLS-1$
+ }
+
+ private void notifyChange(String prop, Object oldValue, Object newValue) {
+ fRuntimeModel.firePropertyChanged(new PropertyChangeEvent(this, prop, oldValue, newValue));
+ }
+
+ @Override
+ public long getLastRefresh() {
+ return fRefreshTime;
+ }
+
+ private FSTreeNode binarySearch(final FSTreeNode[] children, String name) {
+ if (children == null)
+ return null;
+
+ boolean caseSensitive = !isWindowsNode();
+ int low = 0;
+ int high = children.length - 1;
+
+ while (low <= high) {
+ int mid = (low + high) >>> 1;
+ FSTreeNode midVal = children[mid];
+ int cmp = caseSensitive ? midVal.getName().compareTo(name) : midVal.getName().compareToIgnoreCase(name);
+ if (cmp < 0)
+ low = mid + 1;
+ else if (cmp > 0)
+ high = mid - 1;
+ else
+ return midVal;
+ }
+ return null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNodeBase.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNodeBase.java
new file mode 100644
index 000000000..48ac5d1d5
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNodeBase.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.internal;
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IWindowsFileAttributes;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNodeBase;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IUserAccount;
+
+/**
+ * Representation of a file system tree node.
+ * <p>
+ * <b>Note:</b> Node construction and child list access is limited to the TCF
+ * event dispatch thread.
+ */
+public abstract class FSTreeNodeBase extends PlatformObject implements IFSTreeNodeBase {
+
+ protected abstract int getWin32Attrs();
+ protected abstract int getPermissions();
+
+ @Override
+ public final boolean getWin32Attr(int attribute) {
+ return (getWin32Attrs() & attribute) == attribute;
+ }
+
+ @Override
+ public final boolean isHidden() {
+ return getWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_HIDDEN);
+ }
+
+ @Override
+ public final boolean isReadOnly() {
+ return getWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_READONLY);
+ }
+
+ @Override
+ public final boolean getPermission(int bit) {
+ return (getPermissions() & bit) == bit;
+ }
+
+
+ @Override
+ public final boolean isReadable() {
+ return checkPermission(IFileSystem.S_IRUSR, IFileSystem.S_IRGRP, IFileSystem.S_IROTH);
+ }
+
+ @Override
+ public final boolean isWritable() {
+ return checkPermission(IFileSystem.S_IWUSR, IFileSystem.S_IWGRP, IFileSystem.S_IWOTH);
+ }
+
+ @Override
+ public final boolean isExecutable() {
+ return checkPermission(IFileSystem.S_IXUSR, IFileSystem.S_IXGRP, IFileSystem.S_IXOTH);
+ }
+
+ private boolean checkPermission(int user, int group, int other) {
+ IUserAccount account = getUserAccount();
+ int permissions = getPermissions();
+ if (account != null && permissions != 0) {
+ if (getUID() == account.getEUID()) {
+ return getPermission(user);
+ }
+ if (getGID() == account.getEGID()) {
+ return getPermission(group);
+ }
+ return getPermission(other);
+ }
+ return false;
+ }
+
+ @Override
+ public final boolean isAgentOwner() {
+ IUserAccount account = getUserAccount();
+ if (account != null) {
+ return getUID() == account.getEUID();
+ }
+ return false;
+ }
+
+ @Override
+ public final boolean isSystemFile() {
+ if (isFileSystem())
+ return false;
+
+ return isWindowsNode() && getWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_SYSTEM);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNodeWorkingCopy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNodeWorkingCopy.java
new file mode 100644
index 000000000..d2e05b7ab
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNodeWorkingCopy.java
@@ -0,0 +1,246 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.internal;
+
+import static java.text.MessageFormat.format;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.services.IFileSystem.FileAttrs;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IWindowsFileAttributes;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNodeWorkingCopy;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IUserAccount;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.AbstractOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCommitAttr;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+
+class FSTreeNodeWorkingCopy extends FSTreeNodeBase implements IFSTreeNodeWorkingCopy {
+
+ private final FSTreeNodeBase fOriginal;
+
+ private int fPermissions;
+ private int fWin32Attributes;
+
+
+ FSTreeNodeWorkingCopy(FSTreeNodeWorkingCopy original) {
+ fOriginal = original;
+ fPermissions = original.fPermissions;
+ fWin32Attributes = original.fWin32Attributes;
+ }
+
+ FSTreeNodeWorkingCopy(FSTreeNode original) {
+ fOriginal = original;
+ fPermissions = original.getPermissions();
+ fWin32Attributes = original.getWin32Attrs();
+ }
+
+ @Override
+ protected int getWin32Attrs() {
+ return fWin32Attributes;
+ }
+
+ @Override
+ protected int getPermissions() {
+ return fPermissions;
+ }
+
+ @Override
+ public IFSTreeNodeWorkingCopy createWorkingCopy() {
+ return new FSTreeNodeWorkingCopy(this);
+ }
+
+ @Override
+ public void setWritable(boolean b) {
+ IUserAccount account = getUserAccount();
+ if (account != null) {
+ int bit;
+ if (getUID() == account.getEUID()) {
+ bit = IFileSystem.S_IWUSR;
+ } else if (getGID() == account.getEGID()) {
+ bit = IFileSystem.S_IWGRP;
+ } else {
+ bit = IFileSystem.S_IWOTH;
+ }
+ setPermission(bit, true);
+ }
+ }
+
+ @Override
+ public void setPermission(int bit, boolean value) {
+ if (value) {
+ fPermissions |= bit;
+ } else {
+ fPermissions &= ~bit;
+ }
+ }
+
+ @Override
+ public void setWin32Attr(int bit, boolean value) {
+ if (value) {
+ fWin32Attributes |= bit;
+ } else {
+ fWin32Attributes &= ~bit;
+ }
+ }
+
+ @Override
+ public void setHidden(boolean hidden) {
+ setWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_HIDDEN, hidden);
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly) {
+ setWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_READONLY, readOnly);
+ }
+
+ @Override
+ public boolean isDirty() {
+ if (fOriginal.getPermissions() != getPermissions())
+ return true;
+ if (fOriginal.getWin32Attrs() != getWin32Attrs())
+ return true;
+ return false;
+ }
+
+ @Override
+ public IOperation operationCommit() {
+ return new AbstractOperation() {
+ @Override
+ public String getName() {
+ return format(Messages.FSTreeNodeWorkingCopy_commitOperation_name, FSTreeNodeWorkingCopy.this.getName());
+ }
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) {
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+ return doCommit(monitor);
+ }
+ };
+ }
+
+ protected IStatus doCommit(IProgressMonitor monitor) {
+ try {
+ if (fOriginal instanceof FSTreeNodeWorkingCopy) {
+ return commit((FSTreeNodeWorkingCopy) fOriginal);
+ }
+ if (fOriginal instanceof FSTreeNode) {
+ return commit((FSTreeNode) fOriginal, monitor);
+ }
+ return Status.CANCEL_STATUS;
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private IStatus commit(FSTreeNodeWorkingCopy original) {
+ original.fPermissions = fPermissions;
+ original.fWin32Attributes = fWin32Attributes;
+ return Status.OK_STATUS;
+ }
+
+
+ private IStatus commit(FSTreeNode original, IProgressMonitor monitor) {
+ if (!isDirty())
+ return Status.OK_STATUS;
+
+ FileAttrs attrs = original.getAttributes();
+ if (attrs != null) {
+ Map<String, Object> attributes = new HashMap<String, Object>(attrs.attributes);
+ if (fWin32Attributes != original.getWin32Attrs()) {
+ attrs.attributes.put(FSTreeNode.KEY_WIN32_ATTRS, Integer.valueOf(fWin32Attributes));
+ }
+
+ attrs = new FileAttrs(attrs.flags, attrs.size, attrs.uid, attrs.gid, fPermissions, attrs.atime, attrs.mtime, attributes);
+ return new OpCommitAttr(original, attrs).run(monitor);
+ }
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ public String getName() {
+ return fOriginal.getName();
+ }
+
+ @Override
+ public Type getType() {
+ return fOriginal.getType();
+ }
+
+ @Override
+ public String getFileTypeLabel() {
+ return fOriginal.getFileTypeLabel();
+ }
+
+ @Override
+ public IUserAccount getUserAccount() {
+ return fOriginal.getUserAccount();
+ }
+
+ @Override
+ public String getLocation() {
+ return fOriginal.getLocation();
+ }
+
+ @Override
+ public boolean isFileSystem() {
+ return fOriginal.isFileSystem();
+ }
+
+ @Override
+ public boolean isRootDirectory() {
+ return fOriginal.isRootDirectory();
+ }
+
+ @Override
+ public boolean isDirectory() {
+ return fOriginal.isDirectory();
+ }
+
+ @Override
+ public boolean isFile() {
+ return fOriginal.isFile();
+ }
+
+ @Override
+ public long getAccessTime() {
+ return fOriginal.getAccessTime();
+ }
+
+ @Override
+ public long getModificationTime() {
+ return fOriginal.getModificationTime();
+ }
+
+ @Override
+ public long getSize() {
+ return fOriginal.getSize();
+ }
+
+ @Override
+ public boolean isWindowsNode() {
+ return fOriginal.isWindowsNode();
+ }
+
+ @Override
+ public int getUID() {
+ return fOriginal.getUID();
+ }
+
+ @Override
+ public int getGID() {
+ return fOriginal.getGID();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java
index b46ed125a..9c391d354 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/UserAccount.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -11,10 +11,12 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IUserAccount;
+
/**
* The data model of a user account.
*/
-public class UserAccount {
+public class UserAccount implements IUserAccount {
// The user's id.
private int uid;
// The user's group id.
@@ -71,6 +73,7 @@ public class UserAccount {
*
* @return The user's effective id.
*/
+ @Override
public int getEUID() {
return euid;
}
@@ -80,6 +83,7 @@ public class UserAccount {
*
* @return The user's effective group id.
*/
+ @Override
public int getEGID() {
return egid;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/CallbackBase.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/CallbackBase.java
deleted file mode 100644
index e85a38595..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/CallbackBase.java
+++ /dev/null
@@ -1,35 +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.filesystem.core.internal.callbacks;
-
-import org.eclipse.tcf.protocol.IErrorReport;
-/**
- * The base class for all callback classes.
- */
-public class CallbackBase {
-
- /**
- * Get the error message from the throwable error.
- *
- * @param error The throwable error.
- * @return The error message.
- */
- protected String getErrorMessage(Throwable error) {
- String message = null;
- if(error instanceof IErrorReport) {
- IErrorReport report = (IErrorReport) error;
- message = (String)report.getAttributes().get(IErrorReport.ERROR_FORMAT);
- }
- else {
- message = error.getMessage();
- }
- return message;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpen.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpen.java
deleted file mode 100644
index 42ddeb53b..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpen.java
+++ /dev/null
@@ -1,82 +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.core.internal.callbacks;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.services.IFileSystem.DoneClose;
-import org.eclipse.tcf.services.IFileSystem.DoneOpen;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.services.IFileSystem.IFileHandle;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The callback handler that handles the event that a directory is opened.
- */
-public class QueryDoneOpen extends CallbackBase implements DoneOpen {
- // The tcf channel used.
- IChannel channel;
- // The file system service.
- IFileSystem service;
- // The parent node being queried.
- FSTreeNode parentNode;
- // The callback
- ICallback callback;
-
- /**
- * Create an instance with parameters to initialize the fields.
- *
- * @param callback the callback
- * @param channel The tcf channel.
- * @param service The file system service.
- * @param node The parent node.
- */
- public QueryDoneOpen(ICallback callback, IChannel channel, IFileSystem service, FSTreeNode node) {
- this.callback = callback;
- this.channel = channel;
- this.service = service;
- this.parentNode = node;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem.DoneOpen#doneOpen(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.IFileHandle)
- */
- @Override
- public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
- if (error == null) {
- // Read the directory content until finished
- service.readdir(handle, new QueryDoneReadDir(callback, channel, service, handle, parentNode));
- }
- else if (callback != null) {
- // Close the handle and channel if EOF is signaled or an error occurred.
- if (handle != null) {
- service.close(handle, new DoneClose() {
- @Override
- public void doneClose(IToken token, FileSystemException error) {
- IStatus status;
- if (error == null) status = Status.OK_STATUS;
- else status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- });
- }
- else {
- IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpenChannel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpenChannel.java
deleted file mode 100644
index 62298c98e..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneOpenChannel.java
+++ /dev/null
@@ -1,93 +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.core.internal.callbacks;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-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.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * The callback handler that handles the event when the channel opens.
- */
-public class QueryDoneOpenChannel extends CallbackBase implements DoneOpenChannel {
- // The parent node to be queried.
- FSTreeNode parentNode;
- // Callback object.
- ICallback callback;
-
- /**
- * Create an instance with a parent node.
- *
- * @param parentNode The parent node.
- */
- public QueryDoneOpenChannel(FSTreeNode parentNode) {
- this(parentNode, null);
- }
-
- /**
- * Create an instance with a parent node.
- *
- * @param parentNode The parent node.
- * @param callback Callback object.
- */
- public QueryDoneOpenChannel(FSTreeNode parentNode, ICallback callback) {
- this.parentNode = parentNode;
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel#doneOpenChannel(java.lang.Throwable, org.eclipse.tcf.protocol.IChannel)
- */
- @Override
- public void doneOpenChannel(Throwable error, final IChannel channel) {
- Assert.isTrue(Protocol.isDispatchThread());
- if(error == null) {
- ICallback proxy = new Callback(){
- @Override
- protected void internalDone(Object caller, IStatus status) {
- // Reset the children query markers
- parentNode.queryDone();
- Tcf.getChannelManager().closeChannel(channel);
- if(callback != null) {
- callback.done(caller, status);
- }
- }
- };
- IFileSystem service = channel.getRemoteService(IFileSystem.class);
- if(service != null) {
- if(parentNode.isSystemRoot()) {
- service.roots(new QueryDoneRoots(proxy, parentNode));
- } else {
- String absPath = parentNode.getLocation();
- service.opendir(absPath, new QueryDoneOpen(proxy, channel, service, parentNode));
- }
- } else {
- Status status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), Messages.Operation_NoFileSystemError, null);
- proxy.done(this, status);
- }
- }
- else if(!(error instanceof OperationCanceledException) && callback != null) {
- IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneReadDir.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneReadDir.java
deleted file mode 100644
index 35b8ad64e..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneReadDir.java
+++ /dev/null
@@ -1,96 +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.core.internal.callbacks;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.services.IFileSystem.DirEntry;
-import org.eclipse.tcf.services.IFileSystem.DoneClose;
-import org.eclipse.tcf.services.IFileSystem.DoneReadDir;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The callback handler that handles the event when a directory is read.
- */
-public class QueryDoneReadDir extends CallbackBase implements DoneReadDir {
- // The tcf channel.
- IChannel channel;
- // The file system service.
- IFileSystem service;
- // The file handle of the parent directory.
- IFileSystem.IFileHandle handle;
- // The parent node being queried.
- FSTreeNode parentNode;
- // The callback object.
- ICallback callback;
- /**
- * Create an instance with parameters to initialize the fields.
- *
- * @param channel The tcf channel.
- * @param service The file system service.
- * @param handle The directory's file handle.
- * @param parentNode The parent directory.
- */
- public QueryDoneReadDir(ICallback callback, IChannel channel, IFileSystem service, IFileSystem.IFileHandle handle, FSTreeNode parentNode) {
- this.callback = callback;
- this.channel = channel;
- this.service = service;
- this.handle = handle;
- this.parentNode = parentNode;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem.DoneReadDir#doneReadDir(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.DirEntry[], boolean)
- */
- @Override
- public void doneReadDir(IToken token, FileSystemException error, DirEntry[] entries, boolean eof) {
- // Process the returned data
- if (error == null) {
- if (entries != null && entries.length > 0) {
- for (DirEntry entry : entries) {
- FSTreeNode node = new FSTreeNode(parentNode, entry, false);
- parentNode.addChild(node);
- }
- }
-
- if (eof) {
- // Close the handle and channel if EOF is signaled or an error occurred.
- service.close(handle, new DoneClose() {
- @Override
- public void doneClose(IToken token, FileSystemException error) {
- if(callback != null) {
- IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), error.getMessage(), error);
- callback.done(this, status);
- }
- }});
- }
- else {
- // And invoke ourself again
- service.readdir(handle, new QueryDoneReadDir(callback, channel, service, handle, parentNode));
- }
- } else if(callback != null) {
- // Close the handle and channel if EOF is signaled or an error occurred.
- service.close(handle, new DoneClose() {
- @Override
- public void doneClose(IToken token, FileSystemException error) {
- IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- });
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneRoots.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneRoots.java
deleted file mode 100644
index 70f1967cf..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/QueryDoneRoots.java
+++ /dev/null
@@ -1,64 +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.core.internal.callbacks;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem.DirEntry;
-import org.eclipse.tcf.services.IFileSystem.DoneRoots;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The callback handler that handles the event when the roots are listed.
- */
-public class QueryDoneRoots extends CallbackBase implements DoneRoots {
- // The parent directory node.
- FSTreeNode parentNode;
- // The callback object
- ICallback callback;
-
- /**
- * Create an instance with parameters to initialize the fields.
- *
- * @param callback the callback.
- * @param parentNode The parent directory node.
- */
- public QueryDoneRoots(ICallback callback, FSTreeNode parentNode) {
- this.callback = callback;
- this.parentNode = parentNode;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem.DoneRoots#doneRoots(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.DirEntry[])
- */
- @Override
- public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) {
- if (error == null) {
- if (entries.length > 0) {
- for (DirEntry entry : entries) {
- FSTreeNode node = new FSTreeNode(parentNode, entry, true);
- parentNode.addChild(node);
- }
- }
- else {
- parentNode.clearChildren();
- }
- }
- if(callback != null) {
- IStatus status = error == null ? Status.OK_STATUS : new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), getErrorMessage(error), error);
- callback.done(this, status);
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneOpenChannel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneOpenChannel.java
deleted file mode 100644
index d194fb97e..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneOpenChannel.java
+++ /dev/null
@@ -1,88 +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.filesystem.core.internal.callbacks;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFFileSystemException;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * The callback to process the channel opened event for refreshing the state of a
- * file system node.
- */
-public class RefreshStateDoneOpenChannel extends CallbackBase implements IChannelManager.DoneOpenChannel{
- // The node to be refreshed.
- FSTreeNode node;
- // The callback after the refreshing is done.
- ICallback callback;
-
- /**
- * Create an instance.
- */
- public RefreshStateDoneOpenChannel(FSTreeNode node, ICallback callback) {
- this.node = node;
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel#doneOpenChannel(java.lang.Throwable, org.eclipse.tcf.protocol.IChannel)
- */
- @Override
- public void doneOpenChannel(Throwable error, IChannel channel) {
- IPeer peer = node.peerNode.getPeer();
- if (error != null) {
- if(channel != null) {
- Tcf.getChannelManager().closeChannel(channel);
- }
- if (!(error instanceof OperationCanceledException)) {
- String message = getErrorMessage(error);
- IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), message, error);
- invokeCallback(status);
- }
- }
- else {
- IFileSystem service = channel.getRemoteService(IFileSystem.class);
- if (service != null) {
- String path = node.getLocation(true);
- service.stat(path, new RefreshStateDoneStat(node, channel, callback));
- }
- else {
- Tcf.getChannelManager().closeChannel(channel);
- String message = NLS.bind(Messages.Operation_NoFileSystemError, peer.getID());
- IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), message, new TCFFileSystemException(IStatus.ERROR, message));
- invokeCallback(status);
- }
- }
- }
-
- /**
- * Invoke the callback using the specified status, if the callback
- * is not null.
- *
- * @param status The processing result.
- */
- private void invokeCallback(IStatus status) {
- if(callback != null) {
- callback.done(this, status);
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneStat.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneStat.java
deleted file mode 100644
index aab2d304e..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/callbacks/RefreshStateDoneStat.java
+++ /dev/null
@@ -1,111 +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.filesystem.core.internal.callbacks;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IToken;
-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.runtime.interfaces.callback.ICallback;
-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.operations.JobExecutor;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpTargetFileDigest;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The callback to process the stat done event when
- * refreshing the state of a file system node.
- */
-public class RefreshStateDoneStat extends CallbackBase implements DoneStat {
- // The channel used to refresh the node's state.
- IChannel channel;
- // The node whose state is being refreshed.
- FSTreeNode node;
- // The callback to be invoked after refreshing.
- ICallback callback;
-
- /**
- * Create an instance
- */
- public RefreshStateDoneStat(FSTreeNode node, IChannel channel, ICallback callback) {
- this.node = node;
- this.channel = channel;
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.services.IFileSystem.DoneStat#doneStat(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.FileAttrs)
- */
- @Override
- public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
- Tcf.getChannelManager().closeChannel(channel);
- if (error == null) {
- FileAttrs oldAttrs = node.attr;
- node.setAttributes(attrs);
- // Only update a file's cache diagest.
- if (node.isFile()) {
- // Only update its target digest when it has a local cache file.
- File file = CacheManager.getCacheFile(node);
- if (file.exists()) {
- FileState fileDigest = PersistenceManager.getInstance().getFileDigest(node);
- if (fileDigest.getTargetDigest() == null || (oldAttrs == null && attrs != null || oldAttrs != null && attrs == null || oldAttrs != null && attrs != null && oldAttrs.mtime != attrs.mtime)) {
- // Its modification time has changed. Update the digest.
- updateTargetDigest();
- }
- else {
- invokeCallback(Status.OK_STATUS);
- }
- }
- else {
- invokeCallback(Status.OK_STATUS);
- }
- }
- else {
- invokeCallback(Status.OK_STATUS);
- }
- }
- else {
- String message = getErrorMessage(error);
- IStatus status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), message, error);
- invokeCallback(status);
- }
- }
-
- /**
- * Invoke the callback handler if it is not null using
- * the specified status.
- *
- * @param status The refreshing result.
- */
- protected void invokeCallback(IStatus status) {
- if(callback != null) {
- callback.done(this, status);
- }
- }
-
- /**
- * Update the node's target digest and invoke the callback
- * when the job is done.
- */
- private void updateTargetDigest() {
- JobExecutor executor = new JobExecutor(callback);
- executor.execute(new OpTargetFileDigest(node));
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java
index e42569a5a..c6f934c5c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/exceptions/TCFException.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -15,14 +15,14 @@ package org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions;
*/
public class TCFException extends Exception {
private static final long serialVersionUID = -220092425137980661L;
-
+
// The severity code of this exception, could be used in job status handling.
private int severity;
-
+
/**
* Constructor.
*
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
+ * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
* <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
* @param message
* The exception detail message or <code>null</code>.
@@ -35,7 +35,7 @@ public class TCFException extends Exception {
/**
* Constructor.
*
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
+ * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
* <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
* @param message
* The exception detail message or <code>null</code>.
@@ -46,7 +46,7 @@ public class TCFException extends Exception {
super(message, cause);
this.severity = severity;
}
-
+
/**
* Returns the severity. The severities are as follows (in
* descending order):
@@ -63,9 +63,8 @@ public class TCFException extends Exception {
* no children.
* </p>
*
- * @return the severity: one of <code>OK</code>, <code>ERROR</code>,
+ * @return the severity: one of <code>OK</code>, <code>ERROR</code>,
* <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @see #matches(int)
*/
public int getSeverity() {
return severity;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/AbstractOperation.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/AbstractOperation.java
new file mode 100644
index 000000000..8493a47e3
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/AbstractOperation.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
+
+import static java.util.Arrays.asList;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.services.IFileSystem.DirEntry;
+import org.eclipse.tcf.services.IFileSystem.DoneClose;
+import org.eclipse.tcf.services.IFileSystem.DoneOpen;
+import org.eclipse.tcf.services.IFileSystem.DoneReadDir;
+import org.eclipse.tcf.services.IFileSystem.FileSystemException;
+import org.eclipse.tcf.services.IFileSystem.IFileHandle;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+
+public abstract class AbstractOperation implements IOperation {
+ public interface IReadDirDone {
+
+ void error(FileSystemException error);
+
+ boolean checkCancelled();
+
+ void done(List<DirEntry> entries);
+
+ }
+
+
+ private static final DecimalFormat SIZE_FORMAT = new DecimalFormat("#,##0.##"); //$NON-NLS-1$
+ protected static final int DEFAULT_CHUNK_SIZE = 5 * 1024;
+
+ private int fStandardAnswer = -1;
+
+ protected abstract IStatus doRun(IProgressMonitor monitor);
+
+ @Override
+ public final IStatus run(IProgressMonitor monitor) {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+ try {
+ return doRun(monitor);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ @Override
+ public final void runInJob(ICallback callback) {
+ runInJob(false, callback);
+ }
+
+ @Override
+ public final void runInUserJob(ICallback callback) {
+ runInJob(true, callback);
+ }
+
+ private final void runInJob(boolean user, final ICallback callback) {
+ Job job = new Job(getName()){
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ return AbstractOperation.this.run(monitor);
+ }
+ };
+ if (callback != null) {
+ job.addJobChangeListener(new JobChangeAdapter(){
+ @Override
+ public void done(final IJobChangeEvent event) {
+ callback.done(AbstractOperation.this, event.getResult());
+ }
+ });
+ }
+ job.setUser(user);
+ job.schedule();
+ }
+
+ protected String getPath(FSTreeNode node, String childName) {
+ String path = node.getLocation(true);
+ if (path.charAt(path.length()-1) == '/')
+ return path + childName;
+ return path + '/' + childName;
+ }
+
+ protected List<FSTreeNode> dropNestedNodes(List<? extends IFSTreeNode> nodes) {
+ List<FSTreeNode> result = new ArrayList<FSTreeNode>();
+ for (IFSTreeNode n : nodes) {
+ addWithoutNested(result, n);
+ }
+ return result;
+ }
+
+ private void addWithoutNested(List<FSTreeNode> result, IFSTreeNode newNode) {
+ if (!(newNode instanceof FSTreeNode))
+ return;
+ for (ListIterator<FSTreeNode> it = result.listIterator(); it.hasNext(); ) {
+ FSTreeNode node = it.next();
+ if (node == newNode || node.isAncestorOf(newNode))
+ return;
+ if (newNode.isAncestorOf(node)) {
+ it.set((FSTreeNode) newNode);
+ return;
+ }
+ }
+ result.add((FSTreeNode) newNode);
+ }
+
+ protected IStatus refresh(FSTreeNode node, long olderThan, IProgressMonitor monitor) {
+ if (node.getLastRefresh() < olderThan)
+ return node.operationRefresh(false).run(new SubProgressMonitor(monitor, 0));
+ return Status.OK_STATUS;
+ }
+
+
+ protected int confirmCallback(final FSTreeNode node, IConfirmCallback confirmCallback) {
+ if (confirmCallback == null)
+ return IConfirmCallback.YES;
+
+ if (fStandardAnswer >= 0)
+ return fStandardAnswer;
+
+ int answer = confirmCallback.confirms(node);
+ switch (answer) {
+ case IConfirmCallback.CANCEL:
+ case IConfirmCallback.NO:
+ case IConfirmCallback.YES:
+ return answer;
+ case IConfirmCallback.NO_TO_ALL:
+ fStandardAnswer = IConfirmCallback.NO;
+ return fStandardAnswer;
+ case IConfirmCallback.YES_TO_ALL:
+ fStandardAnswer = IConfirmCallback.YES;
+ return fStandardAnswer;
+ default:
+ return IConfirmCallback.CANCEL;
+ }
+ }
+
+ /**
+ * Use the SIZE_FORMAT to format the file's size. The rule is: 1. If the
+ * size is less than 1024 bytes, then show it as "####" bytes. 2. If the
+ * size is less than 1024 KBs, while more than 1 KB, then show it as
+ * "####.##" KBs. 3. If the size is more than 1 MB, then show it as
+ * "####.##" MBs.
+ *
+ * @param size
+ * The file size to be displayed.
+ * @return The string representation of the size.
+ */
+ protected String formatSize(long size) {
+ double kbSize = size / 1024.0;
+ if (kbSize < 1.0) {
+ return SIZE_FORMAT.format(size) + Messages.OpStreamOp_Bytes;
+ }
+ double mbSize = kbSize / 1024.0;
+ if (mbSize < 1.0)
+ return SIZE_FORMAT.format(kbSize) + Messages.OpStreamOp_KBs;
+ return SIZE_FORMAT.format(mbSize) + Messages.OpStreamOp_MBs;
+ }
+
+
+ protected void tcfReadDir(final IFileSystem fs, String path, final IReadDirDone callback) {
+ fs.opendir(path, new DoneOpen() {
+ private IFileHandle fHandle;
+ protected List<DirEntry> fEntries;
+
+ @Override
+ public void doneOpen(IToken token, FileSystemException error, final IFileHandle handle) {
+ if (error != null) {
+ callback.error(error);
+ } else {
+ fHandle = handle;
+ if (callback.checkCancelled()) {
+ cleanup();
+ } else {
+ fEntries = new ArrayList<DirEntry>();
+ readDir();
+ }
+ }
+ }
+
+ protected void readDir() {
+ fs.readdir(fHandle, new DoneReadDir() {
+ @Override
+ public void doneReadDir(IToken token, FileSystemException error, DirEntry[] entries, boolean eof) {
+ if (error != null) {
+ cleanup();
+ callback.error(error);
+ } else if (callback.checkCancelled()) {
+ cleanup();
+ } else {
+ fEntries.addAll(asList(entries));
+ if (eof) {
+ cleanup();
+ callback.done(fEntries);
+ } else {
+ readDir();
+ }
+ }
+ }
+ });
+ }
+
+ protected void cleanup() {
+ if (fHandle != null) {
+ fs.close(fHandle, new DoneClose() {
+ @Override
+ public void doneClose(IToken token, FileSystemException error) {
+ }
+ });
+ }
+ }
+ });
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/IOpExecutor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/IOpExecutor.java
deleted file mode 100644
index f88fdb173..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/IOpExecutor.java
+++ /dev/null
@@ -1,28 +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.core.internal.operations;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-
-/**
- * The interface is to defined an operation executor, which executes
- * the given operation providing the context including the progress monitor.
- */
-public interface IOpExecutor {
- /**
- * Execute the specified operation providing an execution
- * context.
- *
- * @param operation The operation to be executed.
- * @return a result status of the execution.
- */
- public IStatus execute(IOperation operation);
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/JobExecutor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/JobExecutor.java
deleted file mode 100644
index a46e64e62..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/JobExecutor.java
+++ /dev/null
@@ -1,100 +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.core.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException;
-
-/**
- * The operation that is executed as a back ground job.
- */
-public class JobExecutor implements IOpExecutor{
- // The callback
- protected ICallback callback;
-
- /**
- * Create an instance with no callback.
- */
- public JobExecutor() {
- this(null);
- }
-
- /**
- * Create an instance with the specified callback.
- *
- * @param callback called when the creation is done.
- */
- public JobExecutor(ICallback callback) {
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.IOpExecutor#execute(org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation)
- */
- @Override
- public IStatus execute(final IOperation operation) {
- Job job = new Job(operation.getName()){
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- monitor.setTaskName(operation.getName());
- monitor.beginTask(operation.getName(), operation.getTotalWork());
- operation.run(monitor);
- return Status.OK_STATUS;
- }
- catch (InvocationTargetException e) {
- Throwable throwable = e.getTargetException();
- if(throwable instanceof TCFException) {
- int severity = ((TCFException)throwable).getSeverity();
- return new Status(severity, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable);
- }
- return new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable);
- }
- catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- }
- finally {
- monitor.done();
- }
- }};
- job.addJobChangeListener(new JobChangeAdapter(){
- @Override
- public void done(final IJobChangeEvent event) {
- doCallback(operation, event);
- }
- });
- job.schedule();
- return Status.OK_STATUS;
- }
-
- /**
- * Called when the creation is done.
- *
- * @param operation The operation object.
- * @param event The job change event.
- */
- void doCallback(IOperation operation, IJobChangeEvent event) {
- IStatus status = event.getResult();
- if(callback != null) {
- callback.done(operation, status);
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/NullOpExecutor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/NullOpExecutor.java
deleted file mode 100644
index 369b9063b..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/NullOpExecutor.java
+++ /dev/null
@@ -1,79 +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.filesystem.core.internal.operations;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException;
-
-/**
- * An operation executor that executes an operation directly and silently.
- */
-public class NullOpExecutor implements IOpExecutor {
- // The callback being invoked after execution.
- ICallback callback;
-
- /**
- * Empty argument constructor
- */
- public NullOpExecutor() {
- this(null);
- }
-
- /**
- * Create an instance with a callback.
- *
- * @param callback The callback to be invoked after execution.
- */
- public NullOpExecutor(ICallback callback) {
- this.callback = callback;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor#execute(org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation)
- */
- @Override
- public IStatus execute(IOperation operation) {
- IProgressMonitor monitor = new NullProgressMonitor();
- IStatus status;
- try {
- monitor.setTaskName(operation.getName());
- monitor.beginTask(operation.getName(), operation.getTotalWork());
- operation.run(monitor);
- status = Status.OK_STATUS;
- }
- catch (InvocationTargetException e) {
- Throwable throwable = e.getTargetException();
- if (throwable instanceof TCFException) {
- int severity = ((TCFException) throwable).getSeverity();
- status = new Status(severity, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable);
- }
- else {
- status = new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), throwable.getMessage(), throwable);
- }
- }
- catch (InterruptedException e) {
- status = Status.CANCEL_STATUS;
- }
- finally {
- monitor.done();
- }
- if(callback != null) callback.done(operation, status);
- return status;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java
index 7aaca2c18..fcc6fe91a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -12,41 +12,32 @@ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
/**
* The operation to calculate the message digest of a cache file.
*/
-public class OpCacheFileDigest implements IOperation {
+public class OpCacheFileDigest extends AbstractOperation {
// The digest of which is going to be computed.
- FSTreeNode node;
+ private FSTreeNode node;
// The computing result
- byte[] digest;
-
- /**
- * Create an operation to compute the digest of its local cache file.
- *
- * @param node The file system node.
- */
+ private byte[] digest;
+
public OpCacheFileDigest(FSTreeNode node) {
this.node = node;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
@Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ protected IStatus doRun(IProgressMonitor monitor) {
+ monitor.beginTask(getName(), 100);
File file = CacheManager.getCacheFile(node);
BufferedInputStream input = null;
try {
@@ -56,9 +47,9 @@ public class OpCacheFileDigest implements IOperation {
long bytesRead = 0;
MessageDigest digest = MessageDigest.getInstance(MD_ALG);
input = new BufferedInputStream(new DigestInputStream(new FileInputStream(file), digest));
- byte[] data = new byte[OpStreamOp.DEFAULT_CHUNK_SIZE];
+ byte[] data = new byte[DEFAULT_CHUNK_SIZE];
int length;
- while ((length = input.read(data)) >= 0){
+ while ((length = input.read(data)) >= 0 && !monitor.isCanceled()){
bytesRead += length;
if (chunk_size != 0) {
int percent = (int) bytesRead / chunk_size;
@@ -69,23 +60,22 @@ public class OpCacheFileDigest implements IOperation {
}
}
this.digest = digest.digest();
- }
- catch (NoSuchAlgorithmException e) {
- throw new InvocationTargetException(e);
- }
- catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- finally {
+ return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), "Failed to update digest", e); //$NON-NLS-1$
+ } finally {
if (input != null) {
- try {input.close();} catch (Exception e) {}
+ try {
+ input.close();
+ } catch (Exception e) {
+ }
}
}
}
-
+
/**
* Get the computing result.
- *
+ *
* @return The message digest of this cache file.
*/
public byte[] getDigest() {
@@ -100,13 +90,4 @@ public class OpCacheFileDigest implements IOperation {
public String getName() {
return "Update cache digest"; //$NON-NLS-1$
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return 100;
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheUpdate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheUpdate.java
deleted file mode 100644
index d9f668c6a..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheUpdate.java
+++ /dev/null
@@ -1,76 +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.filesystem.core.internal.operations;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The operation class that updates the local cache to target file systems.
- */
-public class OpCacheUpdate extends OpDownload {
-
- /**
- * Create an instance of an OpCacheUpdate which
- * updates the specified nodes.
- *
- * @param nodes The nodes to be updated.
- */
- public OpCacheUpdate(FSTreeNode... nodes) {
- super(nodes);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDownload#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- for (FSTreeNode node : srcNodes) {
- // Write the data to its local cache file.
- File file = CacheManager.getCachePath(node).toFile();
- if (file.exists() && !file.canWrite()) {
- // If the file exists and is read-only, delete it.
- deleteFileChecked(file);
- }
- }
- try {
- super.run(monitor);
- } finally {
- if (!monitor.isCanceled()) {
- for (FSTreeNode node : srcNodes) {
- File file = CacheManager.getCachePath(node).toFile();
- if (file.exists()) {
- // If downloading is successful, update the attributes of the file and
- // set the last modified time to that of its corresponding file.
- if (!node.isWritable()) setReadOnlyChecked(file);
- }
- }
- }
- monitor.done();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDownload#updateNodeDigest(org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode, byte[])
- */
- @Override
- protected void updateNodeDigest(FSTreeNode node, byte[] digest) {
- FileState fdigest = PersistenceManager.getInstance().getFileDigest(node);
- fdigest.reset(digest);
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpClipboard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpClipboard.java
deleted file mode 100644
index 4b92a59b8..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpClipboard.java
+++ /dev/null
@@ -1,113 +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.core.internal.operations;
-
-import java.beans.PropertyChangeEvent;
-import java.util.List;
-
-import org.eclipse.tcf.te.core.utils.PropertyChangeProvider;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-
-/**
- * The clip board to which copy or cut files/folders.
- */
-public class OpClipboard extends PropertyChangeProvider {
- // The constants to define the current operation type of the clip board.
- private static final int NONE = -1;
- private static final int CUT = 0;
- private static final int COPY = 1;
- // The operation type, CUT, COPY or NONE.
- private int operation;
- // The currently selected files/folders.
- private List<FSTreeNode> files;
-
- /**
- * Create a clip board instance.
- */
- public OpClipboard() {
- operation = NONE;
- }
-
- /**
- * If the current operation is a cut operation.
- *
- * @return true if it is.
- */
- public boolean isCutOp() {
- return operation == CUT;
- }
-
- /**
- * If the current operation is a copy operation.
- *
- * @return true if it is.
- */
- public boolean isCopyOp() {
- return operation == COPY;
- }
-
- /**
- * If the clip board is empty.
- *
- * @return true if the operation is NONE and no files are selected.
- */
- public boolean isEmpty() {
- return operation == NONE && (files == null || files.isEmpty());
- }
-
- /**
- * Get the currently selected files/folders to operated.
- *
- * @return The file/folder list using their location URLs.
- */
- public List<FSTreeNode> getFiles() {
- return files;
- }
-
- /**
- * Cut the specified files/folders to the clip board.
- *
- * @param files The file/folder nodes.
- */
- public void cutFiles(List<FSTreeNode> files) {
- operation = CUT;
- this.files = files;
- PropertyChangeEvent event = new PropertyChangeEvent(this, "cut", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Copy the specified files/folders to the clip board.
- *
- * @param files The file/folder nodes.
- */
- public void copyFiles(List<FSTreeNode> files) {
- operation = COPY;
- this.files = files;
- PropertyChangeEvent event = new PropertyChangeEvent(this, "copy", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Clear the clip board.
- */
- public void clear() {
- operation = NONE;
- this.files = null;
- PropertyChangeEvent event = new PropertyChangeEvent(this, "clear", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Dispose the clipboard.
- */
- public void dispose() {
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java
index 6e95f637f..0009ffc25 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCommitAttr.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -9,77 +9,62 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import java.lang.reflect.InvocationTargetException;
-
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.DoneSetStat;
import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-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.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+
/**
* The operation implementation to commit the new attributes to
* the file system node.
*/
-public class OpCommitAttr extends Operation {
- // The node whose attributes are being updated.
- FSTreeNode node;
- // The new attributes for the file system node.
- IFileSystem.FileAttrs attrs;
-
- /**
- * Create an instance
- */
+public class OpCommitAttr extends AbstractOperation {
+ protected FSTreeNode fNode;
+ protected IFileSystem.FileAttrs fAttributes;
+
public OpCommitAttr(FSTreeNode node, IFileSystem.FileAttrs attrs) {
- this.node = node;
- this.attrs = attrs;
+ fNode = node;
+ fAttributes = attrs;
}
- /*
- * (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 {
- IChannel channel = null;
- try {
- channel = openChannel(node.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = Operation.getBlockingFileSystem(channel);
- if (service != null) {
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- String path = node.getLocation(true);
- service.setstat(path, attrs, new DoneSetStat() {
+ public IStatus doRun(IProgressMonitor monitor) {
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+
+ final TCFResult<?> result = new TCFResult<Object>();
+ final IFileSystem fileSystem = fNode.getRuntimeModel().getFileSystem();
+ if (fileSystem == null) {
+ return result.setCancelled();
+ }
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ if (!result.checkCancelled()) {
+ String path = fNode.getLocation(true);
+ fileSystem.setstat(path, fAttributes, new DoneSetStat() {
@Override
public void doneSetStat(IToken token, FileSystemException error) {
- if (error == null) {
- node.setAttributes(attrs);
+ if (error != null) {
+ result.setError(Messages.OpCommitAttr_error_cannotSetAttributes, error);
} else {
- errors[0] = newTCFException(IStatus.WARNING, error);
+ fNode.setAttributes(fAttributes, true);
+ result.setDone(null);
}
}
});
- if (errors[0] != null) {
- throw errors[0];
- }
- } else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, node.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
}
}
- }
- catch(TCFException e) {
- throw new InvocationTargetException(e);
- }
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- }
+ });
+ return result.waitDone(monitor);
+ }
+
+ @Override
+ public String getName() {
+ return Messages.OpCommitAttr_name + fNode.getName();
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java
index eec8ce292..76c486811 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCopy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,52 +9,51 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import java.lang.reflect.InvocationTargetException;
+import static java.text.MessageFormat.format;
+
+import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.Status;
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.DoneCopy;
+import org.eclipse.tcf.services.IFileSystem.DoneMkDir;
+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.interfaces.IConfirmCallback;
-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.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
* The operation class that copies selected FSTreeNodes to a specify destination folder.
*/
-public class OpCopy extends Operation {
- // The nodes to be copied.
- List<FSTreeNode> nodes;
- // The destination folder to be copied to.
- FSTreeNode dest;
- // The callback invoked to confirm overwriting when there're files with same names.
- IConfirmCallback confirmCallback;
- // If it is required to copy the permissions.
- boolean cpPermission;
- // If it is required to copy the ownership.
- boolean cpOwnership;
-
- /**
- * Create a copy operation using the specified nodes and destination folder.
- *
- * @param nodes The file/folder nodes to be copied.
- * @param dest The destination folder to be copied to.
- */
- public OpCopy(List<FSTreeNode> nodes, FSTreeNode dest) {
- this(nodes, dest, false, false, null);
+public class OpCopy extends AbstractOperation {
+ private static class WorkItem {
+ final boolean fTop;
+ final FSTreeNode fDestination;
+ final FSTreeNode[] fSources;
+ WorkItem(FSTreeNode[] sources, FSTreeNode destination, boolean top) {
+ fSources = sources;
+ fDestination = destination;
+ fTop = top;
+ }
}
+ IConfirmCallback fConfirmCallback;
+ boolean fCopyPermissions;
+ boolean fCopyOwnership;
+
+ LinkedList<WorkItem> fWork = new LinkedList<WorkItem>();
+ private long fStartTime;
+
/**
* Create a copy operation using the specified nodes and destination folder,
* using the specified flags of copying permissions and ownership and a callback
@@ -63,196 +62,208 @@ public class OpCopy extends Operation {
* @param nodes The file/folder nodes to be copied.
* @param dest The destination folder to be copied to.
*/
- public OpCopy(List<FSTreeNode> nodes, FSTreeNode dest, boolean cpPerm, boolean cpOwn, IConfirmCallback confirmCallback) {
+ public OpCopy(List<? extends IFSTreeNode> nodes, FSTreeNode dest, boolean cpPerm, boolean cpOwn, IConfirmCallback confirmCallback) {
super();
- this.nodes = getAncestors(nodes);
- this.dest = dest;
- this.cpOwnership = cpOwn;
- this.cpPermission = cpPerm;
- this.confirmCallback = confirmCallback;
+ fCopyOwnership = cpOwn;
+ fCopyPermissions = cpPerm;
+ fConfirmCallback = confirmCallback;
+ nodes = dropNestedNodes(nodes);
+ fWork.add(new WorkItem(nodes.toArray(new FSTreeNode[nodes.size()]), dest, true));
}
- /*
- * (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 {
- super.run(monitor);
- FSTreeNode head = nodes.get(0);
- IChannel channel = null;
- try {
- channel = openChannel(head.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- for (FSTreeNode node : nodes) {
- // Iterate the nodes and copy each of them to the destination folder.
- copyNode(service, node, dest);
- }
- }
- else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, head.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
+ public IStatus doRun(IProgressMonitor monitor) {
+ fStartTime = System.currentTimeMillis();
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+ WorkItem lastTop = null;
+ while (!fWork.isEmpty()) {
+ WorkItem item = fWork.remove();
+ if (item.fTop) {
+ if (lastTop != null)
+ lastTop.fDestination.notifyChange();
+ lastTop = item;
+ }
+ IStatus s = runWorkItem(item, monitor);
+ if (!s.isOK()) {
+ lastTop.fDestination.notifyChange();
+ return s;
}
}
- catch (TCFException e) {
- throw new InvocationTargetException(e, e.getMessage());
+ if (lastTop != null)
+ lastTop.fDestination.notifyChange();
+ return Status.OK_STATUS;
+ }
+
+ protected IStatus runWorkItem(final WorkItem item, IProgressMonitor monitor) {
+ final FSTreeNode destination = item.fDestination;
+ IStatus status = refresh(destination, fStartTime, monitor);
+ if (!status.isOK()) {
+ return status;
}
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- monitor.done();
+
+ for (FSTreeNode source : item.fSources) {
+ status = refresh(source, fStartTime, monitor);
+ if (!status.isOK()) {
+ return status;
+ }
+
+ status = performCopy(source, destination, monitor);
+ if (!status.isOK())
+ return status;
}
+ return Status.OK_STATUS;
}
- /**
- * Copy the file/folder represented by the specified node to the destination folder.
- *
- * @param service The file system service to do the remote copying.
- * @param node The file/folder node to be copied.
- * @param dest The destination folder.
- * @throws TCFFileSystemException The exception thrown during copying
- * @throws InterruptedException The exception thrown when the operation is canceled.
- */
- void copyNode(IFileSystem service, FSTreeNode node, FSTreeNode dest) throws TCFFileSystemException, InterruptedException {
- if (node.isFile()) {
- copyFile(service, node, dest);
- }
- else if (node.isDirectory()) {
- copyFolder(service, node, dest);
+ private IStatus performCopy(FSTreeNode source, FSTreeNode destination, IProgressMonitor monitor) {
+ String newName = source.getName();
+ FSTreeNode existing = destination.findChild(newName);
+ if (existing != null) {
+ if (source == existing) {
+ newName = createNewNameForCopy(destination, newName);
+ existing = null;
+ } else if (source.isDirectory()) {
+ if (!existing.isDirectory()) {
+ return StatusHelper.createStatus(format(Messages.OpCopy_error_noDirectory, existing.getLocation()), null);
+ }
+ int replace = confirmCallback(existing, fConfirmCallback);
+ if (replace == IConfirmCallback.NO) {
+ return Status.OK_STATUS;
+ }
+ if (replace != IConfirmCallback.YES) {
+ return Status.CANCEL_STATUS;
+ }
+
+ fWork.addFirst(new WorkItem(source.getChildren(), existing, false));
+ return Status.OK_STATUS;
+ } else if (source.isFile()) {
+ if (!existing.isFile()) {
+ return StatusHelper.createStatus(format(Messages.OpCopy_error_noFile, existing.getLocation()), null);
+ }
+ int replace = confirmCallback(existing, fConfirmCallback);
+ if (replace == IConfirmCallback.NO) {
+ return Status.OK_STATUS;
+ }
+ if (replace != IConfirmCallback.YES) {
+ return Status.CANCEL_STATUS;
+ }
+ } else {
+ return Status.OK_STATUS;
+ }
}
+ return performCopy(source, destination, newName, existing, monitor);
}
- /**
- * Copy the folder represented by the specified node to the destination folder.
- *
- * @param service The file system service to do the remote copying.
- * @param node The folder node to be copied.
- * @param dest The destination folder.
- * @throws TCFFileSystemException The exception thrown during copying
- * @throws InterruptedException The exception thrown when the operation is canceled.
- */
- private void copyFolder(IFileSystem service, FSTreeNode node, FSTreeNode dest) throws TCFFileSystemException, InterruptedException {
- if (monitor.isCanceled()) throw new InterruptedException();
- FSTreeNode copy = findChild(service, dest, node.name);
- if (copy == null) {
- // If no existing directory with the same name, create it.
- copy = (FSTreeNode) node.clone();
- addChild(service, dest, copy);
- mkdir(service, copy);
- copyChildren(service, node, copy);
+
+ private String createNewNameForCopy(FSTreeNode node, String origName) {
+ String name = origName;
+ int n = 0;
+ while (node.findChild(name) != null) {
+ if (n > 0) {
+ name = NLS.bind(Messages.Operation_CopyNOfFile, Integer.valueOf(n), origName);
+ } else {
+ name = NLS.bind(Messages.Operation_CopyOfFile, origName);
+ }
+ n++;
}
- else if (node.equals(copy)) {
- copy = createCopyDestination(service, node, dest);
- mkdir(service, copy);
- copyChildren(service, node, copy);
+ return name;
+ }
+
+ private IStatus performCopy(final FSTreeNode source, final FSTreeNode destination, final String newName, final FSTreeNode existing, IProgressMonitor monitor) {
+ final TCFResult<?> result = new TCFResult<Object>();
+ monitor.subTask(NLS.bind(Messages.OpCopy_Copying, source.getLocation()));
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ tcfPerformCopy(source, destination, newName, existing, result);
+ }
+ });
+ return result.waitDone(monitor);
+ }
+
+
+ protected void tcfPerformCopy(FSTreeNode source, FSTreeNode destination, String newName, FSTreeNode existing, TCFResult<?> result) {
+ if (result.checkCancelled())
+ return;
+
+ if (source.isFile()) {
+ tcfCopyFile(source, destination, newName, existing, result);
+ } else if (source.isDirectory()) {
+ tcfCopyFolder(source, destination, newName, result);
+ } else {
+ result.setDone(null);
}
- else if (confirmReplace(node, confirmCallback)) {
- copyChildren(service, node, copy);
+ }
+
+ private void tcfCopyFolder(final FSTreeNode source, final FSTreeNode dest, final String newName, final TCFResult<?> result) {
+ final IFileSystem fileSystem = dest.getRuntimeModel().getFileSystem();
+ if (fileSystem == null) {
+ result.setCancelled();
+ return;
}
- monitor.worked(1);
+
+ final String path = getPath(dest, newName);
+ fileSystem.mkdir(path, source.getAttributes(), new DoneMkDir() {
+ @Override
+ public void doneMkDir(IToken token, FileSystemException error) {
+ if (error != null) {
+ result.setError(format(Messages.Operation_CannotCreateDirectory, newName), error);
+ } else if (!result.checkCancelled()) {
+ fileSystem.lstat(path, new DoneStat() {
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ result.setError(format(Messages.Operation_CannotCreateDirectory, newName), error);
+ } else if (!result.checkCancelled()) {
+ FSTreeNode copy = new FSTreeNode(dest, newName, false, attrs);
+ copy.setContent(new FSTreeNode[0], false);
+ dest.addNode(copy, false);
+ fWork.addFirst(new WorkItem(source.getChildren(), copy, false));
+ result.setDone(null);
+ }
+ }
+ });
+ }
+ }
+ });
}
- /**
- * Copy the children of the node to the destination folder.
- *
- * @param service The file system service to do the remote copying.
- * @param node The folder node to be copied.
- * @param dest The destination folder.
- * @throws TCFFileSystemException The exception thrown during copying
- * @throws InterruptedException The exception thrown when the operation is canceled.
- */
- private void copyChildren(IFileSystem service, FSTreeNode node, FSTreeNode dest) throws TCFFileSystemException, InterruptedException {
- List<FSTreeNode> children = getChildren(node, service);
- if (!children.isEmpty()) {
- for (FSTreeNode child : children) {
- // Iterate and copy its children nodes.
- copyNode(service, child, dest);
- }
- }
- }
+ private void tcfCopyFile(final FSTreeNode source, final FSTreeNode dest, final String newName, final FSTreeNode existing, final TCFResult<?> result) {
+ final IFileSystem fileSystem = dest.getRuntimeModel().getFileSystem();
+ if (fileSystem == null) {
+ result.setCancelled();
+ return;
+ }
- /**
- * Copy the file represented by the specified node to the destination folder.
- *
- * @param service The file system service to do the remote copying.
- * @param node The file node to be copied.
- * @param dest The destination folder.
- * @throws TCFFileSystemException The exception thrown during copying
- * @throws InterruptedException The exception thrown when the operation is canceled.
- */
- private void copyFile(IFileSystem service, FSTreeNode node, FSTreeNode dest) throws TCFFileSystemException, InterruptedException {
- if (monitor.isCanceled()) throw new InterruptedException();
- monitor.subTask(NLS.bind(Messages.OpCopy_Copying, node.name));
- // Create the copy target file
- final FSTreeNode copy = createCopyDestination(service, node, dest);
- String src_path = node.getLocation(true);
- String dst_path = copy.getLocation(true);
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- // Get the options of copy permission and ownership.
- service.copy(src_path, dst_path, cpPermission, cpOwnership, new DoneCopy() {
+ String sourcePath = source.getLocation(true);
+ final String path = getPath(dest, newName);
+ fileSystem.copy(sourcePath, path, fCopyPermissions, fCopyOwnership, new DoneCopy() {
@Override
public void doneCopy(IToken token, FileSystemException error) {
if (error != null) {
- String message = NLS.bind(Messages.OpCopy_CannotCopyFile, copy.name, error);
- errors[0] = new TCFFileSystemException(IStatus.ERROR, message, error);
+ result.setError(format(Messages.OpCopy_CannotCopyFile, source.getName()), error);
+ } else if (!result.checkCancelled()) {
+ fileSystem.stat(path, new DoneStat() {
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ result.setError(format(Messages.OpCopy_CannotCopyFile, source.getName()), error);
+ } else if (!result.checkCancelled()) {
+ if (existing != null) {
+ existing.setAttributes(attrs, false);
+ } else {
+ dest.addNode(new FSTreeNode(dest, newName, false, attrs), false);
+ }
+ result.setDone(null);
+ }
+ }
+ });
}
}
});
- if (errors[0] != null) {
- removeChild(service, dest, copy);
- throw errors[0];
- }
- monitor.worked(1);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
@Override
public String getName() {
return Messages.OpCopy_CopyingFile;
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- if(nodes != null && !nodes.isEmpty()) {
- final AtomicReference<Integer> ref = new AtomicReference<Integer>();
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose.
- }
- @Override
- public void run() throws Exception {
- FSTreeNode head = nodes.get(0);
- IChannel channel = null;
- try {
- channel = openChannel(head.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- ref.set(Integer.valueOf(count(service, nodes)));
- }
- else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, head.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
- }
- }
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- }
- }});
- Integer value = ref.get();
- return value == null ? IProgressMonitor.UNKNOWN : value.intValue();
- }
- return IProgressMonitor.UNKNOWN;
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java
index ad9460869..4709535d4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,184 +9,70 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import java.lang.reflect.InvocationTargetException;
+import static java.text.MessageFormat.format;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.SubProgressMonitor;
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.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.exceptions.TCFException;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFFileSystemException;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
* The base operation class for creating a file or a folder in the file system of Target
* Explorer.
*/
-public abstract class OpCreate extends Operation {
- // The folder in which a file/folder is going to be created.
- final protected FSTreeNode folder;
- // The node that is created after the operation.
- protected FSTreeNode node;
- // The name of the node to be created.
- final protected String name;
+public abstract class OpCreate extends AbstractOperation implements IResultOperation<IFSTreeNode> {
+ final protected FSTreeNode fDestination;
+ final protected String fName;
+ protected FSTreeNode fResult;
- /**
- * Create an FSCreate instance with the specified folder and the name of the new node.
- *
- * @param folder The folder in which the new node is going to be created. Must not be <code>null</code>.
- * @param name The new node's name. Must not be <code>null</code>.
- */
public OpCreate(FSTreeNode folder, String name) {
Assert.isNotNull(folder);
- this.folder = folder;
Assert.isNotNull(name);
- this.name = name;
+ fDestination = folder;
+ fName = name;
}
- /*
- * (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 {
- super.run(monitor);
- IChannel channel = null;
- try {
- channel = openChannel(folder.peerNode.getPeer());
- monitor.worked(1);
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- if (!folder.childrenQueried) {
- // If the children of folder is not queried, load it first.
- loadChildren(folder, service);
- monitor.worked(1);
- }
- monitor.worked(1);
- create(service);
- monitor.worked(1);
- addNode(service);
- monitor.worked(1);
- refresh(service);
- monitor.worked(1);
- }
- else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, folder.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
+ protected IStatus doRun(IProgressMonitor monitor) {
+ if (fDestination.getChildren() == null) {
+ IStatus status = fDestination.operationRefresh(false).run(new SubProgressMonitor(monitor, 0));
+ if (!status.isOK())
+ return status;
}
- catch (TCFException e) {
- throw new InvocationTargetException(e, e.getMessage());
+ FSTreeNode existing = fDestination.findChild(fName);
+ if (existing != null) {
+ return StatusHelper.createStatus(format(Messages.OpCreate_error_existingFile, existing.getLocation()), null);
}
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- monitor.done();
- }
- }
- /**
- * Refresh new node's stat using the file system service.
- *
- * @param service The file system service.
- * @throws TCFFileSystemException Thrown when refreshing the new node's stat.
- */
- void refresh(final IFileSystem service) throws TCFFileSystemException {
- if (node != null) {
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- String path = node.getLocation(true);
- service.stat(path, new DoneStat() {
- @Override
- public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
- if (error == null) {
- if (node != null) node.setAttributes(attrs);
- }
- else {
- errors[0] = newTCFException(IStatus.WARNING, error);
- }
- }
- });
- if (errors[0] != null) {
- throw errors[0];
+ final TCFResult<FSTreeNode> result = new TCFResult<FSTreeNode>();
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ tcfCreate(fDestination, fName, result);
}
- }
- }
+ });
- /**
- * Add the new node to the folder and its RuntimeModel.
- *
- * @param service The file system service to be used.
- * @throws TCFFileSystemException Thrown when adding.
- */
- void addNode(final IFileSystem service) throws TCFFileSystemException {
- if (Protocol.isDispatchThread()) {
- node = newTreeNode();
- folder.addChild(node);
- }
- else {
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- try {
- addNode(service);
- }
- catch (TCFFileSystemException e) {
- errors[0] = e;
- }
- }
- });
- if (errors[0] != null) throw errors[0];
- }
+ IStatus status = result.waitDone(monitor);
+ fResult = result.getValue();
+ return status;
}
- /**
- * Create the new node, either a directory node or a file node.
- *
- * @return The new node.
- */
- protected abstract FSTreeNode newTreeNode();
-
- /**
- * Create the node in the target system.
- *
- * @param service The file system service used to create the new node.
- * @throws TCFFileSystemException Thrown when creating the node.
- */
- protected abstract void create(IFileSystem service) throws TCFFileSystemException;
-
- /**
- * Get the node that is created by this operation.
- *
- * @return the node created.
- */
- public FSTreeNode getNode() {
- return node;
- }
+ protected abstract void tcfCreate(FSTreeNode destination, String name, TCFResult<FSTreeNode> result);
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
@Override
public String getName() {
- return NLS.bind(Messages.OpCreate_TaskName, name);
+ return NLS.bind(Messages.OpCreate_TaskName, fName);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
@Override
- public int getTotalWork() {
- return folder.childrenQueried ? 5 : 6;
- }
+ public FSTreeNode getResult() {
+ return fResult;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java
index 44d9bdc98..f4402aa50 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,16 +9,19 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import org.eclipse.core.runtime.IStatus;
+import static java.text.MessageFormat.format;
+
+import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IFileSystem;
import org.eclipse.tcf.services.IFileSystem.DoneClose;
import org.eclipse.tcf.services.IFileSystem.DoneOpen;
+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.services.IFileSystem.IFileHandle;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFFileSystemException;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.RuntimeModel;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
@@ -26,56 +29,52 @@ import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
*/
public class OpCreateFile extends OpCreate {
- /**
- * Create an instance to create a file with the name in the folder.
- *
- * @param folder The folder in which the file is to be created. Must not be <code>null</code>.
- * @param name The new file's name. Must not be <code>null</code>.
- */
public OpCreateFile(FSTreeNode folder, String name) {
super(folder, name);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreate#create(org.eclipse.tcf.services.IFileSystem)
- */
@Override
- protected void create(IFileSystem service) throws TCFFileSystemException {
- String path = folder.getLocation(true);
- if (!path.endsWith("/")) path += "/"; //$NON-NLS-1$ //$NON-NLS-2$
- path += name;
- final FileSystemException[] errors = new FileSystemException[1];
- // Open the file.
- final IFileHandle[] handles = new IFileHandle[1];
- service.open(path, IFileSystem.TCF_O_WRITE | IFileSystem.TCF_O_CREAT | IFileSystem.TCF_O_TRUNC, null, new DoneOpen() {
- @Override
- public void doneOpen(IToken token, FileSystemException error, IFileHandle hdl) {
- errors[0] = error;
- handles[0] = hdl;
- }
- });
- if (errors[0] != null) {
- TCFFileSystemException exception = new TCFFileSystemException(IStatus.ERROR, errors[0].toString());
- exception.initCause(errors[0]);
- throw exception;
- }
- if (handles[0] == null) {
- throw new TCFFileSystemException(IStatus.ERROR, Messages.TcfURLConnection_NoFileHandleReturned);
+ protected void tcfCreate(final FSTreeNode destination, final String name, final TCFResult<FSTreeNode> result) {
+ Assert.isTrue(Protocol.isDispatchThread());
+ if (result.checkCancelled())
+ return;
+
+ final String path = getPath(destination, name);
+ final IFileSystem fileSystem = destination.getRuntimeModel().getFileSystem();
+ if (fileSystem == null) {
+ result.setCancelled();
+ return;
}
- service.close(handles[0], new DoneClose() {
+
+ fileSystem.open(path, IFileSystem.TCF_O_WRITE | IFileSystem.TCF_O_CREAT | IFileSystem.TCF_O_TRUNC, null, new DoneOpen() {
@Override
- public void doneClose(IToken token, FileSystemException error) {
+ public void doneOpen(IToken token, FileSystemException error, IFileHandle hdl) {
+ if (error != null) {
+ result.setError(format(Messages.OpCreateFile_error_create, path), error);
+ } else if (!result.checkCancelled()) {
+ fileSystem.close(hdl, new DoneClose() {
+ @Override
+ public void doneClose(IToken token, FileSystemException error) {
+ if (error != null) {
+ result.setError(format(Messages.OpCreateFile_error_create, path), error);
+ } else if (!result.checkCancelled()) {
+ fileSystem.stat(path, new DoneStat() {
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ result.setError(format(Messages.OpCreateFile_error_create, path), error);
+ } else if (!result.checkCancelled()) {
+ FSTreeNode node = new FSTreeNode(destination, name, false, attrs);
+ destination.addNode(node, true);
+ result.setDone(node);
+ }
+ }
+ });
+ }
+ }
+ });
+ }
}
});
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreate#newTreeNode()
- */
- @Override
- protected FSTreeNode newTreeNode() {
- return RuntimeModel.createFileNode(name, folder);
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java
index f2ff3a59b..ab39988cc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCreateFolder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,64 +9,62 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import org.eclipse.core.runtime.IStatus;
+import static java.text.MessageFormat.format;
+
+import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IFileSystem;
import org.eclipse.tcf.services.IFileSystem.DoneMkDir;
+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.filesystem.core.internal.exceptions.TCFFileSystemException;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.RuntimeModel;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
* The file operation class to create a folder in the file system of Target Explorer.
*/
public class OpCreateFolder extends OpCreate {
- /**
- * Create an instance to create a folder with the name in the folder.
- *
- * @param folder The folder in which the new folder is to be created. Must not be <code>null</code>.
- * @param name The name of the new folder. Must not be <code>null</code>.
- */
public OpCreateFolder(FSTreeNode folder, String name) {
super(folder, name);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreate#create(org.eclipse.tcf.services.IFileSystem)
- */
@Override
- protected void create(IFileSystem service) throws TCFFileSystemException {
- String path = folder.getLocation(true);
- if (!path.endsWith("/")) path += "/"; //$NON-NLS-1$ //$NON-NLS-2$
- path += name;
- final FileSystemException[] errors = new FileSystemException[1];
- service.mkdir(path, null, new DoneMkDir() {
+ protected void tcfCreate(final FSTreeNode destination, final String name, final TCFResult<FSTreeNode> result) {
+ Assert.isTrue(Protocol.isDispatchThread());
+ if (result.checkCancelled())
+ return;
+
+ final String path = getPath(destination, name);
+ final IFileSystem fileSystem = destination.getRuntimeModel().getFileSystem();
+ if (fileSystem == null) {
+ result.setCancelled();
+ return;
+ }
+
+ fileSystem.mkdir(path, null, new DoneMkDir() {
@Override
public void doneMkDir(IToken token, FileSystemException error) {
if (error != null) {
- errors[0] = error;
+ result.setError(format(Messages.OpCreateFolder_error_createFolder, path), error);
+ } else if (!result.checkCancelled()) {
+ fileSystem.stat(path, new DoneStat() {
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ result.setError(format(Messages.OpCreateFolder_error_createFolder, path), error);
+ } else if (!result.checkCancelled()) {
+ FSTreeNode node = new FSTreeNode(destination, name, false, attrs);
+ node.setContent(new FSTreeNode[0], false);
+ destination.addNode(node, true);
+ result.setDone(node);
+ }
+ }
+ });
}
}
});
- if (errors[0] != null) {
- TCFFileSystemException exception = new TCFFileSystemException(IStatus.ERROR, errors[0].toString());
- exception.initCause(errors[0]);
- throw exception;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCreate#newTreeNode()
- */
- @Override
- protected FSTreeNode newTreeNode() {
- FSTreeNode node = RuntimeModel.createFolderNode(name, folder);
- // Newly created folder does not have any children. Mark it as queried.
- node.queryDone();
- return node;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java
index 5dea3e520..d5516e7bf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDelete.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,224 +9,228 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import java.lang.reflect.InvocationTargetException;
+import static java.text.MessageFormat.format;
+
+import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
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.te.tcf.core.Tcf;
+import org.eclipse.tcf.services.IFileSystem.DirEntry;
+import org.eclipse.tcf.services.IFileSystem.DoneRemove;
+import org.eclipse.tcf.services.IFileSystem.FileSystemException;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
-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.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNodeWorkingCopy;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
* FSDelete deletes the selected FSTreeNode list.
*/
-public class OpDelete extends Operation {
- private static final int RETRY_TIMES = 3;
- //The nodes to be deleted.
- List<FSTreeNode> nodes;
- //The callback invoked to confirm deleting read-only files.
- IConfirmCallback confirmCallback;
-
- /**
- * Create a delete operation using the specified nodes.
- *
- * @param nodes The nodes to be deleted.
- */
- public OpDelete(List<FSTreeNode> nodes, IConfirmCallback confirmCallback) {
- this.nodes = getAncestors(nodes);
- this.confirmCallback = confirmCallback;
+public class OpDelete extends AbstractOperation {
+ private static class WorkItem {
+ final WorkItem fParent;
+ final FSTreeNode fNode;
+ boolean fContentCleared = false;
+ boolean fContentLeftOK = false;
+
+ WorkItem(FSTreeNode node) {
+ fParent = null;
+ fNode = node;
+ }
+
+ WorkItem(WorkItem item, FSTreeNode node) {
+ fParent = item;
+ fNode = node;
+ }
+
+ void setContentLeftOK() {
+ fContentLeftOK = true;
+ if (fParent != null)
+ fParent.setContentLeftOK();
+ }
+ }
+
+ LinkedList<WorkItem> fWork = new LinkedList<WorkItem>();
+ IConfirmCallback fConfirmCallback;
+ private List<FSTreeNode> fNodes;
+
+ public OpDelete(List<? extends IFSTreeNode> nodes, IConfirmCallback confirmCallback) {
+ fNodes = dropNestedNodes(nodes);
+ fConfirmCallback = confirmCallback;
}
- /*
- * (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 {
- super.run(monitor);
- FSTreeNode head = nodes.get(0);
- IChannel channel = null;
- try {
- channel = openChannel(head.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- for (FSTreeNode node : nodes) {
- remove(node, service);
- }
- }
- else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, head.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
+ protected IStatus doRun(IProgressMonitor monitor) {
+ SubMonitor sm = SubMonitor.convert(monitor, getName(), fNodes.size());
+ for (FSTreeNode node : fNodes) {
+ IStatus status = removeNode(node, sm.newChild(1));
+ node.getParent().notifyChange();
+ if (!status.isOK())
+ return status;
+ }
+ return Status.OK_STATUS;
+ }
+
+
+ private IStatus removeNode(FSTreeNode node, SubMonitor monitor) {
+ fWork.add(new WorkItem(node));
+ while (!fWork.isEmpty()) {
+ IStatus s = runWorkItem(fWork.remove(), monitor);
+ if (!s.isOK()) {
+ node.notifyChange();
+ return s;
}
}
- catch (TCFException e) {
- throw new InvocationTargetException(e, e.getMessage());
+ return Status.OK_STATUS;
+ }
+
+ protected IStatus runWorkItem(final WorkItem item, IProgressMonitor monitor) {
+ if (item.fContentLeftOK) {
+ if (item.fParent == null) {
+ return item.fNode.operationRefresh(true).run(monitor);
+ }
+ return Status.OK_STATUS;
}
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- monitor.done();
+
+ if (fConfirmCallback != null && fConfirmCallback.requires(item.fNode)) {
+ int makeWritable = confirmCallback(item.fNode, fConfirmCallback);
+ switch (makeWritable) {
+ case IConfirmCallback.NO:
+ item.setContentLeftOK();
+ return Status.OK_STATUS;
+ case IConfirmCallback.YES:
+ IStatus s = mkWritable(item.fNode, monitor);
+ if (!s.isOK())
+ return s;
+ break;
+ case IConfirmCallback.CANCEL:
+ default:
+ return Status.CANCEL_STATUS;
+ }
}
+
+ CacheManager.clearCache(item.fNode);
+
+ final TCFResult<?> result = new TCFResult<Object>();
+ monitor.subTask(NLS.bind(Messages.OpDelete_RemovingFileFolder, item.fNode.getLocation()));
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ tcfRunWorkItem(item, result);
+ }
+ });
+ return result.waitDone(monitor);
}
- /**
- * Delete the file/folder node using the file system service.
- *
- * @param monitor The monitor to report the progress.
- * @param node The file/folder node to be deleted.
- * @param service The file system service.
- * @throws TCFFileSystemException The exception thrown during deleting.
- * @throws InterruptedException Thrown when the operation is canceled.
- */
- void remove(FSTreeNode node, IFileSystem service) throws TCFFileSystemException, InterruptedException {
- if (node.isFile()) {
- removeFile(node, service);
- }
- else if (node.isDirectory()) {
- removeFolder(node, service);
+ private IStatus mkWritable(IFSTreeNode node, IProgressMonitor monitor) {
+ final IFSTreeNodeWorkingCopy workingCopy = node.createWorkingCopy();
+ if (node.isWindowsNode()) {
+ workingCopy.setReadOnly(false);
+ } else {
+ workingCopy.setWritable(true);
}
+ return workingCopy.operationCommit().run(new SubProgressMonitor(monitor, 0));
}
- /**
- * Delete the folder node and its children using the file system service.
- *
- * @param monitor The monitor to report the progress.
- * @param node The folder node to be deleted.
- * @param service The file system service.
- * @throws TCFFileSystemException The exception thrown during deleting.
- * @throws InterruptedException Thrown when the operation is canceled.
- */
- @Override
- protected void removeFolder(final FSTreeNode node, IFileSystem service) throws TCFFileSystemException, InterruptedException {
- List<FSTreeNode> children = getChildren(node, service);
- if (!children.isEmpty()) {
- for (FSTreeNode child : children) {
- // Delete each child node.
- remove(child, service);
+ protected void tcfRunWorkItem(final WorkItem item, TCFResult<?> result) {
+ if (item.fNode.isFile()) {
+ tcfDeleteFile(item, result);
+ } else if (item.fNode.isDirectory()) {
+ if (item.fContentCleared) {
+ tcfDeleteEmptyFolder(item, result);
+ } else {
+ tcfDeleteFolder(item, result);
}
+ } else {
+ result.setDone(null);
}
- monitor.subTask(NLS.bind(Messages.OpDelete_RemovingFileFolder, node.name));
- super.removeFolder(node, service);
- monitor.worked(1);
}
- /**
- * Delete the file node using the file system service.
- *
- * @param node The file node to be deleted.
- * @param service The file system service.
- * @throws TCFFileSystemException The exception thrown during deleting.
- * @throws InterruptedException Thrown when the operation is canceled.
- */
- protected void removeFile(final FSTreeNode node, IFileSystem service) throws TCFFileSystemException, InterruptedException {
- if (monitor.isCanceled()) throw new InterruptedException();
- monitor.subTask(NLS.bind(Messages.OpDelete_RemovingFileFolder, node.name));
- // If the file is read only on windows or not writable on unix, then make it deletable.
- if (confirmCallback != null && confirmCallback.requires(node)) {
- if (!yes2All) {
- int result = confirmCallback.confirms(node);
- if (result == 1) {
- yes2All = true;
- }
- else if (result == 2) {
- monitor.worked(1);
- return;
- }
- else if (result == 3) {
- // Cancel the whole operation
- monitor.setCanceled(true);
- throw new InterruptedException();
+ private void tcfDeleteFolder(final WorkItem item, final TCFResult<?> result) {
+ final String path = item.fNode.getLocation(true);
+ final IFileSystem fs = item.fNode.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ return;
+ }
+
+ tcfReadDir(fs, path, new IReadDirDone() {
+ @Override
+ public void error(FileSystemException error) {
+ result.setError(format(Messages.OpDelete_error_readDir, path), error);
+ }
+
+ @Override
+ public boolean checkCancelled() {
+ return result.checkCancelled();
+ }
+
+ @Override
+ public void done(List<DirEntry> entries) {
+ // Add current work item for final deletion
+ item.fContentCleared = true;
+ fWork.addFirst(item);
+ // Create work items for the children
+ for (DirEntry entry : entries) {
+ FSTreeNode node = new FSTreeNode(item.fNode, entry.filename, false, entry.attrs);
+ fWork.addFirst(new WorkItem(item, node));
}
+ result.setDone(null);
}
- IStatus status = mkWritable(node);
- if (!status.isOK()) return;
- }
- super.removeFile(node, service);
- monitor.worked(1);
+ });
}
-
- /**
- * Make the file/folder writable by changing its properties.
- * It will try several times before return.
- *
- * @param node the file/folder node.
- */
- private IStatus mkWritable(FSTreeNode node) {
- final FSTreeNode clone = (FSTreeNode) node.clone();
- if (node.isWindowsNode()) {
- clone.setReadOnly(false);
+
+ private void tcfDeleteFile(final WorkItem item, final TCFResult<?> result) {
+ final IFileSystem fs = item.fNode.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ return;
}
- else {
- clone.setWritable(true);
+ fs.remove(item.fNode.getLocation(true), new DoneRemove() {
+ @Override
+ public void doneRemove(IToken token, FileSystemException error) {
+ tcfHandleRemoved(item, error, result);
+ }
+ });
+ }
+
+ private void tcfDeleteEmptyFolder(final WorkItem item, final TCFResult<?> result) {
+ final IFileSystem fs = item.fNode.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ return;
}
- // Make the file writable.
- OpCommitAttr op = new OpCommitAttr(node, clone.attr);
- IOpExecutor executor = new NullOpExecutor();
- IStatus status = null;
- for (int i = 0; i < RETRY_TIMES; i++) {
- status = executor.execute(op);
- if (status.isOK()) return status;
+ fs.rmdir(item.fNode.getLocation(true), new DoneRemove() {
+ @Override
+ public void doneRemove(IToken token, FileSystemException error) {
+ tcfHandleRemoved(item, error, result);
+ }
+ });
+ }
+
+ protected void tcfHandleRemoved(final WorkItem item, FileSystemException error, final TCFResult<?> result) {
+ if (error != null) {
+ result.setError(format(Messages.OpDelete_error_delete, item.fNode.getLocation()), error);
+ } else if (!result.checkCancelled()) {
+ if (item.fParent == null) {
+ item.fNode.getParent().removeNode(item.fNode, true);
+ }
+ result.setDone(null);
}
- return status;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
@Override
public String getName() {
return Messages.OpDelete_Deleting;
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- if(nodes != null && !nodes.isEmpty()) {
- final AtomicReference<Integer> ref = new AtomicReference<Integer>();
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose.
- }
- @Override
- public void run() throws Exception {
- FSTreeNode head = nodes.get(0);
- IChannel channel = null;
- try {
- channel = openChannel(head.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- ref.set(Integer.valueOf(count(service, nodes)));
- }
- else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, head.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
- }
- }
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- }
- }});
- Integer value = ref.get();
- return value == null ? IProgressMonitor.UNKNOWN : value.intValue();
- }
- return IProgressMonitor.UNKNOWN;
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java
index 3b72c9355..72aaa3bc3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -11,162 +11,108 @@ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
-import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.OutputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-/**
- * Download multiple files from local system to a remote system.
- */
-public class OpDownload extends OpStreamOp {
- // The destination files to be downloaded to.
- protected File[] dstFiles;
- // The source nodes to be downloaded from.
- protected FSTreeNode[] srcNodes;
+public class OpDownload extends AbstractOperation {
- /**
- * Create a download operation to download a file node
- * to a local file.
- *
- * @param dstFile The local file to be downloaded to.
- * @param srcNode The source node to be downloaded from.
- */
- public OpDownload(File dstFile, FSTreeNode srcNode) {
- this(new File[]{dstFile}, new FSTreeNode[]{srcNode});
- }
-
- /**
- * Create a download operation to download file nodes
- * to local files.
- *
- * @param dstFiles The local files to be downloaded to.
- * @param srcNodes The source nodes to be downloaded from.
- */
- public OpDownload(File[] dstFiles, FSTreeNode[] srcNodes) {
- this.dstFiles = dstFiles;
- this.srcNodes = srcNodes;
- }
+ private final OutputStream fTarget;
+ private final FSTreeNode fSource;
+ private final boolean fResetDigest;
- /**
- * Create a download operation to download specified nodes
- * to its local cache files.
- *
- * @param srcNodes The source file nodes to be downloaded.
- */
- public OpDownload(FSTreeNode... srcNodes) {
- this.srcNodes = srcNodes;
- this.dstFiles = new File[srcNodes.length];
- for (int i = 0; i < srcNodes.length; i++) {
- this.dstFiles[i] = CacheManager.getCacheFile(srcNodes[i]);
- }
+ public OpDownload(FSTreeNode srcNode, OutputStream target) {
+ fTarget = target;
+ fSource = srcNode;
+ fResetDigest = target == null;
}
- /*
- * (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 {
- super.run(monitor);
+ public IStatus doRun(IProgressMonitor monitor) {
try {
- downloadFiles(dstFiles, srcNodes);
- if(monitor.isCanceled()) throw new InterruptedException();
- } catch (MalformedURLException e) {
- throw new InvocationTargetException(e, e.getLocalizedMessage());
- } catch (IOException e) {
- throw new InvocationTargetException(e, e.getLocalizedMessage());
- } finally {
- monitor.done();
+ if (fTarget != null) {
+ downloadFile(fSource, fTarget, monitor);
+ } else {
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(fSource.getCacheFile()));
+ try {
+ downloadFile(fSource, out, monitor);
+ } finally {
+ try {
+ out.close();
+ } catch(IOException e) {
+ }
+ }
+ }
+ } catch (Exception e) {
+ if (fTarget == null) {
+ fSource.getCacheFile().delete();
+ }
+ return StatusHelper.createStatus("Cannot download " + fSource.getName(), e); //$NON-NLS-1$
}
+ return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
- /**
- * Download the specified file list to the specified locations, reporting the progress
- * using the specified monitor.
- *
- * @param dstFiles The file list to be downloaded to.
- * @param srcNodes The node list to be downloaded from.
- * @param monitor The monitor that reports progress.
- * @throws IOException The exception reported during downloading.
- */
- private void downloadFiles(File[] dstFiles, FSTreeNode[] srcNodes) throws IOException {
- // The buffer used to download the file.
+ private void downloadFile(FSTreeNode source, OutputStream out, IProgressMonitor monitor) throws IOException {
byte[] data = new byte[DEFAULT_CHUNK_SIZE];
- // Calculate the total size.
- long totalSize = 0;
- for (FSTreeNode node:srcNodes) {
- totalSize += node.attr == null ? 0L : node.attr.size;
- }
- // Calculate the chunk size of one percent.
- int chunk_size = (int) totalSize / 100;
- // The current reading percentage.
+ long size = source.getSize();
+ long percentSize = size / 100;
int percentRead = 0;
- // The current length of read bytes.
long bytesRead = 0;
- for (int i = 0; i < srcNodes.length && !monitor.isCanceled(); i++) {
- FSTreeNode node = srcNodes[i];
- long size = node.attr == null ? 0L : node.attr.size;
- MessageDigest digest = null;
- BufferedInputStream input = null;
- BufferedOutputStream output = null;
+
+ monitor.beginTask(getName(), 100);
+
+ MessageDigest digest = null;
+ BufferedInputStream input = null;
+
+ TcfURLConnection connection = (TcfURLConnection) source.getLocationURL().openConnection();
+ try {
try {
- URL url = node.getLocationURL();
- TcfURLConnection connection = (TcfURLConnection) url.openConnection();
- try {
- digest = MessageDigest.getInstance(MD_ALG);
- input = new BufferedInputStream(new DigestInputStream(connection.getInputStream(), digest));
- }
- catch (NoSuchAlgorithmException e) {
- input = new BufferedInputStream(connection.getInputStream());
- }
- output = new BufferedOutputStream(new FileOutputStream(dstFiles[i]));
+ digest = MessageDigest.getInstance(MD_ALG);
+ input = new BufferedInputStream(new DigestInputStream(connection.getInputStream(), digest));
+ } catch (NoSuchAlgorithmException e) {
+ input = new BufferedInputStream(connection.getInputStream());
+ }
- // Total size displayed on the progress dialog.
- String fileLength = formatSize(size);
- int length;
- while ((length = input.read(data)) >= 0 && !monitor.isCanceled()) {
- output.write(data, 0, length);
- output.flush();
- bytesRead += length;
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- // Report the progress.
- monitor.subTask(NLS.bind(Messages.OpDownload_Downloading, new Object[]{node.name, formatSize(bytesRead), fileLength}));
- }
+ String fileLength = formatSize(size);
+ int length;
+ while ((length = input.read(data)) >= 0 && !monitor.isCanceled()) {
+ out.write(data, 0, length);
+ bytesRead += length;
+ if (percentSize != 0) {
+ int percent = (int) (bytesRead / percentSize);
+ if (percent != percentRead) { // Update the progress.
+ monitor.worked(percent - percentRead);
+ percentRead = percent; // Remember the percentage.
+ // Report the progress.
+ monitor.subTask(NLS.bind(Messages.OpDownload_Downloading, new Object[]{source.getName(), formatSize(bytesRead), fileLength}));
}
}
}
- finally {
- if (output != null) {
- try {
- output.close();
- } catch (Exception e) {
- }
+ if (!monitor.isCanceled()) {
+ if (digest != null) {
+ updateNodeDigest(source, digest.digest());
}
- if (input != null) {
- try {
- input.close();
- } catch (Exception e) {
- }
- }
- if(digest != null) {
- updateNodeDigest(node, digest.digest());
+ }
+ } finally {
+ out.flush();
+ if (input != null) {
+ try {
+ input.close();
+ } catch (Exception e) {
}
}
}
@@ -179,28 +125,16 @@ public class OpDownload extends OpStreamOp {
* @param digest The digest data.
*/
protected void updateNodeDigest(FSTreeNode node, byte[] digest) {
+ FileState fileDigest = PersistenceManager.getInstance().getFileDigest(node);
+ if (fResetDigest) {
+ fileDigest.reset(digest);
+ } else {
+ fileDigest.updateTargetDigest(digest);
+ }
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
@Override
public String getName() {
- String message;
- if(dstFiles.length==1)
- message = NLS.bind(Messages.OpDownload_DownloadingSingleFile, dstFiles[0].getName());
- else
- message = NLS.bind(Messages.OpDownload_DownloadingMultipleFiles, Long.valueOf(dstFiles.length));
- return message;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return 100;
+ return NLS.bind(Messages.OpDownload_DownloadingSingleFile, fSource.getName());
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java
index d1d0e50d1..d8990ca50 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpMove.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,197 +9,262 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import java.lang.reflect.InvocationTargetException;
+import static java.text.MessageFormat.format;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
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.DoneRemove;
import org.eclipse.tcf.services.IFileSystem.DoneRename;
import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.tcf.core.Tcf;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
-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.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
* FSMove moves specified tree nodes to a destination folder.
*/
-public class OpMove extends Operation {
- // The file/folder nodes to be moved.
- List<FSTreeNode> nodes;
- // The destination folder to be moved to.
- FSTreeNode dest;
- // The callback
- IConfirmCallback confirmCallback;
-
- /**
- * Create a move operation to move the specified nodes to the destination folder.
- *
- * @param nodes The nodes to be moved.
- * @param dest the destination folder to move to.
- */
- public OpMove(List<FSTreeNode> nodes, FSTreeNode dest) {
- this(nodes, dest, null);
+public class OpMove extends AbstractOperation {
+ private static class WorkItem {
+ final WorkItem fParent;
+ final FSTreeNode fDestination;
+ final FSTreeNode fSource;
+ boolean fContentCleared = false;
+ boolean fContentLeftOK = false;
+
+ WorkItem(FSTreeNode source, FSTreeNode destination) {
+ this(null, source, destination);
+ }
+
+ WorkItem(WorkItem parent, FSTreeNode source, FSTreeNode destination) {
+ fParent = parent;
+ fSource = source;
+ fDestination = destination;
+ }
+
+ void setContentLeftOK() {
+ fContentLeftOK = true;
+ if (fParent != null)
+ fParent.setContentLeftOK();
+ }
+
}
- /**
- * Create a move operation to move the specified nodes to the destination folder
- * and a confirmation callback.
- *
- * @param nodes The nodes to be moved.
- * @param dest the destination folder to move to.
- * @param confirmCallback the confirmation callback.
- */
- public OpMove(List<FSTreeNode> nodes, FSTreeNode dest, IConfirmCallback confirmCallback) {
- super();
- this.nodes = getAncestors(nodes);
- this.dest = dest;
- this.confirmCallback = confirmCallback;
+ IConfirmCallback fConfirmCallback;
+
+ LinkedList<WorkItem> fWork = new LinkedList<WorkItem>();
+ private long fStartTime;
+
+ public OpMove(List<? extends IFSTreeNode> nodes, FSTreeNode dest, IConfirmCallback confirmCallback) {
+ fConfirmCallback = confirmCallback;
+ for (FSTreeNode node : dropNestedNodes(nodes)) {
+ fWork.add(new WorkItem(node, dest));
+ }
}
- /*
- * (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 {
- super.run(monitor);
- // Remove its self from the clipped nodes.
- nodes.remove(dest);
- IChannel channel = null;
- try {
- if (!nodes.isEmpty()) {
- FSTreeNode head = nodes.get(0);
- channel = openChannel(head.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- for (FSTreeNode node : nodes) {
- // Move each node.
- moveNode(service, node, dest);
- }
- }
- else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, head.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
- }
- }
+ public String getName() {
+ return Messages.OpMove_MovingFile;
+ }
+
+ @Override
+ public IStatus doRun(IProgressMonitor monitor) {
+ if (fWork.isEmpty())
+ return Status.OK_STATUS;
+
+ fStartTime = System.currentTimeMillis();
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+
+ List<FSTreeNode> notify = new ArrayList<FSTreeNode>();
+ notify.add(fWork.peek().fDestination);
+ for (WorkItem item : fWork) {
+ notify.add(item.fSource.getParent());
}
- catch (TCFException e) {
- throw new InvocationTargetException(e, e.getMessage());
+
+ IStatus status = Status.OK_STATUS;
+ while (!fWork.isEmpty()) {
+ WorkItem item = fWork.remove();
+ status = runWorkItem(item, monitor);
+ if (!status.isOK())
+ break;
}
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- monitor.done();
+
+ for (FSTreeNode node : dropNestedNodes(notify)) {
+ node.notifyChange();
}
+ return status;
}
- /**
- * Move the file/folder to the destination folder using the specified file system service.
- *
- * @param monitor The monitor used to report the moving progress.
- * @param service The file system service used to move the remote files.
- * @param node The file/folder node to be moved.
- * @param dest The destination folder.
- * @throws TCFFileSystemException The exception thrown during moving.
- * @throws InterruptedException Thrown when the operation is canceled.
- */
- void moveNode(IFileSystem service, final FSTreeNode node, FSTreeNode dest) throws TCFFileSystemException, InterruptedException {
- if (monitor.isCanceled()) throw new InterruptedException();
- monitor.subTask(NLS.bind(Messages.OpMove_Moving, node.name));
- FSTreeNode copy = findChild(service, dest, node.name);
- if (copy == null || !copy.equals(node) && confirmReplace(node, confirmCallback)) {
- if (copy != null && copy.isDirectory() && node.isDirectory()) {
- List<FSTreeNode> children = getChildren(node, service);
- for (FSTreeNode child : children) {
- moveNode(service, child, copy);
- }
- removeFolder(node, service);
- monitor.worked(1);
- }
- else if (copy != null && copy.isFile() && node.isDirectory()) {
- String error = NLS.bind(Messages.OpMove_FileExistsError, copy.name);
- throw new TCFFileSystemException(IStatus.ERROR, error);
- }
- else if (copy != null && copy.isDirectory() && node.isFile()) {
- String error = NLS.bind(Messages.OpMove_FolderExistsError, copy.name);
- throw new TCFFileSystemException(IStatus.ERROR, error);
+ protected IStatus runWorkItem(final WorkItem item, final IProgressMonitor monitor) {
+ if (item.fContentLeftOK)
+ return Status.OK_STATUS;
+
+ if (item.fContentCleared) {
+ return deleteEmptyFolder(item.fSource, monitor);
+ }
+
+ return move(item, monitor);
+ }
+
+ private IStatus move(final WorkItem item, final IProgressMonitor monitor) {
+ monitor.subTask(NLS.bind(Messages.OpMove_Moving, item.fSource.getLocation()));
+
+ final FSTreeNode source = item.fSource;
+ final FSTreeNode destination = item.fDestination;
+ IStatus status = refresh(destination, fStartTime, monitor);
+ if (!status.isOK())
+ return status;
+
+ status = refresh(source, fStartTime, monitor);
+ if (!status.isOK())
+ return status;
+
+ final FSTreeNode existing = destination.findChild(source.getName());
+ if (existing != null) {
+ if (source == existing) {
+ return Status.OK_STATUS;
}
- else {
- if (copy != null && copy.isFile() && node.isFile()) {
- removeFile(copy, service);
+ if (source.isDirectory()) {
+ if (!existing.isDirectory()) {
+ return StatusHelper.createStatus(format(Messages.OpCopy_error_noDirectory, existing.getLocation()), null);
+ }
+ int replace = confirmCallback(existing, fConfirmCallback);
+ if (replace == IConfirmCallback.NO) {
+ item.setContentLeftOK();
+ return Status.OK_STATUS;
+ }
+ if (replace != IConfirmCallback.YES) {
+ return Status.CANCEL_STATUS;
}
- else if (copy == null) {
- copy = (FSTreeNode) node.clone();
+
+ item.fContentCleared = true;
+ fWork.addFirst(item);
+ for (FSTreeNode child : source.getChildren()) {
+ fWork.addFirst(new WorkItem(item, child, existing));
+ }
+ return Status.OK_STATUS;
+ } else if (source.isFile()) {
+ if (!existing.isFile()) {
+ return StatusHelper.createStatus(format(Messages.OpCopy_error_noFile, existing.getLocation()), null);
}
- addChild(service, dest, copy);
- String dst_path = copy.getLocation(true);
- String src_path = node.getLocation(true);
- final FSTreeNode copyNode = copy;
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- service.rename(src_path, dst_path, new DoneRename() {
- @Override
- public void doneRename(IToken token, FileSystemException error) {
- if (error != null) {
- String message = NLS.bind(Messages.OpMove_CannotMove, node.name, error);
- errors[0] = new TCFFileSystemException(IStatus.ERROR, message, error);
- }
- else {
- cleanUpNode(node, copyNode);
- }
- }
- });
- if (errors[0] != null) {
- removeChild(service, dest, copy);
- throw errors[0];
+ int replace = confirmCallback(existing, fConfirmCallback);
+ if (replace == IConfirmCallback.NO) {
+ item.setContentLeftOK();
+ return Status.OK_STATUS;
}
- monitor.worked(1);
+ if (replace != IConfirmCallback.YES) {
+ return Status.CANCEL_STATUS;
+ }
+ } else {
+ return Status.OK_STATUS;
}
}
+
+ CacheManager.clearCache(existing);
+ CacheManager.clearCache(source);
+
+ final TCFResult<?> result = new TCFResult<Object>();
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ if (existing != null) {
+ tcfMoveReplace(source, destination, existing, result);
+ } else {
+ tcfMove(source, destination, result);
+ }
+ }
+ });
+ return result.waitDone(monitor);
}
- /**
- * Clean up the node after successful moving.
- *
- * @param node The node being moved.
- * @param copyNode The target node that is moved to.
- */
- void cleanUpNode(FSTreeNode node, FSTreeNode copyNode) {
- if (node.isFile()) {
- super.cleanUpFile(node);
+
+ protected void tcfMoveReplace(final FSTreeNode source, final FSTreeNode destination, final FSTreeNode existing, final TCFResult<?> result) {
+ if (result.checkCancelled())
+ return;
+
+ final IFileSystem fileSystem = destination.getRuntimeModel().getFileSystem();
+ if (fileSystem == null) {
+ result.setCancelled();
+ return;
}
- else if (node.isDirectory()) {
- super.cleanUpFolder(node);
- List<FSTreeNode> children = node.getChildren();
- copyNode.addChidren(children);
- for (FSTreeNode child : children) {
- child.setParent(copyNode);
+
+ fileSystem.remove(existing.getLocation(true), new DoneRemove() {
+ @Override
+ public void doneRemove(IToken token, FileSystemException error) {
+ if (error != null) {
+ result.setError(format(Messages.OpMove_CannotMove, source.getLocation()), error);
+ } else if (!result.checkCancelled()) {
+ existing.getParent().removeNode(existing, false);
+ tcfMove(source, destination, result);
+ }
}
+ });
+ }
+
+ protected void tcfMove(final FSTreeNode source, final FSTreeNode dest, final TCFResult<?> result) {
+ final IFileSystem fileSystem = dest.getRuntimeModel().getFileSystem();
+ if (fileSystem == null) {
+ result.setCancelled();
+ return;
}
+
+ final String sourcePath = source.getLocation(true);
+ final String destPath = getPath(dest, source.getName());
+
+ fileSystem.rename(sourcePath, destPath, new DoneRename() {
+ @Override
+ public void doneRename(IToken token, FileSystemException error) {
+ if (error != null) {
+ result.setError(format(Messages.OpMove_CannotMove, sourcePath), error);
+ } else {
+ source.getParent().removeNode(source, false);
+ source.changeParent(dest);
+ dest.addNode(source, false);
+ result.setDone(null);
+ }
+ }
+ });
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
- @Override
- public String getName() {
- return Messages.OpMove_MovingFile;
- }
+ private IStatus deleteEmptyFolder(final FSTreeNode source, IProgressMonitor monitor) {
+ CacheManager.clearCache(source);
+ final TCFResult<?> result = new TCFResult<Object>();
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ tcfDeleteEmptyFolder(source, result);
+ }
+ });
+ return result.waitDone(monitor);
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return nodes == null ? IProgressMonitor.UNKNOWN : nodes.size();
- }
+ protected void tcfDeleteEmptyFolder(final FSTreeNode source, final TCFResult<?> result) {
+ final IFileSystem fs = source.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ return;
+ }
+ fs.rmdir(source.getLocation(true), new DoneRemove() {
+ @Override
+ public void doneRemove(IToken token, FileSystemException error) {
+ if (error != null) {
+ result.setError(format(Messages.OpDelete_error_delete, source.getLocation()), error);
+ } else if (!result.checkCancelled()) {
+ source.getParent().removeNode(source, false);
+ result.setDone(null);
+ }
+ }
+ });
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpOutStreamOp.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpOutStreamOp.java
deleted file mode 100644
index 314feab03..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpOutStreamOp.java
+++ /dev/null
@@ -1,98 +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.filesystem.core.internal.operations;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * The operation class that download a file node to a specified output stream.
- */
-public class OpOutStreamOp extends OpStreamOp {
- // The output stream to write to.
- private OutputStream output;
- // The file node to download from.
- private FSTreeNode node;
-
- /**
- * Create an operation instance to download the specified file to the specified
- * output stream.
- *
- * @param node The file to be downloaded.
- * @param output The output stream to write to.
- */
- public OpOutStreamOp(FSTreeNode node, OutputStream output) {
- this.node = node;
- this.output = output;
- }
-
- /*
- * (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 {
- super.run(monitor);
- InputStream input = null;
- // Open the input stream of the node using the tcf stream protocol.
- try {
- URL url = node.getLocationURL();
- InputStream in = url.openStream();
- input = new BufferedInputStream(in);
- // The buffer used to download the file.
- byte[] data = new byte[DEFAULT_CHUNK_SIZE];
- // Calculate the chunk size of one percent.
- int chunk_size = (int) node.attr.size / 100;
- // Total size displayed on the progress dialog.
- String total_size = formatSize(node.attr.size);
-
- int percentRead = 0;
- long bytesRead = 0;
- int length;
- while ((length = input.read(data)) >= 0 && !monitor.isCanceled()) {
- output.write(data, 0, length);
- output.flush();
- bytesRead += length;
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- // Report the progress.
- monitor.subTask(NLS.bind(Messages.OpOutStreamOp_DownloadingProgress, formatSize(bytesRead), total_size));
- }
- }
- }
- if(monitor.isCanceled()) throw new InterruptedException();
- }
- catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- finally {
- if (input != null) {
- try {
- input.close();
- }
- catch (Exception e) {
- }
- }
- monitor.done();
- }
- }
-}
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 625f37747..e34669a13 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -9,22 +9,25 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
+import static java.text.MessageFormat.format;
+import static org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager.getRuntimeModel;
+
import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.utils.Host;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.testers.TargetPropertyTester;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
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.ModelManager;
@@ -32,7 +35,7 @@ import org.eclipse.tcf.te.tcf.locator.model.ModelManager;
/**
* The operation to parse a platform specific path to a target's node.
*/
-public class OpParsePath extends Operation {
+public class OpParsePath extends AbstractOperation implements IResultOperation<IFSTreeNode> {
// The peer on which the file is located.
IPeerNode peer;
// The path on the target.
@@ -119,109 +122,71 @@ public class OpParsePath extends Operation {
}
}
- /**
- * Get the parsing result, which is a node that representing
- * a file on the target system.
- *
- * @return The file system node.
- */
+ @Override
public FSTreeNode getResult() {
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 (peer != null && path != null) {
- final FSTreeNode root = org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager.getRuntimeModel(peer).getRoot();
- if (!root.childrenQueried) {
- new NullOpExecutor().execute(new OpRefreshRoots(root));
- }
- Object[] elements = root.getChildren().toArray();
- if (elements != null && elements.length != 0 && path.length() != 0) {
- final FSTreeNode[] children = new FSTreeNode[elements.length];
- System.arraycopy(elements, 0, children, 0, elements.length);
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void handleException(Throwable e) {
- // Ignore exception
- }
+ public IStatus doRun(IProgressMonitor monitor) {
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+ if (peer == null || path == null)
+ return Status.OK_STATUS;
- @Override
- public void run() throws Exception {
- result = findPath(peer.getPeer(), children, path);
- }
- });
- }
- }
+ IRuntimeModel rtm = getRuntimeModel(peer);
+ if (rtm == null)
+ return null;
+
+ final FSTreeNode node = (FSTreeNode) rtm.getRoot();
+ return findPath(node, path, monitor);
}
+ private IStatus findPath(FSTreeNode node, String path, IProgressMonitor monitor) {
+ if (path == null || path.length() == 0) {
+ result = node;
+ return Status.OK_STATUS;
+ }
- /**
- * Search the path in the children list. If it exists, then search the children of the found
- * node recursively until the whole path is found. Or else return null.
- *
- * @param children The children nodes to search the path.
- * @param path The path to be searched.
- * @return The leaf node that has the searched path.
- * @throws TCFException Thrown during searching.
- */
- FSTreeNode findPath(IPeer peer, FSTreeNode[] children, String path) throws TCFException, InterruptedException {
- Assert.isTrue(children != null && children.length != 0);
- Assert.isTrue(path != null && path.length() != 0);
- FSTreeNode node = children[0];
- String osPathSep = node.isWindowsNode() ? "\\" : "/"; //$NON-NLS-1$ //$NON-NLS-2$
- int delim = path.indexOf(osPathSep);
- String segment = null;
- if (delim != -1) {
- segment = path.substring(0, delim);
- path = path.substring(delim + 1);
- if (node.isRoot()) {
- // If it is root directory, the name ends with the path separator.
- segment += osPathSep;
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
+
+ path = path.replace(':', CacheManager.PATH_ESCAPE_CHAR);
+
+ if (node.getChildren() == null) {
+ IStatus status = node.operationRefresh(false).run(new SubProgressMonitor(monitor, 0));
+ if (!status.isOK())
+ return status;
+ }
+
+ if (node.isFileSystem()) {
+ for (FSTreeNode child : node.getChildren()) {
+ if (path.startsWith(child.getName().replace(':', CacheManager.PATH_ESCAPE_CHAR))) {
+ return findPath(child, path.substring(child.getName().length()), monitor);
+ }
}
+ return Status.OK_STATUS;
}
- else {
+
+ String osPathSep = node.isWindowsNode() ? "\\" : "/"; //$NON-NLS-1$ //$NON-NLS-2$
+ int delim = path.indexOf(osPathSep);
+ final String segment;
+ if (delim == -1) {
segment = path;
path = null;
+ } else {
+ segment = path.substring(0, delim);
+ path = path.substring(delim+1);
}
- node = findPathSeg(children, segment);
- if (path == null || path.trim().length() == 0) {
- // The end of the path.
- return node;
- }
- else if (node != null) {
- if (node.isDirectory()) {
- List<FSTreeNode> nodes= new Operation().getChildren(node);
- children = nodes.toArray(new FSTreeNode[nodes.size()]);
- }
- else {
- children = null;
- }
- if (children != null && children.length != 0) {
- return findPath(peer, children, path);
- }
- }
- return null;
+
+ node = node.findChild(segment);
+ if (node == null)
+ return Status.OK_STATUS;
+
+ return findPath(node, path, monitor);
}
- /**
- * Find in the children array the node that has the specified name.
- *
- * @param children The children array in which to find the node.
- * @param name The name of the node to be searched.
- * @return The node that has the specified name.
- */
- private FSTreeNode findPathSeg(FSTreeNode[] children, String name) {
- for (FSTreeNode child : children) {
- if (child.isWindowsNode()) {
- if (child.name.equalsIgnoreCase(name)) return child;
- }
- else if (child.name.equals(name)) return child;
- }
- return null;
+ @Override
+ public String getName() {
+ return format(Messages.OpParsePath_name, path);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java
index 8df9e38eb..e70332f5f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,185 +9,284 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
+import static java.text.MessageFormat.format;
+
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeoutException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
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.te.tcf.core.Tcf;
-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.FSTreeNode;
+import org.eclipse.tcf.services.IFileSystem.DirEntry;
+import org.eclipse.tcf.services.IFileSystem.DoneRoots;
+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.runtime.callback.Callback;
+import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
* FSRefresh refreshes a specified tree node and its children and grand children recursively.
*/
-public class OpRefresh extends Operation {
- //The root node to be refreshed.
- FSTreeNode node;
-
- /**
- * Create an FSRefresh to refresh the specified node and its descendants.
- *
- * @param node The root node to be refreshed.
- */
- public OpRefresh(FSTreeNode node) {
- this.node = node;
+public class OpRefresh extends AbstractOperation {
+ static final FSTreeNode[] NO_CHILDREN = {};
+ private static Map<FSTreeNode, TCFResult<?>> fPendingResults = new HashMap<FSTreeNode, TCFResult<?>>();
+
+ final LinkedList<FSTreeNode> fWork = new LinkedList<FSTreeNode>();
+ final boolean fRecursive;
+ private long fStartTime;
+
+ public OpRefresh(FSTreeNode node, boolean recursive) {
+ fWork.add(node);
+ fRecursive = recursive;
}
- /**
- * Create an FSRefresh to refresh the specified nodes and its descendants.
- *
- * @param nodes The node list to be refreshed.
- */
- public OpRefresh(List<FSTreeNode> nodes) {
- this.node = getAncestor(nodes);
+ public OpRefresh(List<IFSTreeNode> nodes, boolean recursive) {
+ fRecursive = recursive;
+ for (IFSTreeNode node : nodes) {
+ if (node instanceof FSTreeNode) {
+ fWork.add((FSTreeNode) node);
+ }
+ }
}
- /*
- * (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 {
- super.run(monitor);
- if (node != null && (node.childrenQueried || node.isFile())) {
- IChannel channel = null;
- try {
- channel = openChannel(node.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- refresh(node, service);
- }
- else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, node.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
+ public IStatus doRun(IProgressMonitor monitor) {
+ FSTreeNode needsNotification = null;
+ FSTreeNode trigger = fWork.peek();
+ fStartTime = System.currentTimeMillis();
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+ while (!fWork.isEmpty()) {
+ FSTreeNode node = fWork.remove();
+ boolean isTop = trigger == node;
+ if (isTop) {
+ if (needsNotification != null) {
+ needsNotification.notifyChange();
}
+ needsNotification = node;
+ trigger = fWork.peek();
}
- catch (TCFException e) {
- throw new InvocationTargetException(e, e.getMessage());
- }
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- monitor.done();
+ IStatus s = refreshNode(node, isTop, monitor);
+ if (!s.isOK()) {
+ if (needsNotification != null)
+ needsNotification.notifyChange();
+ return s;
}
}
- else {
- monitor.done();
- }
+ if (needsNotification != null)
+ needsNotification.notifyChange();
+ return Status.OK_STATUS;
}
- /**
- * Refresh the specified node and its children recursively using the file system service.
- *
- * @param node The node to be refreshed.
- * @param service The file system service.
- * @throws TCFFileSystemException Thrown during refreshing.
- */
- void refresh(final FSTreeNode node, final IFileSystem service) throws InterruptedException {
- if(monitor.isCanceled()) throw new InterruptedException();
- if ((node.isSystemRoot() || node.isDirectory()) && node.childrenQueried) {
- if (!node.isSystemRoot()) {
- try {
- updateChildren(node, service);
+ private IStatus refreshNode(final FSTreeNode node, final boolean isTop, IProgressMonitor monitor) {
+ if (node.getLastRefresh() >= fStartTime) {
+ FSTreeNode[] children = node.getChildren();
+ if (children != null) {
+ for (FSTreeNode child : children) {
+ fWork.addFirst(child);
}
- catch (TCFException e) {
- }
- }
- monitor.worked(1);
- List<FSTreeNode> children = node.getChildren();
- for (FSTreeNode child : children) {
- refresh(child, service);
}
+ return Status.OK_STATUS;
}
- else if(node.isFile()) {
- node.refresh();
+
+ boolean isDir = node.isDirectory();
+ boolean isFile = node.isFile();
+
+ if (!node.isFileSystem() && !isDir && !isFile)
+ return Status.OK_STATUS;
+
+ final Rendezvous rendezvous;
+ if (!isTop) {
+ rendezvous = null;
+ if (isFile || node.getChildren() == null)
+ return Status.OK_STATUS;
+ } else {
+ if (isFile) {
+ FileState digest = PersistenceManager.getInstance().getFileDigest(node);
+ rendezvous = new Rendezvous();
+ digest.updateState(new Callback(){
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ rendezvous.arrive();
+ }
+ });
+ } else {
+ rendezvous = null;
+ }
}
- }
+ monitor.subTask(format(Messages.OpRefresh_name, node.getLocation()));
+ IStatus status;
+ synchronized (fPendingResults) {
+ TCFResult<?> result = fPendingResults.get(node);
+ if (result == null) {
+ result = new TCFResult<Object>(false);
+ fPendingResults.put(node, result);
+ scheduleTcfRefresh(node, isTop, result);
+ }
+ status = result.waitDone(monitor);
+ if (!result.hasWaiters()) {
+ result.setCancelled();
+ fPendingResults.remove(node);
+ }
+ }
- /**
- * Update the children of the specified folder node using the file system service.
- *
- * @param node The folder node.
- * @param service The file system service.
- * @throws TCFFileSystemException Thrown during querying the children nodes.
- */
- protected void updateChildren(final FSTreeNode node, final IFileSystem service) throws TCFFileSystemException, InterruptedException {
- if(monitor.isCanceled()) throw new InterruptedException();
- List<FSTreeNode> current = node.getChildren();
- List<FSTreeNode> latest = queryChildren(node, service);
- List<FSTreeNode> newNodes = diff(latest, current);
- List<FSTreeNode> deleted = diff(current, latest);
- node.removeChildren(deleted);
- node.addChidren(newNodes);
+ if (rendezvous != null) {
+ try {
+ rendezvous.waiting(10000);
+ } catch (TimeoutException e) {
+ }
+ }
+ return status;
}
- /**
- * Find those nodes which are in aList yet not in bList and return them as a list.
- *
- * @param aList
- * @param bList
- * @return the difference list.
- */
- private List<FSTreeNode> diff(List<FSTreeNode> aList, List<FSTreeNode> bList) {
- List<FSTreeNode> newList = new ArrayList<FSTreeNode>();
- for (FSTreeNode aNode : aList) {
- boolean found = false;
- for (FSTreeNode bNode : bList) {
- if (aNode.name.equals(bNode.name)) {
- found = true;
- break;
+ private void scheduleTcfRefresh(final FSTreeNode node, final boolean isTop, final TCFResult<?> result) {
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ if (node.isFileSystem()) {
+ tcfRefreshRoots(node, result);
+ } else if (isTop && !node.isRootDirectory()) {
+ tcfStatAndRefresh(node, result);
+ } else {
+ tcfRefreshDir(node, result);
}
}
- if (!found) {
- newList.add(aNode);
+ });
+ }
+
+ protected void tcfStatAndRefresh(final FSTreeNode node, final TCFResult<?> result) {
+ if (!result.checkCancelled()) {
+ final IFileSystem fs = node.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ return;
}
+
+ fs.stat(node.getLocation(true), new DoneStat() {
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ handleFSError(node, Messages.OpRefresh_errorReadAttributes, error, result);
+ } else {
+ node.setAttributes(attrs, false);
+ if (!attrs.isDirectory()) {
+ node.operationDownload(new OutputStream() {
+ @Override
+ public void write(int b) {}
+ }).runInJob(new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ result.setDone(null);
+ }
+ });
+ result.setDone(null);
+ } else if (!result.checkCancelled()){
+ tcfRefreshDir(node, result);
+ }
+ }
+ }
+ });
}
- return newList;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
- @Override
- public String getName() {
- return NLS.bind(Messages.OpRefresh_RefreshJobTitle, node == null ? "" : node.name); //$NON-NLS-1$
- }
+ protected void tcfRefreshRoots(final FSTreeNode node, final TCFResult<?> result) {
+ if (!result.checkCancelled()) {
+ final IFileSystem fs = node.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ return;
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return count(node);
+ fs.roots(new DoneRoots() {
+ @Override
+ public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) {
+ if (error != null) {
+ result.setError(format(Messages.OpRefresh_errorGetRoots, node.getRuntimeModel().getName()), error);
+ } else if (!result.checkCancelled()) {
+ int i = 0;
+ FSTreeNode[] nodes = new FSTreeNode[entries.length];
+ for (DirEntry entry : entries) {
+ nodes[i++] = new FSTreeNode(node, entry.filename, true, entry.attrs);
+ }
+ node.setContent(nodes, false);
+ if (fRecursive) {
+ for (FSTreeNode node : nodes) {
+ fWork.addFirst(node);
+ }
+ }
+ result.setDone(null);
+ }
+ }
+ });
+ }
}
- /**
- * Count the nodes that should be refreshed under
- * the specified directory.
- *
- * @param node The specified directory.
- * @return the total count of the qualified nodes.
- */
- private int count(FSTreeNode node) {
- if ((node.isSystemRoot() || node.isDirectory()) && node.childrenQueried) {
- int total = 1;
- List<FSTreeNode> children = node.getChildren();
- for (FSTreeNode child : children) {
- total += count(child);
+ protected void tcfRefreshDir(final FSTreeNode node, final TCFResult<?> result) {
+ if (!result.checkCancelled()) {
+ final String path = node.getLocation(true);
+ final IFileSystem fs = node.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ return;
}
- return total;
+
+ tcfReadDir(fs, path, new IReadDirDone() {
+ @Override
+ public void error(FileSystemException error) {
+ result.setError(format(Messages.OpRefresh_errorOpenDir, path), error);
+ }
+
+ @Override
+ public boolean checkCancelled() {
+ return result.checkCancelled();
+ }
+
+ @Override
+ public void done(List<DirEntry> entries) {
+ int i = 0;
+ FSTreeNode[] nodes = new FSTreeNode[entries.size()];
+ for (DirEntry entry : entries) {
+ nodes[i++] = new FSTreeNode(node, entry.filename, false, entry.attrs);
+ }
+ node.setContent(nodes, false);
+ if (fRecursive) {
+ for (FSTreeNode node : nodes) {
+ fWork.addFirst(node);
+ }
+ }
+ result.setDone(null);
+ }
+ });
+ }
+ }
+
+ protected void handleFSError(final FSTreeNode node, String msg, FileSystemException error, final TCFResult<?> result) {
+ int status = error.getStatus();
+ if (status == IFileSystem.STATUS_NO_SUCH_FILE) {
+ node.getParent().removeNode(node, true);
+ result.setDone(null);
+ } else {
+ node.setContent(NO_CHILDREN, false);
+ result.setDone(null);
}
- return 0;
}
+
+ @Override
+ public String getName() {
+ return NLS.bind(Messages.OpRefresh_name, ""); //$NON-NLS-1$
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefreshRoots.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefreshRoots.java
deleted file mode 100644
index 6470c6e12..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefreshRoots.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2014 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;
-
-/**
- * The file operation class to create the root node in the file system of Target Explorer.
- */
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.services.IFileSystem.DirEntry;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-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.model.FSTreeNode;
-
-/**
- * The operation to refresh the root of the file system.
- */
-public class OpRefreshRoots extends Operation {
- /* default */FSTreeNode root;
-
- /**
- * Create an instance using the peer model.
- *
- * @param peerModel The peer model.
- */
- public OpRefreshRoots(FSTreeNode root) {
- this.root = root;
- }
-
- /*
- * (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 {
- super.run(monitor);
- IChannel channel = null;
- try {
- channel = openChannel(root.peerNode.getPeer());
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- root.queryStarted();
- service.roots(new IFileSystem.DoneRoots() {
- @Override
- public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) {
- if (error == null) {
- for (DirEntry entry : entries) {
- FSTreeNode node = new FSTreeNode(root, entry, true);
- root.addChild(node);
- }
- }
- }
- });
- // Reset the children query markers
- root.queryDone();
- }
- }
- catch(TCFChannelException e) {
- throw new InvocationTargetException(e);
- }
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java
index f7a0661c5..3bc9e4f9a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRename.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,115 +9,81 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
+import static java.text.MessageFormat.format;
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.DoneRename;
import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-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.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
* FSRename renames the specified file/folder to a
* new name.
*
*/
-public class OpRename extends Operation {
- // The file/folder node to be renamed.
+public class OpRename extends AbstractOperation {
FSTreeNode node;
- // The new name the file/folder is renamed to.
String newName;
- /**
- * Create a rename operation that renames the node with the new name.
- *
- * @param node The file/folder node to be renamed.
- * @param newName The new name of this node.
- */
public OpRename(FSTreeNode node, String newName) {
this.node = node;
this.newName = newName;
}
- /*
- * (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 {
- super.run(monitor);
- IChannel channel = null;
- try {
- channel = openChannel(node.peerNode.getPeer());
- if (channel != null) {
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- renameNode(service);
- }
- else {
- String message = NLS.bind(Messages.Operation_NoFileSystemError, node.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
+ public IStatus doRun(IProgressMonitor monitor) {
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+
+ CacheManager.clearCache(node);
+ final TCFResult<?> result = new TCFResult<Object>();
+ monitor.subTask(NLS.bind(Messages.OpMove_Moving, node.getLocation()));
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ tcfRename(result);
}
- }
- catch (TCFException e) {
- throw new InvocationTargetException(e, e.getMessage());
- }
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- monitor.done();
- }
+ });
+ return result.waitDone(monitor);
}
-
- /**
- * Rename the node using the new name.
- *
- * @param service File system service used to rename.
- * @throws TCFFileSystemException The exception thrown during renaming.
- */
- void renameNode(IFileSystem service) throws TCFFileSystemException {
- String src_path = node.getLocation(true);
- String oldName = node.name;
- node.name = newName;
- String dst_path = node.getLocation(true);
- node.name = oldName;
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- service.rename(src_path, dst_path, new DoneRename() {
+
+
+ protected void tcfRename(final TCFResult<?> result) {
+ if (result.checkCancelled())
+ return;
+
+ final IFileSystem fileSystem = node.getRuntimeModel().getFileSystem();
+ if (fileSystem == null) {
+ result.setCancelled();
+ return;
+ }
+
+ CacheManager.clearCache(node);
+
+ final String sourcePath = node.getLocation(true);
+ final String destPath = getPath(node.getParent(), newName);
+
+ fileSystem.rename(sourcePath, destPath, new DoneRename() {
@Override
public void doneRename(IToken token, FileSystemException error) {
if (error != null) {
- String message = NLS.bind(Messages.OpRename_CannotRename, node.name, error);
- errors[0] = new TCFFileSystemException(IStatus.ERROR, message, error);
- }
- else {
- final File file = CacheManager.getCacheFile(node);
- if (node.isFile() && file.exists()) {
- PersistenceManager.getInstance().removeFileDigest(node.getLocationURI());
- }
- deleteFileChecked(file);
- node.setName(newName);
+ result.setError(format(Messages.OpMove_CannotMove, sourcePath), error);
+ } else {
+ FSTreeNode parent = node.getParent();
+ parent.removeNode(node, true);
+ node.changeName(newName);
+ parent.addNode(node, true);
+ result.setDone(null);
}
}
});
- monitor.worked(1);
- if (errors[0] != null) {
- throw errors[0];
- }
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
+
@Override
public String getName() {
return Messages.OpRename_TitleRename;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpStreamOp.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpStreamOp.java
deleted file mode 100644
index c2768a6e1..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpStreamOp.java
+++ /dev/null
@@ -1,74 +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.filesystem.core.internal.operations;
-
-import java.io.File;
-import java.text.DecimalFormat;
-
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * The operation class that streams file upward downward. It is the base
- * class for uploading, downloading, cache update and commit.
- */
-public abstract class OpStreamOp extends Operation {
- // The formatter used to format the size displayed while downloading.
- protected static final DecimalFormat SIZE_FORMAT = new DecimalFormat("#,##0.##"); //$NON-NLS-1$
- // The default chunk size of the buffer used during downloading files.
- public static final int DEFAULT_CHUNK_SIZE = 5 * 1024;
-
- /**
- * Check if the file exists and set its read-only attribute if it does. Record
- * the failure message if it fails.
- *
- * @param file The file to be set.
- */
- protected void setReadOnlyChecked(final File file) {
- if (file.exists()) {
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void run() throws Exception {
- if (!file.setReadOnly()) {
- throw new Exception(NLS.bind(Messages.OpStreamOp_SetReadOnlyFailed, file.getAbsolutePath()));
- }
- }
-
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }});
- }
- }
-
- /**
- * Use the SIZE_FORMAT to format the file's size. The rule is: 1. If the
- * size is less than 1024 bytes, then show it as "####" bytes. 2. If the
- * size is less than 1024 KBs, while more than 1 KB, then show it as
- * "####.##" KBs. 3. If the size is more than 1 MB, then show it as
- * "####.##" MBs.
- *
- * @param size
- * The file size to be displayed.
- * @return The string representation of the size.
- */
- protected String formatSize(long size) {
- double kbSize = size / 1024.0;
- if (kbSize < 1.0) {
- return SIZE_FORMAT.format(size) + Messages.OpStreamOp_Bytes;
- }
- double mbSize = kbSize / 1024.0;
- if (mbSize < 1.0)
- return SIZE_FORMAT.format(kbSize) + Messages.OpStreamOp_KBs;
- return SIZE_FORMAT.format(mbSize) + Messages.OpStreamOp_MBs;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java
index 328acbd3a..6d8d23aaa 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpTargetFileDigest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -9,54 +9,71 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
+import static java.text.MessageFormat.format;
+
import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
+import java.io.InputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.services.IFileSystem.DoneOpen;
+import org.eclipse.tcf.services.IFileSystem.FileSystemException;
+import org.eclipse.tcf.services.IFileSystem.IFileHandle;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.StatusHelper;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+import org.eclipse.tcf.util.TCFFileInputStream;
/**
* The operation that computes the digest of the cache file in the background.
*/
-public class OpTargetFileDigest implements IOperation {
- // The digest of which is going to be computed.
+public class OpTargetFileDigest extends AbstractOperation {
FSTreeNode node;
- // The computing result
byte[] digest;
- /**
- * Create an operation to compute the digest of its target file.
- *
- * @param node The file system node.
- */
public OpTargetFileDigest(FSTreeNode node) {
this.node = node;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
+
@Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- BufferedInputStream input = null;
+ public IStatus doRun(IProgressMonitor monitor) {
+ long totalSize = node.getSize();
+ monitor.beginTask(getName(), 100);
+
+ final String path = node.getLocation(true);
+ final TCFResult<InputStream> result = new TCFResult<InputStream>();
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ IFileSystem fs = node.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ } else {
+ tcfGetInputStream(fs, path, result);
+ }
+ }
+ });
+ IStatus status = result.waitDone(monitor);
+ if (!status.isOK())
+ return status;
+
+ InputStream in = new BufferedInputStream(result.getValue());
try {
- long totalSize = node.attr.size;
int chunk_size = (int) totalSize / 100;
int percentRead = 0;
long bytesRead = 0;
- URL url = node.getLocationURL();
MessageDigest digest = MessageDigest.getInstance(MD_ALG);
- input = new BufferedInputStream(new DigestInputStream(url.openStream(), digest));
+ in = new DigestInputStream(in, digest);
// The buffer used to download the file.
- byte[] data = new byte[OpStreamOp.DEFAULT_CHUNK_SIZE];
+ byte[] data = new byte[DEFAULT_CHUNK_SIZE];
int length;
- while ((length = input.read(data)) >= 0){
+ while ((length = in.read(data)) >= 0){
bytesRead += length;
if (chunk_size != 0) {
int percent = (int) bytesRead / chunk_size;
@@ -65,46 +82,46 @@ public class OpTargetFileDigest implements IOperation {
percentRead = percent; // Remember the percentage.
}
}
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
}
this.digest = digest.digest();
- }
- catch (NoSuchAlgorithmException e) {
- throw new InvocationTargetException(e);
- }
- catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- finally {
- if (input != null) {
- try {input.close();} catch (Exception e) {}
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return StatusHelper.createStatus(format(Messages.OpTargetFileDigest_error_download, path), e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (Exception e) {
+ }
}
}
}
-
- /**
- * Get the computing result.
- *
- * @return The message digest of this cache file.
- */
+
+ protected void tcfGetInputStream(IFileSystem fileSystem, final String path, final TCFResult<InputStream> result) {
+ int flags = IFileSystem.TCF_O_READ;
+ if (!result.checkCancelled()) {
+ fileSystem.open(path, flags, null, new DoneOpen() {
+ @Override
+ public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
+ if (error != null) {
+ result.setError(format(Messages.OpTargetFileDigest_error_openFile, path), error);
+ } else {
+ result.setDone(new TCFFileInputStream(handle));
+ }
+ }
+ });
+ }
+ }
+
+
public byte[] getDigest() {
return digest;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
@Override
public String getName() {
return "Update target digest"; //$NON-NLS-1$
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return 100;
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java
index 54e20fcd9..47223fec8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUpload.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,423 +9,291 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
+import static java.text.MessageFormat.format;
+
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.LinkedList;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.services.IFileSystem.DoneOpen;
+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.services.IFileSystem.IFileHandle;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+import org.eclipse.tcf.util.TCFFileOutputStream;
/**
- * Upload multiple files from local system to a remote system.
+ * Upload multiple files from local system to a remote system.
*/
-public class OpUpload extends OpStreamOp {
- // The source files to be uploaded.
- File[] srcFiles;
- // The destination URLs to be uploaded to.
- URL[] dstURLs;
- // The confirm callback
- IConfirmCallback confirmCallback;
- // The parent folder map to search files that have same names.
- Map<File, FSTreeNode> parentFolders;
- // The files that are to be committed to its target file system.
- FSTreeNode[] nodes;
-
- /**
- * Constructor.
- *
- * @param srcFile The source file to be uploaded.
- * @param dstURL The destination URL.
- */
- public OpUpload(File srcFile, URL dstURL) {
- this(new File[]{srcFile}, new URL[]{dstURL});
- }
-
- /**
- * Constructor.
- *
- * @param srcFiles The source files to be uploaded.
- * @param dstURLs The destination URLs.
- */
- public OpUpload(File[] srcFiles, URL[] dstURLs) {
- this(srcFiles, dstURLs, null);
+public class OpUpload extends AbstractOperation {
+ private static class WorkItem {
+ final File fSource;
+ final FSTreeNode fDestination;
+ final boolean fDropToDestination;
+ WorkItem(File source, FSTreeNode destination, boolean isDrop) {
+ fSource = source;
+ fDestination = destination;
+ fDropToDestination = isDrop;
+ }
}
-
- /**
- * Constructor.
- *
- * @param sourceFiles The source files in the native file system to be uploaded.
- * @param targetFolder The taret parent folder to upload these files to.
- */
- public OpUpload(String[]sourceFiles, FSTreeNode targetFolder) {
- this(sourceFiles, targetFolder, null);
+
+ IConfirmCallback fConfirmCallback;
+
+ LinkedList<WorkItem> fWork = new LinkedList<WorkItem>();
+ private long fStartTime;
+
+ public OpUpload(IConfirmCallback confirm) {
+ fConfirmCallback = confirm;
}
-
- /**
- * Constructor.
- *
- * @param sourceFiles The source files in the native file system to be uploaded.
- * @param targetFolder The target parent folder to upload these files to.
- * @param confirmCallback the confirmation callback to confirm overwriting.
- */
- public OpUpload(File[] srcFiles, URL[] dstURLs, IConfirmCallback confirmCallback) {
- this.srcFiles = srcFiles;
- this.dstURLs = dstURLs;
- this.confirmCallback = confirmCallback;
+
+ public void addUpload(File source, FSTreeNode destinationFile) {
+ fWork.add(new WorkItem(source, destinationFile, false));
}
-
- /**
- * Constructor that upload the local cache files of the specified nodes.
- *
- * @param nodes The nodes to be uploaded.
- */
- public OpUpload(FSTreeNode... nodes) {
- srcFiles = new File[nodes.length];
- dstURLs = new URL[nodes.length];
- for (int i = 0; i < nodes.length; i++) {
- srcFiles[i] = CacheManager.getCacheFile(nodes[i]);
- dstURLs[i] = nodes[i].getLocationURL();
- }
- this.nodes = nodes;
+
+ public void addDrop(File source, FSTreeNode destiniationFolder) {
+ fWork.add(new WorkItem(source, destiniationFolder, true));
}
-
- /**
- * Create an instance with specified files, target folder and a callback.
- *
- * @param sourceFiles the source files being uploaded.
- * @param targetFolder the target folder to upload the files to.
- * @param callback the callback that is invoked after uploading.
- */
- public OpUpload(String[] sourceFiles, FSTreeNode targetFolder, IConfirmCallback confirmCallback) {
- this.confirmCallback = confirmCallback;
- List<File> fileList = new ArrayList<File>();
- List<URL> urlList = new ArrayList<URL>();
- prepareDirStruct(sourceFiles, fileList, urlList, targetFolder);
- srcFiles = fileList.toArray(new File[fileList.size()]);
- dstURLs = urlList.toArray(new URL[urlList.size()]);
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.operations.FSOperation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
@Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- super.run(monitor);
- try {
- uploadFiles(srcFiles, dstURLs);
- if(monitor.isCanceled()) throw new InterruptedException();
- } catch (MalformedURLException e) {
- throw new InvocationTargetException(e);
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
+ public IStatus doRun(IProgressMonitor monitor) {
+ fStartTime = System.currentTimeMillis();
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+ while (!fWork.isEmpty()) {
+ IStatus s = runWorkItem(fWork.remove(), monitor);
+ if (!s.isOK())
+ return s;
}
- }
- /**
- * Test if the specified file should be confirmed.
- *
- * @param file The file to be confirmed.
- * @return true if it is.
- */
- private boolean requireConfirmation(File file) {
- return parentFolders != null && confirmCallback != null && !yes2All && confirmCallback.requires(file) && findNode(file) != null;
+ return Status.OK_STATUS;
}
-
- /**
- * Upload the specified file list to the specified locations, reporting the progress
- * using the specified monitor.
- *
- * @param files The file list to be uploaded.
- * @param urls The
- * @param monitor
- * @throws IOException
- */
- private void uploadFiles(File[] files, URL[] urls) throws IOException {
- // The buffer used to download the file.
- byte[] data = new byte[DEFAULT_CHUNK_SIZE];
- // Calculate the total size.
- long totalSize = 0;
- for (File file:files) {
- totalSize += file.length();
- }
- // Calculate the chunk size of one percent.
- int chunk_size = (int) totalSize / 100;
- // The current reading percentage.
- int percentRead = 0;
- // The current length of read bytes.
- long bytesRead = 0;
- for (int i = 0; i < files.length && !monitor.isCanceled(); i++) {
- File file = files[i];
- if (requireConfirmation(file)) {
- int result = confirmCallback.confirms(file);
- switch (result) {
- case IConfirmCallback.YES:
- break;
- case IConfirmCallback.YES_TO_ALL:
- yes2All = true;
- break;
- case IConfirmCallback.NO:
- bytesRead += file.length();
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- // Report the progress.
- monitor.subTask(NLS
- .bind(Messages.OpUpload_UploadingProgress, new Object[] { file
- .getName(), formatSize(bytesRead), formatSize(file
- .length()) }));
- }
+
+ protected IStatus runWorkItem(final WorkItem item, IProgressMonitor monitor) {
+ final String path;
+ final FSTreeNode destination = item.fDestination;
+ FSTreeNode existing;
+ final String name;
+ final File source = item.fSource;
+ if (item.fDropToDestination) {
+ IStatus status = refresh(destination, fStartTime, monitor);
+ if (!status.isOK())
+ return status;
+
+ name = item.fSource.getName();
+ existing = destination.findChild(name);
+
+ if (source.isDirectory()) {
+ if (existing != null) {
+ if (!existing.isDirectory()) {
+ return StatusHelper.createStatus(format(Messages.OpCopy_error_noDirectory, existing.getLocation()), null);
}
- continue;
- case IConfirmCallback.CANCEL:
- monitor.setCanceled(true);
- continue;
- }
- }
- BufferedInputStream input = null;
- BufferedOutputStream output = null;
- MessageDigest digest = null;
- try {
- URL url = urls[i];
- TcfURLConnection connection = (TcfURLConnection) url.openConnection();
- connection.setDoInput(false);
- connection.setDoOutput(true);
- if (nodes != null) {
- try {
- digest = MessageDigest.getInstance(MD_ALG);
- input = new BufferedInputStream(new DigestInputStream(new FileInputStream(file), digest));
- }
- catch (NoSuchAlgorithmException e) {
- input = new BufferedInputStream(new FileInputStream(file));
- }
- }
- else {
- input = new BufferedInputStream(new FileInputStream(file));
+ int replace = confirmCallback(existing, fConfirmCallback);
+ if (replace == IConfirmCallback.NO) {
+ return Status.OK_STATUS;
+ }
+ if (replace != IConfirmCallback.YES) {
+ return Status.CANCEL_STATUS;
+ }
+ } else {
+ status = destination.operationNewFolder(name).run(new SubProgressMonitor(monitor, 0));
+ if (!status.isOK())
+ return status;
+ existing = destination.findChild(name);
}
- output = new BufferedOutputStream(connection.getOutputStream());
- // Total size displayed on the progress dialog.
- String fileLength = formatSize(file.length());
- int length;
- while ((length = input.read(data)) >= 0 && !monitor.isCanceled()) {
- output.write(data, 0, length);
- output.flush();
- bytesRead += length;
- if (chunk_size != 0) {
- int percent = (int) bytesRead / chunk_size;
- if (percent != percentRead) { // Update the progress.
- monitor.worked(percent - percentRead);
- percentRead = percent; // Remember the percentage.
- // Report the progress.
- monitor.subTask(NLS.bind(Messages.OpUpload_UploadingProgress, new Object[]{file.getName(), formatSize(bytesRead), fileLength}));
- }
- }
+ for (File child : source.listFiles()) {
+ fWork.addFirst(new WorkItem(child, existing, true));
}
- } finally {
- if (output != null) {
- try {
- output.close();
- } catch (Exception e) {
+ return Status.OK_STATUS;
+ } else if (source.isFile()) {
+ if (existing != null) {
+ if (!existing.isFile()) {
+ return StatusHelper.createStatus(format(Messages.OpCopy_error_noFile, existing.getLocation()), null);
}
- }
- if (input != null) {
- try {
- input.close();
- } catch (Exception e) {
+ int replace = confirmCallback(existing, fConfirmCallback);
+ if (replace == IConfirmCallback.NO) {
+ return Status.OK_STATUS;
+ }
+ if (replace != IConfirmCallback.YES) {
+ return Status.CANCEL_STATUS;
}
}
- if(digest != null && nodes != null) {
- FileState filedigest = PersistenceManager.getInstance().getFileDigest(nodes[i]);
- filedigest.reset(digest.digest());
- }
+ path = getPath(destination, name);
+ } else {
+ return Status.OK_STATUS;
}
+ } else {
+ name = destination.getName();
+ existing = destination;
+ path = destination.getLocation(true);
}
- }
- /**
- * Prepare the directory structure on the remote target, creating necessary intermediate directories
- * and found all files that should be uploaded. The resulting files to be uploaded should be stored
- * to the file list. The resulting corresponding target file URLs should be stored in the url list.
- *
- * @param fileList The file list to store the files that should be uploaded.
- * @param urlList The list containing the corresponding urls.
- */
- private void prepareDirStruct(String[] sourceFiles, List<File> fileList, List<URL> urlList, FSTreeNode targetFolder) {
- parentFolders = Collections.synchronizedMap(new HashMap<File, FSTreeNode>());
- List<File> files = new ArrayList<File>();
- for(String path: sourceFiles) {
- files.add(new File(path));
- }
- // Find the root nodes of these files.
- List<File> topFiles = getTopFiles(files);
- for(File topFile : topFiles) {
- appendFile(topFile, fileList, urlList, targetFolder);
- }
- }
-
- /**
- * Append the specified file object to the file list and url list. If the file object is a file
- * then append it to the two lists. If the file object is a directory, then recursively
- * add its children and grand children to the two list. During this process, the parents of
- * these files and directories traversed should be put into the parent folders map so that
- * it could be queried to check if it has a file/directory with a same name.
- *
- * @param file The file to be added
- * @param fileList The file list
- * @param urlList The url list
- * @param parent The current parent node
- */
- private void appendFile(final File file, final List<File> fileList, final List<URL> urlList, final FSTreeNode parent) {
- parentFolders.put(file, parent);
- if(file.isFile()) {
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void run() throws Exception {
- URL folderURL = parent.getLocationURL();
- URL url = new URL(folderURL, file.getName());
- fileList.add(file);
- urlList.add(url);
- }
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }});
- } else if(file.isDirectory()) {
- FSTreeNode node = findNode(file);
- if(node == null) {
- OpCreateFolder create = new OpCreateFolder(parent, file.getName());
- new NullOpExecutor().execute(create);
- node = create.getNode();
- }
- File[] children = file.listFiles();
- for(File child : children) {
- appendFile(child, fileList, urlList, node);
+ final TCFResult<OutputStream> result = new TCFResult<OutputStream>();
+ monitor.subTask(NLS.bind(Messages.OpUpload_UploadSingleFile, item.fSource));
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ IFileSystem fs = destination.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ result.setCancelled();
+ } else {
+ tcfGetOutputStream(fs, path, result);
+ }
}
- }
- }
+ });
+ IStatus status = result.waitDone(monitor);
+ if (!status.isOK())
+ return status;
- /**
- * Get the root files of the specified files/folders in the list.
- *
- * @param files The files to be checked.
- * @return Root nodes of these files that has no parent.
- */
- private List<File> getTopFiles(List<File>files) {
- List<File> result = new ArrayList<File>();
- for(File file : files) {
- if(!hasFileAncestor(file, files)) {
- result.add(file);
+ OutputStream out = new BufferedOutputStream(result.getValue());
+ try {
+ IStatus s = uploadFile(item.fSource, existing, out, new SubProgressMonitor(monitor, 0));
+ if (!s.isOK())
+ return s;
+ } finally {
+ try {
+ out.close();
+ } catch (IOException e) {
}
}
- return result;
- }
- /**
- * Check if the target file has an ancestral parent in the specified list.
- *
- * @param target The target file to be checked.
- * @param files The file list to be searched.
- * @return true if it has an ancestral parent.
- */
- private boolean hasFileAncestor(File target, List<File> files) {
- for(File file : files) {
- if(isFileAncestor(file, target)) {
- return true;
+ return updateNode(path, name, destination, existing, monitor);
+ }
+
+ private IStatus updateNode(final String path, final String name,
+ final FSTreeNode destination, final FSTreeNode existing, IProgressMonitor monitor) {
+ final TCFResult<?> r2 = new TCFResult<Object>();
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ IFileSystem fs = destination.getRuntimeModel().getFileSystem();
+ if (fs == null) {
+ r2.setCancelled();
+ } else if (!r2.checkCancelled()) {
+ fs.stat(path, new DoneStat() {
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ if (error != null) {
+ r2.setError(format(Messages.OpUpload_error_upload, name), error);
+ } else if (!r2.checkCancelled()) {
+ if (existing != null) {
+ existing.setAttributes(attrs, true);
+ } else {
+ destination.addNode(new FSTreeNode(destination, name, false, attrs), true);
+ }
+ r2.setDone(null);
+ }
+ }
+ });
+ }
}
+ });
+ return r2.waitDone(monitor);
+ }
+
+ protected void tcfGetOutputStream(IFileSystem fileSystem, final String path, final TCFResult<OutputStream> result) {
+ int flags = IFileSystem.TCF_O_WRITE | IFileSystem.TCF_O_CREAT | IFileSystem.TCF_O_TRUNC;
+ if (!result.checkCancelled()) {
+ fileSystem.open(path, flags, null, new DoneOpen() {
+ @Override
+ public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
+ if (error != null) {
+ result.setError(format(Messages.OpUpload_error_openFile, path), error);
+ } else {
+ result.setDone(new TCFFileOutputStream(handle));
+ }
+ }
+ });
}
- return false;
- }
+ }
- /**
- * Check if the specified "file" is an ancestral parent of the "target" file.
- *
- * @param file The ancestral file.
- * @param target The target file.
- * @return true if "file" is an ancestral parent of "target"
- */
- private boolean isFileAncestor(File file, File target) {
- if(target == null) return false;
- File parent = target.getParentFile();
- if(file.equals(parent)) return true;
- return isFileAncestor(file, parent);
- }
+ private IStatus uploadFile(File source, FSTreeNode existing, OutputStream output, IProgressMonitor monitor) {
+ byte[] data = new byte[DEFAULT_CHUNK_SIZE];
+ // Calculate the total size.
+ long totalSize = source.length();
+ // Calculate the chunk size of one percent.
+ int chunk_size = (int) totalSize / 100;
+ // The current reading percentage.
+ int percentRead = 0;
+ // The current length of read bytes.
+ long bytesRead = 0;
+ MessageDigest digest = null;
+ InputStream input = null;
+ try {
+ input = new BufferedInputStream(new FileInputStream(source));
+ if (existing != null) {
+ try {
+ digest = MessageDigest.getInstance(MD_ALG);
+ input = new DigestInputStream(input, digest);
+ } catch (NoSuchAlgorithmException e) {
+ digest = null;
+ }
+ }
- /**
- * Check if the specified file has a same-named file under its corresponding
- * parent folder.
- *
- * @param file The file to checked.
- * @return the node that has the same name with the file.
- */
- private FSTreeNode findNode(File file) {
- final FSTreeNode parent = parentFolders.get(file);
- if (parent != null) {
- final List<FSTreeNode> targetChildren = new ArrayList<FSTreeNode>();
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void run() throws Exception {
- targetChildren.addAll(getChildren(parent));
+ // Total size displayed on the progress dialog.
+ String fileLength = formatSize(totalSize);
+ int length;
+ while ((length = input.read(data)) >= 0) {
+ output.write(data, 0, length);
+ bytesRead += length;
+ if (chunk_size != 0) {
+ int percent = (int) bytesRead / chunk_size;
+ if (percent != percentRead) { // Update the progress.
+ monitor.worked(percent - percentRead);
+ percentRead = percent; // Remember the percentage.
+ // Report the progress.
+ if (fWork.size() == 0)
+ monitor.subTask(NLS.bind(Messages.OpUpload_UploadingProgress, new Object[]{source.getName(), formatSize(bytesRead), fileLength}));
+ }
}
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
+ }
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
+ if (digest != null && existing != null) {
+ FileState filedigest = PersistenceManager.getInstance().getFileDigest(existing);
+ filedigest.reset(digest.digest());
+ }
+ return Status.OK_STATUS;
+ } catch (IOException e) {
+ return StatusHelper.createStatus(format(Messages.OpUpload_error_upload, source), e);
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (Exception e) {
}
- });
- String name = file.getName();
- for (FSTreeNode child : targetChildren) {
- if (name.equals(child.name)) return child;
}
}
- return null;
- }
+ }
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
@Override
public String getName() {
String message;
- if(srcFiles.length==1)
- message = NLS.bind(Messages.OpUpload_UploadSingleFile, srcFiles[0].getName());
+ if(fWork.size()==1)
+ message = NLS.bind(Messages.OpUpload_UploadSingleFile, fWork.element().fSource);
else
- message = NLS.bind(Messages.OpUpload_UploadNFiles, Long.valueOf(srcFiles.length));
+ message = NLS.bind(Messages.OpUpload_UploadNFiles, Long.valueOf(fWork.size()));
return message;
}
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return 100;
- }
}
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
deleted file mode 100644
index 269f9b142..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpUser.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2014 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/operations/Operation.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java
deleted file mode 100644
index 117667b3e..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java
+++ /dev/null
@@ -1,618 +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.core.internal.operations;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.net.ConnectException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeoutException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IErrorReport;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.services.IFileSystem.DirEntry;
-import org.eclipse.tcf.services.IFileSystem.DoneMkDir;
-import org.eclipse.tcf.services.IFileSystem.DoneOpen;
-import org.eclipse.tcf.services.IFileSystem.DoneReadDir;
-import org.eclipse.tcf.services.IFileSystem.DoneRemove;
-import org.eclipse.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tcf.services.IFileSystem.IFileHandle;
-import org.eclipse.tcf.te.core.utils.Ancestor;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFChannelException;
-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.internal.utils.BlockingFileSystemProxy;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
-
-/**
- * Operation is the base class of file system operation classes.
- * @see IOperation
- */
-public class Operation extends Ancestor<FSTreeNode> implements IOperation {
- // The default timeout waiting for blocked invocations.
- public static final long DEFAULT_TIMEOUT = 60000L;
- // The flag indicating if the following action should be executed without asking.
- protected boolean yes2All = false;
-
- // The current progress monitor, probably null.
- protected IProgressMonitor monitor = new NullProgressMonitor();
-
- /**
- * Create an instance.
- */
- public Operation() {
- }
-
- /**
- * Create a TCFFileSystemException from a FileSystemException.
- *
- * @param error The FileSystemException
- * @return a TCFFileSystemException
- */
- protected TCFFileSystemException newTCFException(int severity, FileSystemException error) {
- String message = null;
- if(error instanceof IErrorReport) {
- IErrorReport report = (IErrorReport) error;
- message = (String)report.getAttributes().get(IErrorReport.ERROR_FORMAT);
- }
- return new TCFFileSystemException(severity, message, error);
- }
-
- /**
- * Clean up the folder node after moving, deleting or copying.
- *
- * @param node the folder node that is to be cleaned.
- */
- protected void cleanUpFolder(FSTreeNode node) {
- File file = CacheManager.getCacheFile(node);
- deleteFileChecked(file);
- FSTreeNode parent = node.getParent();
- if (parent != null) {
- parent.removeChild(node);
- }
- }
-
- /**
- * Check if the file exists and delete if it does. Record
- * the failure message if deleting fails.
- *
- * @param file The file to be deleted.
- */
- protected void deleteFileChecked(final File file) {
- if (file.exists()) {
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void run() throws Exception {
- if (!file.delete()) {
- throw new Exception(NLS.bind(Messages.Operation_DeletingFileFailed, file.getAbsolutePath()));
- }
- }
-
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }});
- }
- }
-
- /**
- * Clean up the file node after moving, deleting or copying.
- *
- * @param node the file node that is to be cleaned.
- */
- protected void cleanUpFile(FSTreeNode node) {
- final File file = CacheManager.getCacheFile(node);
- deleteFileChecked(file);
- PersistenceManager.getInstance().removeFileDigest(node.getLocationURI());
- FSTreeNode parent = node.getParent();
- if (parent != null) {
- parent.removeChild(node);
- }
- }
-
- /**
- * Open a channel connected to the target represented by the peer.
- *
- * @return The channel or null if the operation fails.
- */
- public static IChannel openChannel(final IPeer peer) throws TCFChannelException {
- final TCFChannelException[] errors = new TCFChannelException[1];
- final IChannel[] channels = new IChannel[1];
- final Rendezvous rendezvous = new Rendezvous();
- Tcf.getChannelManager().openChannel(peer, null, new DoneOpenChannel() {
- @Override
- public void doneOpenChannel(Throwable error, IChannel channel) {
- if (error != null) {
- if (error instanceof ConnectException) {
- String message = NLS.bind(Messages.Operation_NotResponding, peer.getID());
- errors[0] = new TCFChannelException(IStatus.ERROR, message);
- }
- else if(!(error instanceof OperationCanceledException)) {
- String message = NLS.bind(Messages.Operation_OpeningChannelFailureMessage, peer.getID(), error.getMessage());
- errors[0] = new TCFChannelException(IStatus.OK, message, error);
- }
- }
- else {
- channels[0] = channel;
- }
- rendezvous.arrive();
- }
- });
- try {
- rendezvous.waiting(DEFAULT_TIMEOUT);
- }
- catch(TimeoutException e) {
- throw new TCFChannelException(IStatus.ERROR, Messages.Operation_TimeoutOpeningChannel);
- }
- if (errors[0] != null) {
- throw errors[0];
- }
- return channels[0];
- }
-
- /**
- * Get a blocking file system service from the channel. The
- * returned file system service is a service that delegates the
- * method call to the file system proxy. If the method returns
- * asynchronously with a callback, it will block the call until
- * the callback returns.
- * <p>
- * <em>Note: All the method of the returned file system
- * service must be called outside of the dispatching thread.</em>
- *
- * @param channel The channel to get the file system service.
- * @return The blocking file system service.
- */
- public static IFileSystem getBlockingFileSystem(final IChannel channel) {
- if(Protocol.isDispatchThread()) {
- IFileSystem service = channel.getRemoteService(IFileSystem.class);
- return new BlockingFileSystemProxy(service);
- }
- final IFileSystem[] service = new IFileSystem[1];
- Protocol.invokeAndWait(new Runnable(){
- @Override
- public void run() {
- service[0] = getBlockingFileSystem(channel);
- }});
- return service[0];
- }
-
- /**
- * Count the total nodes in the node list including their children and grand children
- * recursively.
- *
- * @param service The file system service used to open those folders that are not expanded yet.
- * @param nodes The node list to be counted.
- * @return The count of the total nodes.
- * @throws TCFFileSystemException Thrown when expanding the unexpanded folders.
- */
- protected int count(IFileSystem service, List<FSTreeNode> nodes) throws TCFFileSystemException, InterruptedException {
- int count = 0;
- for (FSTreeNode node : nodes) {
- if (node.isFile()) {
- count++;
- }
- else if (node.isDirectory()) {
- List<FSTreeNode> children = getChildren(node, service);
- count += count(service, children) + 1;
- }
- }
- return count;
- }
-
- /**
- * Get the children of the specified folder node. If the folder node is not expanded, then
- * expanded using the specified file system service.
- *
- * @param node The folder node.
- * @param service The file system service.
- * @return The children of the folder node.
- * @throws TCFFileSystemException Thrown during querying the children nodes.
- */
- protected List<FSTreeNode> getChildren(final FSTreeNode node, final IFileSystem service) throws TCFFileSystemException, InterruptedException {
- if (node.childrenQueried) {
- return node.getChildren();
- }
- loadChildren(node, service);
- return getChildren(node, service);
- }
-
- /**
- * Get the children the specified folder node. If the folder has not yet been loaded, then load it.
- *
- * @param node The folder node.
- * @return The children of the folder node.
- * @throws TCFException Thrown during querying the children nodes.
- */
- public List<FSTreeNode> getChildren(final FSTreeNode node) throws TCFException, InterruptedException {
- if(node.childrenQueried) {
- return node.getChildren();
- }
- IChannel channel = null;
- try {
- channel = openChannel(node.peerNode.getPeer());
- IFileSystem service = getBlockingFileSystem(channel);
- if (service != null) {
- return getChildren(node, service);
- }
- String message = NLS.bind(Messages.Operation_NoFileSystemError, node.peerNode.getPeerId());
- throw new TCFFileSystemException(IStatus.ERROR, message);
- }
- finally {
- if (channel != null) Tcf.getChannelManager().closeChannel(channel);
- }
- }
-
- /**
- * Load the children of the specified folder node using the file system service.
- *
- * @param node The folder node.
- * @param service The file system service.
- * @throws TCFFileSystemException Thrown during querying the children nodes.
- */
- protected void loadChildren(final FSTreeNode node, final IFileSystem service) throws TCFFileSystemException, InterruptedException {
- List<FSTreeNode> children = queryChildren(node, service);
- node.addChidren(children);
- node.queryDone();
- }
-
- /**
- * Query the children of the specified node using the file system service.
- *
- * @param node The folder node.
- * @param service The file system service.
- * @return The children of the folder node.
- * @throws TCFFileSystemException Thrown during querying the children nodes.
- */
- protected List<FSTreeNode> queryChildren(final FSTreeNode node, final IFileSystem service) throws TCFFileSystemException, InterruptedException {
- if(monitor.isCanceled()) throw new InterruptedException();
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- final IFileHandle[] handles = new IFileHandle[1];
- try {
- String dir = node.getLocation();
- service.opendir(dir, new DoneOpen() {
- @Override
- public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
- if (error != null) {
- String message = NLS.bind(Messages.Operation_CannotOpenDir, node.name, error);
- errors[0] = new TCFFileSystemException(IStatus.WARNING, message, error);
- }
- else {
- handles[0] = handle;
- }
- }
- });
- if (errors[0] != null) {
- throw errors[0];
- }
- errors[0] = null;
- final List<FSTreeNode> children = new ArrayList<FSTreeNode>();
- final boolean[] eofs = new boolean[1];
- while (!eofs[0]) {
- service.readdir(handles[0], new DoneReadDir() {
- @Override
- public void doneReadDir(IToken token, FileSystemException error, DirEntry[] entries, boolean eof) {
- if (eof) {
- eofs[0] = true;
- }
- if (error == null) {
- if (entries != null && entries.length > 0) {
- for (DirEntry entry : entries) {
- FSTreeNode childNode = new FSTreeNode(node, entry, false);
- children.add(childNode);
- }
- }
- }
- else {
- errors[0] = newTCFException(IStatus.INFO, error);
- }
- }
- });
- if (errors[0] != null) {
- throw errors[0];
- }
- }
- return children;
- }
- finally {
- if (handles[0] != null) {
- service.close(handles[0], new IFileSystem.DoneClose() {
- @Override
- public void doneClose(IToken token, FileSystemException error) {
- }
- });
- }
- }
- }
-
- /**
- * Remove the child from the children list of the specified folder. If the folder has not yet
- * expanded, then expand it.
- *
- * @param service The file system service.
- * @param folder The folder node from which the node is going to be removed.
- * @param child The child node to be removed.
- * @throws TCFFileSystemException Thrown during children querying.
- */
- protected void removeChild(final IFileSystem service, final FSTreeNode folder, final FSTreeNode child) throws TCFFileSystemException, InterruptedException {
- if (Protocol.isDispatchThread()) {
- if (!folder.childrenQueried) {
- loadChildren(folder, service);
- }
- folder.removeChild(child);
- child.setParent(null);
- }
- else {
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- final InterruptedException[] iexs = new InterruptedException[1];
- Protocol.invokeAndWait(new Runnable() {
-
- @Override
- public void run() {
- try {
- removeChild(service, folder, child);
- }
- catch (TCFFileSystemException e) {
- errors[0] = e;
- }
- catch (InterruptedException e) {
- iexs[0] = e;
- }
- }
- });
- if (errors[0] != null) throw errors[0];
- if (iexs[0] != null) throw iexs[0];
- }
- }
-
- /**
- * Find the node with the name from the children list of the folder.
- *
- * @param service The file system service.
- * @param folder The folder node.
- * @param name The target node's name.
- * @return The node with the specified name or null if no such node is found.
- * @throws TCFFileSystemException Thrown when querying the children.
- */
- protected FSTreeNode findChild(IFileSystem service, FSTreeNode folder, String name) throws TCFFileSystemException, InterruptedException {
- List<FSTreeNode> children = getChildren(folder, service);
- for (FSTreeNode child : children) {
- if (child.name.equals(name)) return child;
- }
- return null;
- }
-
- /**
- * Create the name for the target file that is copied. If there exists a file with the same
- * name, then "Copy of xxxx" and "Copy (n) of xxxx" will be used as the target file name.
- *
- * @param service File system service used to query the children nodes of the folder.
- * @param node The node whose target file is to be created.
- * @param dest The destination folder.
- * @return The new target node with the new name following the rule.
- * @throws TCFFileSystemException Thrown during children querying.
- */
- protected FSTreeNode createCopyDestination(IFileSystem service, FSTreeNode node, FSTreeNode dest) throws TCFFileSystemException, InterruptedException {
- FSTreeNode copy = (FSTreeNode) node.clone();
- String name = node.name;
- FSTreeNode possibleChild = findChild(service, dest, name);
- for (int n = 0; possibleChild != null; n++) {
- if (n > 0) {
- name = NLS.bind(Messages.Operation_CopyNOfFile, Integer.valueOf(n), node.name);
- }
- else {
- name = NLS.bind(Messages.Operation_CopyOfFile, node.name);
- }
- possibleChild = findChild(service, dest, name);
- }
- copy.name = name;
- addChild(service, dest, copy);
- return copy;
- }
-
- /**
- * Make a new directory with for the new node.
- *
- * @param service The file system service.
- * @param node The directory node to be made.
- * @throws TCFFileSystemException Thrown during children querying.
- */
- protected void mkdir(IFileSystem service, final FSTreeNode node) throws TCFFileSystemException {
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- String path = node.getLocation(true);
- service.mkdir(path, node.attr, new DoneMkDir() {
- @Override
- public void doneMkDir(IToken token, FileSystemException error) {
- if (error != null) {
- String message = NLS
- .bind(Messages.Operation_CannotCreateDirectory, new Object[] { node.name, error });
- errors[0] = new TCFFileSystemException(IStatus.WARNING, message, error);
- }
- }
- });
- if (errors[0] != null) {
- throw errors[0];
- }
- }
-
- /**
- * Confirm if the file/folder represented by the specified should be replaced.
- *
- * @param node The file/folder node.
- * @return The confirming result. true yes, false no.
- * @throws InterruptedException Thrown when canceled.
- */
- protected boolean confirmReplace(final FSTreeNode node, IConfirmCallback confirmCallback) throws InterruptedException {
- if(confirmCallback == null) return true;
- if (yes2All) return true;
- int result = confirmCallback.confirms(node);
- switch (result) {
- case 0:
- return true;
- case 1:
- yes2All = true;
- return true;
- case 2:
- return false;
- }
- throw new InterruptedException();
- }
-
- /**
- * Add the specified child to the folder node's children list.
- *
- * @param service The file system service.
- * @param folder The folder node.
- * @param child The child node to be added.
- * @throws TCFFileSystemException Thrown during children querying.
- */
- protected void addChild(final IFileSystem service, final FSTreeNode folder, final FSTreeNode child) throws TCFFileSystemException, InterruptedException {
- if (Protocol.isDispatchThread()) {
- if (!folder.childrenQueried) {
- loadChildren(folder, service);
- }
- child.setParent(folder);
- folder.addChild(child);
- }
- else {
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- final InterruptedException[] iexs = new InterruptedException[1];
- Protocol.invokeAndWait(new Runnable() {
-
- @Override
- public void run() {
- try {
- addChild(service, folder, child);
- }
- catch (TCFFileSystemException e) {
- errors[0] = e;
- }
- catch (InterruptedException e) {
- iexs[0] = e;
- }
- }
- });
- if (errors[0] != null) throw errors[0];
- if (iexs[0] != null) throw iexs[0];
- }
- }
-
- /**
- * Remove the file.
- *
- * @param node
- * @param service
- * @throws TCFFileSystemException
- */
- protected void removeFile(final FSTreeNode node, IFileSystem service) throws TCFFileSystemException, InterruptedException {
- if (monitor.isCanceled()) throw new InterruptedException();
- // Do the actual deleting.
- String path = node.getLocation(true);
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- service.remove(path, new DoneRemove() {
- @Override
- public void doneRemove(IToken token, FileSystemException error) {
- if (error == null) {
- cleanUpFile(node);
- }
- else {
- errors[0] = newTCFException(IStatus.WARNING, error);
- }
- }
- });
- if (errors[0] != null) {
- throw errors[0];
- }
- }
-
- /**
- * Remove the folder.
- *
- * @param node
- * @param service
- * @throws TCFFileSystemException
- */
- protected void removeFolder(final FSTreeNode node, IFileSystem service) throws TCFFileSystemException, InterruptedException {
- if (monitor.isCanceled()) throw new InterruptedException();
- // Do the actual deleting.
- String path = node.getLocation(true);
- final TCFFileSystemException[] errors = new TCFFileSystemException[1];
- service.rmdir(path, new DoneRemove() {
- @Override
- public void doneRemove(IToken token, FileSystemException error) {
- if (error == null) {
- cleanUpFolder(node);
- }
- else {
- errors[0] = newTCFException(IStatus.WARNING, error);
- }
- }
- });
- if (errors[0] != null) {
- throw errors[0];
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- this.monitor = monitor;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName()
- */
- @Override
- public String getName() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getTotalWork()
- */
- @Override
- public int getTotalWork() {
- return IProgressMonitor.UNKNOWN;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.core.utils.Ancestor#getParent(java.lang.Object)
- */
- @Override
- protected FSTreeNode getParent(FSTreeNode element) {
- return element.getParent();
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/TCFResult.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/TCFResult.java
new file mode 100644
index 000000000..db724cf5d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/TCFResult.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.StatusHelper;
+
+public class TCFResult<T> {
+ private static final long UNRESPONSIVE_TIMEOUT = 60*1000;
+
+ private IStatus fStatus;
+ private T fValue;
+ private long fCheckedTime;
+ private boolean fAutoCancel;
+
+ private List<IProgressMonitor> fMonitors = new ArrayList<IProgressMonitor>();
+
+
+ public TCFResult() {
+ this(true);
+ }
+
+ public TCFResult(boolean autoCancel) {
+ fAutoCancel = autoCancel;
+ resetTimeout();
+ }
+
+ public IStatus waitDone(IProgressMonitor monitor) {
+ return waitDone(monitor, Long.MAX_VALUE, UNRESPONSIVE_TIMEOUT);
+ }
+
+ public IStatus waitDone(IProgressMonitor monitor, long absoluteTimeout) {
+ return waitDone(monitor, absoluteTimeout, UNRESPONSIVE_TIMEOUT);
+ }
+
+ public synchronized IStatus waitDone(IProgressMonitor monitor, long absoluteTimeout, long unresponsiveTimeout) {
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+
+ fMonitors.add(monitor);
+ try {
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ if (fStatus != null) {
+ return fStatus;
+ }
+
+ if (monitor.isCanceled()) {
+ return cancelWait(monitor);
+ }
+
+ long time = System.currentTimeMillis();
+ if (time - startTime > absoluteTimeout || time - fCheckedTime > unresponsiveTimeout) {
+ return cancelWait(monitor);
+ }
+
+ try {
+ wait(100);
+ } catch (InterruptedException e) {
+ return cancelWait(monitor);
+ }
+ }
+ } finally {
+ fMonitors.remove(monitor);
+ }
+ }
+
+ private IStatus cancelWait(IProgressMonitor monitor) {
+ if (fAutoCancel && fMonitors.size() == 1) {
+ fStatus = Status.CANCEL_STATUS;
+ }
+
+ return Status.CANCEL_STATUS;
+ }
+
+ private long resetTimeout() {
+ return fCheckedTime = System.currentTimeMillis();
+ }
+
+ public T getValue() {
+ return fValue;
+ }
+
+ public synchronized IStatus setDone(IStatus status, T result) {
+ if (fStatus == null) {
+ fStatus = status;
+ fValue = result;
+ notifyAll();
+ }
+ return fStatus;
+ }
+
+ public IStatus setDone(T result) {
+ return setDone(Status.OK_STATUS, result);
+ }
+
+ public IStatus setError(String msg, Throwable th) {
+ return setDone(StatusHelper.createStatus(msg, th), null);
+ }
+
+ public IStatus setCancelled() {
+ return setDone(Status.CANCEL_STATUS, null);
+ }
+
+ public synchronized boolean checkCancelled() {
+ if (fStatus != null) {
+ return true;
+ }
+ resetTimeout();
+ return false;
+ }
+
+ public IStatus getStatus() {
+ return fStatus;
+ }
+
+ public synchronized boolean hasWaiters() {
+ return !fMonitors.isEmpty();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java
index ec31cf72c..bb5ab76af 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -16,10 +16,10 @@ import java.io.File;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.ContentTypeHelper;
import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
/**
* The property tester of an FSTreeNode. The properties include "isFile"
@@ -32,7 +32,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
* <p>
* "testParent" is a property by which the parent or even the grand parent
* of a node can be tested. The arguments is a recursive list of the above
- * test property including "testParent".
+ * test property including "testParent".
* <p>
* The following is an example of how it is used.
* <pre>
@@ -58,7 +58,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
* args="testParent,testParent,testParent,...,isWritable"
* property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.testParent"&gt;
* &lt;/test&gt;
- * </pre>
+ * </pre>
*/
public class FSTreeNodePropertyTester extends PropertyTester {
@@ -84,9 +84,9 @@ public class FSTreeNodePropertyTester extends PropertyTester {
} else if (property.equals("isExecutable")){ //$NON-NLS-1$
return node.isExecutable();
} else if (property.equals("isRoot")) { //$NON-NLS-1$
- return node.isRoot();
+ return node.isRootDirectory();
} else if (property.equals("isSystemRoot")) { //$NON-NLS-1$
- return node.isSystemRoot();
+ return node.isFileSystem();
} else if (property.equals("isWindows")) { //$NON-NLS-1$
return node.isWindowsNode();
} else if (property.equals("isReadOnly")) { //$NON-NLS-1$
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 3b6ca32b0..a29347a3f 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,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -32,10 +32,10 @@ public class TargetPropertyTester extends PropertyTester {
}
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.
*/
@@ -43,10 +43,10 @@ public class TargetPropertyTester extends PropertyTester {
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.
*/
@@ -64,5 +64,5 @@ public class TargetPropertyTester extends PropertyTester {
});
}
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/TcfInputStream.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfInputStream.java
index 613bf6f64..17f917679 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfInputStream.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfInputStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -48,10 +48,6 @@ public class TcfInputStream extends InputStream {
* Create a TCF input stream connected the specified peer with specified
* path to the remote resource.
*
- * @param peer
- * The TCF agent peer.
- * @param path
- * The path to the remote resource.
*/
public TcfInputStream(TcfURLConnection connection) {
this(connection, DEFAULT_CHUNK_SIZE);
@@ -61,10 +57,6 @@ public class TcfInputStream extends InputStream {
* Create a TCF input stream connected the specified peer with specified
* path to the remote resource using the specified buffer size.
*
- * @param peer
- * The TCF agent peer.
- * @param path
- * The path to the remote resource.
* @param chunk_size
* The buffer size.
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java
index 6f1c7e202..d14024c68 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfOutputStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -42,10 +42,6 @@ public class TcfOutputStream extends OutputStream {
* Create a TCF output stream connected the specified peer with specified
* path to the remote resource.
*
- * @param peer
- * The TCF agent peer.
- * @param path
- * The path to the remote resource.
*/
public TcfOutputStream(TcfURLConnection connection) {
this(connection, DEFAULT_CHUNK_SIZE);
@@ -55,10 +51,6 @@ public class TcfOutputStream extends OutputStream {
* Create a TCF output stream connected the specified peer with specified
* path to the remote resource using the specified buffer size.
*
- * @param peer
- * The TCF agent peer.
- * @param path
- * The path to the remote resource.
* @param chunk_size
* The buffer size.
*/
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 3d1e53126..18e7ce171 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -30,8 +30,8 @@ import org.eclipse.tcf.services.IFileSystem.FileSystemException;
import org.eclipse.tcf.services.IFileSystem.IFileHandle;
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.filesystem.core.services.Operation;
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.ModelManager;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java
index dabe51149..be8c0d87a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLStreamHandlerService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -21,18 +21,18 @@ import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
import org.osgi.service.url.AbstractURLStreamHandlerService;
/**
- * The stream handler service used to parse tcf stream protocol.
+ * The stream handler service used to parse tcf stream protocol.
*/
public class TcfURLStreamHandlerService extends AbstractURLStreamHandlerService {
// The pattern of a windows path.
private static final String WINPATH_PATTERN = "[A-Za-z]:.*"; //$NON-NLS-1$
private static final char[] WINPATH_FORBIDDEN_CHARS = {':', '*', '?', '"', '<', '>', '|' };
-
+
/*
* (non-Javadoc)
* @see org.osgi.service.url.AbstractURLStreamHandlerService#openConnection(java.net.URL)
@@ -45,14 +45,14 @@ public class TcfURLStreamHandlerService extends AbstractURLStreamHandlerService
/**
* Parse the given spec to the specified URL object. The expected format is:
* <p>
- *
+ *
* <pre>
- * TCF_URL = tcf:/<strong>PEER_ID</strong>/(<strong>URL_PATH</strong>)?
- * PEER_ID = (.^/)+
+ * TCF_URL = tcf:/<strong>PEER_ID</strong>/(<strong>URL_PATH</strong>)?
+ * PEER_ID = (.^/)+
* URL_PATH = <strong>WIN_PATH</strong> | <strong>RELATIVE_PATH</strong>
- * WIN_PATH = <strong>DISK_SEG</strong> / (<strong>RELATIVE_PATH</strong>)?
- * DISK_SEG = [a-zA-Z]:
- * RELATIVE_PATH = <strong>PATH_SEG</strong> | <strong>PATH_SEG</strong>/<strong>RELATIVE_PATH</strong>
+ * WIN_PATH = <strong>DISK_SEG</strong> / (<strong>RELATIVE_PATH</strong>)?
+ * DISK_SEG = [a-zA-Z]:
+ * RELATIVE_PATH = <strong>PATH_SEG</strong> | <strong>PATH_SEG</strong>/<strong>RELATIVE_PATH</strong>
* Unix/Linux PATH_SEG = (.^[/])+
* Windows PATH_SEG = (.^[\/:*?"<>|])+
* </pre>
@@ -107,11 +107,11 @@ public class TcfURLStreamHandlerService extends AbstractURLStreamHandlerService
setURL(u, TcfURLConnection.PROTOCOL_SCHEMA, peerId, -1, null, null, path, null, null);
}
}
-
+
/**
- * Decode the path from URI compatible path to a
+ * Decode the path from URI compatible path to a
* file system path.
- *
+ *
* @see FSTreeNode#getURLEncodedPath
* @param path The URL whose path is to be decoded.
* @return The file system path.
@@ -130,10 +130,10 @@ public class TcfURLStreamHandlerService extends AbstractURLStreamHandlerService
String relative = builder.toString();
return path.startsWith("/") ? "/" + relative : relative; //$NON-NLS-1$//$NON-NLS-2$
}
-
+
/**
* Check the format of the specified windows path.
- *
+ *
* @param path The relative path to a disk part.
*/
private void checkWinPath(String path) {
@@ -148,9 +148,9 @@ public class TcfURLStreamHandlerService extends AbstractURLStreamHandlerService
}
/**
- * Encode the path from a file system path to
+ * Encode the path from a file system path to
* URI compatible path.
- *
+ *
* @see FSTreeNode#getURLEncodedPath
* @param path The URL whose path is to be decoded.
* @return The file system path.
@@ -178,7 +178,7 @@ public class TcfURLStreamHandlerService extends AbstractURLStreamHandlerService
String relative = builder.toString();
return path.startsWith("/") ? "/" + relative : relative; //$NON-NLS-1$//$NON-NLS-2$
}
-
+
/*
* (non-Javadoc)
* @see org.osgi.service.url.AbstractURLStreamHandlerService#toExternalForm(java.net.URL)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java
index 98a4b189b..99397b596 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -20,8 +20,8 @@ import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IFileSystem;
import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
-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.filesystem.core.services.Operation;
/**
* A blocking call proxy for a file system service. All calls to the service method are blocked
@@ -32,8 +32,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
* blocked forever.
* <p>
* This class is used to replace BlockingProxyCall for better debugability.
- *
- * @see BlockingCallProxy
+ *
*/
public class BlockingFileSystemProxy implements IFileSystem {
// The default timeout waiting for blocked invocations.
@@ -43,7 +42,7 @@ public class BlockingFileSystemProxy implements IFileSystem {
/**
* Constructor with an delegating service.
- *
+ *
* @param service The delegating service.
*/
public BlockingFileSystemProxy(IFileSystem service) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java
index c5749959f..88c8d3142 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/CacheManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -19,7 +19,8 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
/**
@@ -41,9 +42,9 @@ public class CacheManager {
* @param node The file/folder node.
* @return The local path of the node's cached file.
*/
- public static IPath getCachePath(FSTreeNode node) {
+ public static IPath getCachePath(IFSTreeNode node) {
File location = getCacheRoot();
- String agentId = node.peerNode.getPeerId();
+ String agentId = node.getRuntimeModel().getPeerNode().getPeerId();
// Use Math.abs to avoid negative hash value.
String agent = agentId.replace(':', PATH_ESCAPE_CHAR);
IPath agentDir = new Path(location.getAbsolutePath()).append(agent);
@@ -77,30 +78,6 @@ public class CacheManager {
}
/**
- * Check if the file exists and delete if it does. Record the failure message if deleting fails.
- *
- * @param file The file to be deleted.
- */
- static void deleteFileChecked(final File file) {
- if (file.exists()) {
- SafeRunner.run(new ISafeRunnable() {
- @Override
- public void run() throws Exception {
- if (!file.delete()) {
- throw new Exception(NLS.bind(Messages.Operation_DeletingFileFailed, file
- .getAbsolutePath()));
- }
- }
-
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }
- });
- }
- }
-
- /**
* Check if the file exists and set its read-only attribute if it does. Record the failure
* message if it fails.
*
@@ -112,7 +89,7 @@ public class CacheManager {
@Override
public void run() throws Exception {
if (!file.setReadOnly()) {
- throw new Exception(NLS.bind(Messages.OpStreamOp_SetReadOnlyFailed, file
+ throw new Exception(NLS.bind(Messages.CacheManager_SetReadOnlyFailed, file
.getAbsolutePath()));
}
}
@@ -138,7 +115,7 @@ public class CacheManager {
* @param node The file/folder node.
* @return The file object of the node's local cache.
*/
- public static File getCacheFile(FSTreeNode node) {
+ public static File getCacheFile(IFSTreeNode node) {
return getCachePath(node).toFile();
}
@@ -170,18 +147,20 @@ public class CacheManager {
* @param node The file/folder node.
* @return The path to the node.
*/
- private static IPath appendNodePath(IPath path, FSTreeNode node) {
- if (!node.isRoot() && node.getParent() != null) {
+ private static IPath appendNodePath(IPath path, IFSTreeNode node) {
+ if (!node.isRootDirectory() && node.getParent() != null) {
path = appendNodePath(path, node.getParent());
- return appendPathSegment(node, path, node.name);
+ return appendPathSegment(node, path, node.getName());
}
+ String name = node.getName();
if (node.isWindowsNode()) {
- String name = node.name;
- name = name.substring(0, name.length() - 1);
- name = name.replace(':', PATH_ESCAPE_CHAR);
- return appendPathSegment(node, path, name);
+ name = name.replace('\\', '/');
}
- return path;
+ name = name.replace(':', PATH_ESCAPE_CHAR);
+ if (name.endsWith("/")) //$NON-NLS-1$
+ name = name.substring(0, name.length()-1);
+
+ return appendPathSegment(node, path, name);
}
/**
@@ -193,7 +172,7 @@ public class CacheManager {
* @param name The segment's name.
* @return The path with the segment "name" appended.
*/
- private static IPath appendPathSegment(FSTreeNode node, IPath path, String name) {
+ private static IPath appendPathSegment(IFSTreeNode node, IPath path, String name) {
IPath newPath = path.append(name);
File newFile = newPath.toFile();
if (node.isDirectory()) {
@@ -201,4 +180,25 @@ public class CacheManager {
}
return newPath;
}
+
+ public static void clearCache(FSTreeNode source) {
+ if (source != null) {
+ File cache = getCacheFile(source);
+ if (cache.exists())
+ deleteFileOrDir(cache);
+ }
+ }
+
+ private static boolean deleteFileOrDir(File file) {
+ File[] children = file.listFiles();
+ boolean ok = true;
+ if (children != null) {
+ for (File child : children) {
+ if (!deleteFileOrDir(child)) {
+ ok = false;
+ }
+ }
+ }
+ return ok && file.delete();
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java
index 24914f38e..13f356d08 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/ContentTypeHelper.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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:
* William Chen (Wind River)- [345387]Open the remote files with a proper editor
- * William Chen (Wind River) [360494]Provide an "Open With" action in the pop
+ * William Chen (Wind River) [360494]Provide an "Open With" action in the pop
* up menu of file system nodes of Target Explorer.
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
@@ -22,7 +22,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
/**
* The content type helper used to provide helping methods about the content
@@ -58,6 +58,8 @@ public class ContentTypeHelper {
* @return The content type of the file node.
*/
public static IContentType getContentType(FSTreeNode node) {
+ if (!node.isFile())
+ return null;
if (PersistenceManager.getInstance().isUnresovled(node))
// If it is already known unresolvable.
return null;
@@ -67,7 +69,7 @@ public class ContentTypeHelper {
return contentType;
// First check the content type by its name.
contentType = Platform.getContentTypeManager().findContentTypeFor(
- node.name);
+ node.getName());
if (contentType == null) { // Then find the content type by its stream.
try {
contentType = findContentTypeByStream(node);
@@ -107,7 +109,7 @@ public class ContentTypeHelper {
URL url = node.getLocationURL();
is = url.openStream();
}
- return Platform.getContentTypeManager().findContentTypeFor(is, node.name);
+ return Platform.getContentTypeManager().findContentTypeFor(is, node.getName());
} finally {
if (is != null) {
try {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java
index dbd7a342f..4e699321a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/FileState.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -11,15 +11,16 @@ package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
import java.beans.PropertyChangeEvent;
import java.io.File;
+import java.io.OutputStream;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.tcf.te.runtime.callback.Callback;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.JobExecutor;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCacheFileDigest;
import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
/**
* The state object to describe a file's state.
@@ -29,17 +30,17 @@ public class FileState {
* The base digest of the file data.
*/
private byte[] base_digest = null;
-
+
/**
* The message digest of the file data.
*/
private byte[] target_digest = null;
-
+
/**
* The message digest of the local cache data
*/
private byte[] cache_digest = null;
-
+
/**
* The cache file's modification time.
*/
@@ -49,31 +50,31 @@ public class FileState {
* If the job that computes the local cache's digest is running.
*/
transient boolean cache_digest_running = false;
-
+
/**
* If the job that computes the target file's digest is running.
*/
transient boolean target_digest_running = false;
-
+
/**
* The file system node whose state is described.
*/
private transient FSTreeNode node;
-
+
/**
* Create a file state using the node.
- *
+ *
* @param node The file system node.
*/
public FileState(FSTreeNode node) {
this.node = node;
}
-
+
/**
* Create a file state using the specified state data.
- *
+ *
* @param mtime The cache file's modification time.
- * @param cache_digest The cache file's digest.
+ * @param cache_digest The cache file's digest.
* @param target_digest The target file's digest.
* @param base_digest The baseline digest.
*/
@@ -83,56 +84,56 @@ public class FileState {
this.target_digest = target_digest;
this.base_digest = base_digest;
}
-
+
/**
* Set the file system node.
- *
+ *
* @param node The file system node.
*/
void setNode(FSTreeNode node) {
this.node = node;
}
-
+
/**
* Get the node's target file digest.
- *
+ *
* @return The target file digest.
*/
public byte[] getTargetDigest() {
return target_digest;
}
-
+
/**
* Get the node's baseline digest.
- *
+ *
* @return The baseline digest.
*/
public byte[] getBaseDigest() {
return base_digest;
}
-
+
/**
* Get the node's cache file modification time.
- *
+ *
* @return The cache file's modification time.
*/
public long getCacheMTime() {
return cache_mtime;
}
-
+
/**
* Get the node's cache file digest.
- *
+ *
* @return The cache file digest.
*/
public byte[] getCacheDigest() {
return cache_digest;
}
-
+
/**
* Update the cache state of this file and invoke callback once the update is done.
* If the callback is null, then do not invoke any callback.
- *
+ *
* @param callback Callback invoked after updating.
*/
public synchronized void updateState(final ICallback callback) {
@@ -143,7 +144,7 @@ public class FileState {
cache_digest_running = true;
this.cache_mtime = cache_mtime;
final OpCacheFileDigest op = new OpCacheFileDigest(node);
- new JobExecutor(new Callback() {
+ op.runInJob(new Callback() {
@Override
protected void internalDone(Object caller, IStatus status) {
if (status.isOK()) {
@@ -157,39 +158,46 @@ public class FileState {
callback.done(this, status);
}
}
- }).execute(op);
+ });
}
else if (!target_digest_running && target_digest == null) {
target_digest_running = true;
- node.refresh(new Callback(){
+ final IOperation op = node.operationDownload(new OutputStream() {
+ @Override
+ public void write(int b) {
+ }
+ });
+ op.runInJob(new Callback() {
@Override
protected void internalDone(Object caller, IStatus status) {
target_digest_running = false;
if (status.isOK()) {
updateState(callback);
- }
- else if(callback != null){
+ } else if(callback != null){
callback.done(this, status);
}
}
});
+ } else if (callback != null) {
+ callback.done(this, Status.OK_STATUS);
}
- else if (callback != null) callback.done(this, Status.OK_STATUS);
+ } else if (callback != null) {
+ callback.done(this, Status.OK_STATUS);
}
- else if (callback != null) callback.done(this, Status.OK_STATUS);
}
-
+
/**
* Get this node's cache state using the current state data.
- *
+ *
* @return The state expressed in a CacheState enum value.
*/
public synchronized CacheState getCacheState() {
File file = CacheManager.getCacheFile(node);
if (!file.exists()) return CacheState.consistent;
updateState(null);
- if (cache_digest == null || target_digest == null) return CacheState.consistent;
- if(isUnchanged(target_digest, cache_digest)) {
+ if (cache_digest == null || target_digest == null)
+ return CacheState.consistent;
+ if (isUnchanged(target_digest, cache_digest)) {
base_digest = target_digest;
return CacheState.consistent;
}
@@ -201,18 +209,18 @@ public class FileState {
}
return CacheState.conflict;
}
-
+
/**
* Update the node's target digest and fire an event.
- *
+ *
* @param target_digest The new target digest data.
*/
public void updateTargetDigest(byte[] target_digest) {
this.target_digest = target_digest;
PropertyChangeEvent event = new PropertyChangeEvent(this, "target_digest", null, target_digest); //$NON-NLS-1$
- node.firePropertyChange(event);
+ node.getRuntimeModel().firePropertyChanged(event);
}
-
+
/**
* Compare the two digests to see if they are equal to each other.
*
@@ -232,19 +240,19 @@ public class FileState {
/**
* Update the cache file digest data and fire an event.
- *
+ *
* @param cache_digest The new cache file digest data.
*/
public void updateCacheDigest(byte[] cache_digest) {
byte[] old_digest = cache_digest;
this.cache_digest = cache_digest;
PropertyChangeEvent event = new PropertyChangeEvent(node, "cache_digest", old_digest, cache_digest); //$NON-NLS-1$
- node.firePropertyChange(event);
+ node.getRuntimeModel().firePropertyChanged(event);
}
/**
* Reset all of the node's digest data to a new digest data.
- *
+ *
* @param digest The new digest data.
*/
public void reset(byte[] digest) {
@@ -252,6 +260,6 @@ public class FileState {
target_digest = digest;
base_digest = digest;
PropertyChangeEvent event = new PropertyChangeEvent(node, "reset_digest", null, digest); //$NON-NLS-1$
- node.firePropertyChange(event);
- }
+ node.getRuntimeModel().firePropertyChanged(event);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java
index e28abd4a3..bb6eaf326 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/PersistenceManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -22,7 +22,8 @@ import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
/**
* A facility class to load and save persistent data such including resolved content types, file's
@@ -43,7 +44,7 @@ public class PersistenceManager {
// The persistent properties of the files.
Map<URI, Map<QualifiedName, String>> properties;
-
+
// The file used to store persistent properties of each file.
private static final String PERSISTENT_FILE = "persistent.ini"; //$NON-NLS-1$
@@ -144,7 +145,6 @@ public class PersistenceManager {
/**
* Get the time stamp of the FSTreeNode with the specified location.
*
- * @param uri The FSTreeNode's location URI.
* @return The FSTreeNode's base time stamp.
*/
public FileState getFileDigest(FSTreeNode node) {
@@ -164,7 +164,7 @@ public class PersistenceManager {
* @param node The file node.
* @return The file properties object or empty properties object if it does not exist.
*/
- public Map<QualifiedName, String> getPersistentProperties(FSTreeNode node) {
+ public Map<QualifiedName, String> getPersistentProperties(IFSTreeNode node) {
Map<QualifiedName, String> nodeProperties = properties.get(node.getLocationURI());
if (nodeProperties == null) {
nodeProperties = Collections.synchronizedMap(new HashMap<QualifiedName, String>());
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/StatusHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/StatusHelper.java
new file mode 100644
index 000000000..5fbe2c113
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/StatusHelper.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin;
+
+public class StatusHelper {
+
+ public static IStatus createStatus(String msg, Throwable e) {
+ if (e != null) {
+ String msg2= e.getLocalizedMessage();
+ if (msg2 != null) {
+ msg = msg == null ? msg2 : msg + ": " + msg2; //$NON-NLS-1$
+ }
+ }
+ return new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), msg, e);
+ }
+
+}
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
deleted file mode 100644
index 103ef6293..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2014 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.model;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
-import org.eclipse.tcf.te.core.interfaces.IViewerInput;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-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.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.IPeerNode;
-
-/**
- * The base class of FSTreeNode and ProcessTreeNode which provides base members and methods.
- */
-public abstract class AbstractTreeNode extends PlatformObject {
- // The unique id of this node.
- protected final UUID uniqueId = UUID.randomUUID();
-
- /**
- * The tree node name.
- */
- public String name = null;
-
- /**
- * The tree node type.
- */
- public String type = null;
-
- /**
- * The peer node the file system tree node is associated with.
- */
- public IPeerNode peerNode = null;
-
- /**
- * Flag to mark once the children of the node got queried
- */
- public boolean childrenQueried = false;
-
- /**
- * Flag to mark once the children query is running
- */
- public boolean childrenQueryRunning = false;
-
- /**
- * The tree node parent.
- */
- protected AbstractTreeNode parent = null;
-
- /**
- * The tree node children.
- */
- protected List<AbstractTreeNode> children = Collections.synchronizedList(new ArrayList<AbstractTreeNode>());
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public final int hashCode() {
- return uniqueId.hashCode();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public final boolean equals(Object obj) {
- if(this == obj)
- return true;
- if (obj instanceof AbstractTreeNode) {
- return uniqueId.equals(((AbstractTreeNode) obj).uniqueId);
- }
- return super.equals(obj);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
- buffer.append(": name=" + (name != null ? name : super.toString())); //$NON-NLS-1$
- buffer.append(", UUID=" + uniqueId.toString()); //$NON-NLS-1$
- return buffer.toString();
- }
-
- /**
- * Called when the children query is done.
- */
- public void queryDone() {
- childrenQueryRunning = false;
- childrenQueried = true;
- PropertyChangeEvent event = new PropertyChangeEvent(this, "query_done", Boolean.FALSE, Boolean.TRUE); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Called when the children query is started.
- */
- public void queryStarted() {
- childrenQueryRunning = true;
- PropertyChangeEvent event = new PropertyChangeEvent(this, "query_started", Boolean.FALSE, Boolean.TRUE); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Get the user account of the specified TCF peer.
- *
- * @param peerNode The peer node of the TCF agent.
- * @return The user account that runs the agent.
- */
- protected UserAccount getUserAccount(IPeerNode peerNode) {
- OpUser user = new OpUser(peerNode);
- new NullOpExecutor().execute(user);
- return user.getUserAccount();
- }
-
- /**
- * Fire a property change event to notify one of the node's property has changed.
- *
- * @param event The property change event.
- */
- public void firePropertyChange(PropertyChangeEvent event) {
- if(peerNode != null) {
- IPropertyChangeProvider provider = (IPropertyChangeProvider) peerNode.getAdapter(IPropertyChangeProvider.class);
- provider.firePropertyChange(event);
- } else if(parent != null) {
- parent.firePropertyChange(event);
- }
- }
-
- /**
- * Add the specified nodes to the children list.
- *
- * @param nodes The nodes to be added.
- */
- public void addChidren(List<? extends AbstractTreeNode> nodes) {
- children.addAll(nodes);
- PropertyChangeEvent event = new PropertyChangeEvent(this, "addChildren", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Remove the specified nodes from the children list.
- *
- * @param nodes The nodes to be removed.
- */
- public void removeChildren(List<? extends AbstractTreeNode> nodes) {
- children.removeAll(nodes);
- PropertyChangeEvent event = new PropertyChangeEvent(this, "removeChildren", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Add the specified the node to the children list.
- *
- * @param node The child node to be added.
- */
- public void addChild(AbstractTreeNode node) {
- children.add(node);
- PropertyChangeEvent event = new PropertyChangeEvent(this, "addChild", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Remove the specified child node from its children list.
- *
- * @param node The child node to be removed.
- */
- public void removeChild(AbstractTreeNode node) {
- children.remove(node);
- PropertyChangeEvent event = new PropertyChangeEvent(this, "removeChild", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Clear the children of this folder.
- */
- public void clearChildren() {
- children.clear();
- PropertyChangeEvent event = new PropertyChangeEvent(this, "clearChildren", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * If this node is ancestor of the specified node.
- * @return true if it is.
- */
- public boolean isAncestorOf(AbstractTreeNode node) {
- if (node == null) return false;
- if (node.parent == this) return true;
- return isAncestorOf(node.parent);
- }
-
- /**
- * Get the parent node of this node.
- *
- * @return The parent node.
- */
- public AbstractTreeNode getParent() {
- return parent;
- }
-
- /**
- * Set the parent node of this node.
- *
- * @param parent The parent node.
- */
- public void setParent(AbstractTreeNode parent) {
- this.parent = parent;
- }
-
- /**
- * Recursively refresh the children of the given process context.
- *
- * @param parentNode The process context node. Must not be <code>null</code>.
- */
- public void refresh() {
- refresh(null);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if(IViewerInput.class.equals(adapter)) {
- return peerNode.getAdapter(IViewerInput.class);
- }
- if(IPropertyChangeProvider.class.equals(adapter)) {
- return peerNode.getAdapter(adapter);
- }
- return super.getAdapter(adapter);
- }
-
- /**
- * Recursively refresh the children of the given process context with a callback, which is
- * called when whole process is finished.
- *
- * @param callback The callback object, or <code>null</code> when callback is not needed.
- */
- public void refresh(final ICallback callback) {
- Map<String, Boolean> flags = new HashMap<String, Boolean>();
- flags.put(IChannelManager.FLAG_NO_PATH_MAP, Boolean.TRUE);
- Tcf.getChannelManager().openChannel(peerNode.getPeer(), flags, doCreateRefreshDoneOpenChannel(new Callback() {
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.callback.Callback#internalDone(java.lang.Object, org.eclipse.core.runtime.IStatus)
- */
- @Override
- protected void internalDone(Object caller, IStatus status) {
- refreshChildren(callback);
- }
- }));
- }
-
- /**
- * Create the callback object of opening channel for refreshing itself.
- *
- * @param callback The callback object.
- * @return The callback object.
- */
- protected abstract DoneOpenChannel doCreateRefreshDoneOpenChannel(ICallback callback);
-
- /**
- * Query the children of this file system node.
- */
- public final void queryChildren() {
- queryChildren(null);
- }
- /**
- * Query the children of this file system node.
- */
- public void queryChildren(ICallback callback) {
- queryStarted();
- Map<String, Boolean> flags = new HashMap<String, Boolean>();
- flags.put(IChannelManager.FLAG_NO_PATH_MAP, Boolean.TRUE);
- Tcf.getChannelManager().openChannel(peerNode.getPeer(), flags, doCreateQueryDoneOpenChannel(callback));
- }
-
- /**
- * Create the callback object of opening channel for querying children.
- *
- * @return The callback object.
- */
- protected abstract DoneOpenChannel doCreateQueryDoneOpenChannel(ICallback callback);
-
- /**
- * Return if this node is the system root.
- *
- * @return true if it is.
- */
- public abstract boolean isSystemRoot();
-
- /**
- * Get the children of this tree node.
- *
- * @return The list of the children.
- */
- public List<? extends AbstractTreeNode> getChildren() {
- return new ArrayList<AbstractTreeNode>(children);
- }
-
- /**
- * Refresh the children's children.
- */
- public final void refreshChildren() {
- refreshChildren(null);
- }
-
- /**
- * Refresh the children's children.
- */
- public abstract void refreshChildren(ICallback callback);
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java
index 9242a18cb..b98ef001b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/FSTreeNode.java
@@ -1,681 +1,22 @@
/*******************************************************************************
- * 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
+ * Copyright (c) 2015 Wind River Systems, Inc.
+ * 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
- * William Chen (Wind River) - [345384] Provide property pages for remote file system nodes
- * William Chen (Wind River) - [352302]Opening a file in an editor depending on
- * the client's permissions.
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.model;
-import java.beans.PropertyChangeEvent;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
+package org.eclipse.tcf.te.tcf.filesystem.core.model;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.services.IFileSystem;
-import org.eclipse.tcf.services.IFileSystem.DirEntry;
-import org.eclipse.tcf.services.IFileSystem.FileAttrs;
-import org.eclipse.tcf.te.core.interfaces.IFilterable;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.core.concurrent.CallbackMonitor;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel;
-import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IWindowsFileAttributes;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks.QueryDoneOpenChannel;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks.RefreshStateDoneOpenChannel;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpTargetFileDigest;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.testers.TargetPropertyTester;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLStreamHandlerService;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
- * Representation of a file system tree node.
- * <p>
- * <b>Note:</b> Node construction and child list access is limited to the TCF
- * event dispatch thread.
+ * @deprecated will be removed, use {@link IFSTreeNode} instead
*/
-public final class FSTreeNode extends AbstractTreeNode implements Cloneable, IFilterable {
- // The constant to access the Windows Attributes.
- private static final String KEY_WIN32_ATTRS = "Win32Attrs"; //$NON-NLS-1$
-
- /**
- * The tree node file system attributes
- */
- public IFileSystem.FileAttrs attr = null;
-
- /**
- * Create a folder node using the specified parent node, the directory entry
- * and the flag to indicate if it is a root node.
- *
- * @param parentNode The parent node.
- * @param entry The directory entry.
- * @param entryIsRootNode If this folder is root folder.
- */
- public FSTreeNode(FSTreeNode parentNode, DirEntry entry, boolean entryIsRootNode) {
- Assert.isNotNull(entry);
- IFileSystem.FileAttrs attrs = entry.attrs;
-
- this.attr = attrs;
- this.name = entry.filename;
- if (attrs == null || attrs.isDirectory()) {
- this.type = entryIsRootNode ? "FSRootDirNode" : "FSDirNode"; //$NON-NLS-1$ //$NON-NLS-2$
- } else if (attrs.isFile()) {
- this.type = "FSFileNode"; //$NON-NLS-1$
- }
- this.parent = parentNode;
- this.peerNode = parentNode.peerNode;
- Assert.isTrue(Protocol.isDispatchThread());
- }
-
- /**
- * Constructor.
- */
- public FSTreeNode() {
- Assert.isTrue(Protocol.isDispatchThread());
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#clone()
- */
- @Override
- public Object clone() {
- if (Protocol.isDispatchThread()) {
- FSTreeNode clone = new FSTreeNode();
- clone.childrenQueried = childrenQueried;
- clone.childrenQueryRunning = childrenQueryRunning;
- clone.name = name;
- clone.parent = parent;
- clone.peerNode = peerNode;
- clone.type = type;
- if (attr != null) {
- Map<String, Object> attributes = new HashMap<String, Object>(attr.attributes);
- clone.attr = new IFileSystem.FileAttrs(attr.flags, attr.size, attr.uid, attr.gid, attr.permissions, attr.atime, attr.mtime, attributes);
- } else {
- clone.attr = null;
- }
- return clone;
- }
- final Object[] objects = new Object[1];
- Protocol.invokeAndWait(new Runnable() {
-
- @Override
- public void run() {
- objects[0] = FSTreeNode.this.clone();
- }
- });
- return objects[0];
- }
-
- /**
- * Change the file/folder's write permission.
- * @param b true if the agent is granted with its write permission.
- */
- public void setWritable(boolean b) {
- UserAccount account = getUserAccount(peerNode);
- if (account != null && attr != null) {
- int bit;
- if (attr.uid == account.getEUID()) {
- bit = IFileSystem.S_IWUSR;
- } else if (attr.gid == account.getEGID()) {
- bit = IFileSystem.S_IWGRP;
- } else {
- bit = IFileSystem.S_IWOTH;
- }
- int permissions = attr.permissions;
- setPermissions(b ? (permissions | bit):(permissions & ~ bit));
- }
- }
-
- /**
- * Set the file's permissions.
- * @param permissions The new permissions.
- */
- public void setPermissions(int permissions) {
- attr = new IFileSystem.FileAttrs(attr.flags, attr.size, attr.uid, attr.gid, permissions, attr.atime, attr.mtime, attr.attributes);
- }
-
- /**
- * Returns the children outside of TCF thread.
- *
- * @return The children list.
- */
- @SuppressWarnings("unchecked")
- @Override
- public List<FSTreeNode> getChildren() {
- return (List<FSTreeNode>) super.getChildren();
- }
-
- /**
- * Return if the node is a Windows file/folder node.
- *
- * @return true if it is a Windows node, or else false.
- */
- public boolean isWindowsNode() {
- if (attr != null && attr.attributes != null) {
- return attr.attributes.containsKey(KEY_WIN32_ATTRS);
- }
- if (peerNode != null) {
- String OSName = TargetPropertyTester.getOSName(peerNode);
- if(OSName != null){
- return OSName.startsWith("Windows"); //$NON-NLS-1$
- }
- }
- synchronized (children) {
- if (!children.isEmpty()) {
- for (AbstractTreeNode treeNode : children) {
- FSTreeNode node = (FSTreeNode) treeNode;
- if(node.hasOSInfo()) {
- return node.isWindowsNode();
- }
- }
- }
- }
- if(parent != null) {
- return ((FSTreeNode)parent).isWindowsNode();
- }
- return false;
- }
-
- /**
- * If this node has OS information.
- *
- * @return true if it has.
- */
- private boolean hasOSInfo() {
- return attr != null && attr.attributes != null ||
- peerNode != null && TargetPropertyTester.getOSName(peerNode)!= null;
- }
-
- /**
- * Return if the node is a file.
- *
- * @return true if it is a file, or else false.
- */
- public boolean isFile() {
- if (attr != null) {
- return attr.isFile();
- }
- if (type != null)
- {
- return type.equals("FSFileNode"); //$NON-NLS-1$
- }
- return false;
- }
-
- /**
- * Return if the node is a directory.
- *
- * @return true if it is a directory, or else false.
- */
- public boolean isDirectory() {
- if (attr != null) {
- return attr.isDirectory();
- }
- if (type != null)
- {
- return type.endsWith("DirNode"); //$NON-NLS-1$
- }
- return false;
- }
-
- /**
- * Return if the attribute specified by the mask bit is turned on.
- *
- * @param bit
- * The attribute's mask bit.
- * @return true if it is on, or else false.
- */
- public boolean isWin32AttrOn(int bit) {
- if (attr != null && attr.attributes.get(KEY_WIN32_ATTRS) instanceof Integer) {
- Integer win32Attrs = (Integer) attr.attributes.get(KEY_WIN32_ATTRS);
- return (win32Attrs.intValue() & bit) != 0;
- }
- return false;
- }
-
- /**
- * Set the attribute specified by the mask bit to on or off.
- * @param bit The attribute's mask bit.
- * @param on The flag if the bit should be turned on or off.
- */
- public void setWin32Attr(int bit, boolean on) {
- if (attr != null && attr.attributes.get(KEY_WIN32_ATTRS) instanceof Integer) {
- int win32attr = ((Integer) attr.attributes.get(KEY_WIN32_ATTRS)).intValue();
- win32attr = on ? (win32attr | bit) : (win32attr & ~bit);
- attr.attributes.put(KEY_WIN32_ATTRS, Integer.valueOf(win32attr));
- }
- }
-
- /**
- * Get the file's win32 attributes.
- * @return The file's win32 attributes.
- */
- public int getWin32Attrs() {
- if (attr != null && attr.attributes.get(KEY_WIN32_ATTRS) instanceof Integer) {
- return ((Integer) attr.attributes.get(KEY_WIN32_ATTRS)).intValue();
- }
- return 0;
- }
-
- /**
- * Return if this file/folder is hidden.
- *
- * @return true if it is hidden, or else false.
- */
- public boolean isHidden() {
- return isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_HIDDEN);
- }
-
- /**
- * Set the file/folder hidden attribute's value.
- * @param hidden The new value.
- */
- public void setHidden(boolean hidden) {
- setWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_HIDDEN, hidden);
- }
-
- /**
- * Return if this file/folder is read-only.
- *
- * @return true if it is read-only, or else false.
- */
- public boolean isReadOnly() {
- return isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_READONLY);
- }
-
- /**
- * Set the file/folder read-only attribute's value.
- * @param readOnly The new value.
- */
- public void setReadOnly(boolean readOnly) {
- setWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_READONLY, readOnly);
- }
-
- /**
- * Get the location of a file/folder node using the format of the file
- * system's platform.
- *
- * @param parentNode
- * The file/folder node.
- * @return The location of the file/folder.
- */
- public String getLocation() {
- return getLocation(false);
- }
-
- /**
- * Get the location of a file/folder.
- *
- * @param cross
- * If the format is cross-platform.
- * @return The path to the file/folder.
- */
- public String getLocation(boolean cross) {
- if(isRoot()) {
- if(cross) {
- if(isWindowsNode()) {
- return name.substring(0, name.length() - 1) + "/"; //$NON-NLS-1$
- }
- }
- return name;
- }
- String pLoc = getParent().getLocation(cross);
- if(getParent().isRoot()) {
- return pLoc + name;
- }
- String pathSep = (!cross && isWindowsNode()) ? "\\" : "/"; //$NON-NLS-1$ //$NON-NLS-2$
- return pLoc + pathSep + name;
- }
-
- /**
- * Get the URL of the file or folder. The URL's format is created in the
- * following way: tcf:/<TCF_AGENT_ID>/remote/path/to/the/resource... See
- * {@link TcfURLConnection#TcfURLConnection(URL)}
- *
- * @see TcfURLStreamHandlerService#parseURL(URL, String, int, int)
- * @see #getLocationURI()
- * @return The URL of the file/folder.
- */
- public URL getLocationURL() {
- try {
- String id = peerNode.getPeerId();
- String path = getLocation(true);
- String location = TcfURLConnection.PROTOCOL_SCHEMA + ":/" + id + (path.startsWith("/") ? path : "/" + path); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return new URL(location);
- } catch (MalformedURLException e) {
- assert false;
- return null;
- }
- }
-
- /**
- * Get the URI of the file or folder. The URI's format is created in the
- * following way: tcf:/<TCF_AGENT_ID>/remote/path/to/the/resource...
- *
- * @return The URI of the file/folder.
- */
- public URI getLocationURI() {
- try {
- String id = peerNode.getPeerId();
- String path = getEncodedURIPath();
- String location = TcfURLConnection.PROTOCOL_SCHEMA + ":/" + id + (path.startsWith("/") ? path : "/" + path); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return new URI(location);
- }
- catch (URISyntaxException e) {
- assert false;
- return null;
- }
- }
-
- /**
- * Encode each segment of the path to a URI compatible name,
- * and get the URI encoded path.
- *
- * @return The encoded path which is URI compatible.
- */
- private String getEncodedURIPath() {
- if(isRoot()) {
- if(isWindowsNode()) {
- return name.substring(0, name.length() - 1) + "/"; //$NON-NLS-1$
- }
- return name;
- }
- final AtomicReference<String> ref = new AtomicReference<String>();
- SafeRunner.run(new ISafeRunnable(){
- @Override
- public void handleException(Throwable exception) {
- // Ignore on purpose
- }
- @Override
- public void run() throws Exception {
- ref.set(URLEncoder.encode(name, "UTF-8")); //$NON-NLS-1$
- }});
- String segment = ref.get();
- String pLoc = getParent().getEncodedURIPath();
- if(getParent().isRoot()) {
- return pLoc + segment;
- }
- return pLoc + "/" + segment; //$NON-NLS-1$
- }
-
- /**
- * If this node is a root node.
- *
- * @return true if this node is a root node.
- */
- public boolean isRoot() {
- return type != null && type.equals("FSRootDirNode"); //$NON-NLS-1$
- }
-
- /**
- * If this node is the system root.
- *
- * @return true if this node is the system root.
- */
- @Override
- public boolean isSystemRoot() {
- return type != null && type.equals("FSRootNode"); //$NON-NLS-1$
- }
-
- /**
- * If this file is readable.
- *
- * @return true if it is readable.
- */
- public boolean isReadable() {
- UserAccount account = getUserAccount(peerNode);
- if (account != null && attr != null) {
- if (attr.uid == account.getEUID()) {
- return (attr.permissions & IFileSystem.S_IRUSR) != 0;
- } else if (attr.gid == account.getEGID()) {
- return (attr.permissions & IFileSystem.S_IRGRP) != 0;
- } else {
- return (attr.permissions & IFileSystem.S_IROTH) != 0;
- }
- }
- return false;
- }
-
- /**
- * If the agent is the owner of this file/folder.
- *
- * @return true if the agent is the owner of this file/folder.
- */
- public boolean isAgentOwner() {
- UserAccount account = getUserAccount(peerNode);
- if (account != null && attr != null) {
- return attr.uid == account.getEUID();
- }
- return false;
- }
-
- /**
- * If this file is writable.
- *
- * @return true if it is writable.
- */
- public boolean isWritable() {
- UserAccount account = getUserAccount(peerNode);
- if (account != null && attr != null) {
- if (attr.uid == account.getEUID()) {
- return (attr.permissions & IFileSystem.S_IWUSR) != 0;
- } else if (attr.gid == account.getEGID()) {
- return (attr.permissions & IFileSystem.S_IWGRP) != 0;
- } else {
- return (attr.permissions & IFileSystem.S_IWOTH) != 0;
- }
- }
- return false;
- }
-
- /**
- * If this file is executable.
- *
- * @return true if it is executable.
- */
- public boolean isExecutable() {
- UserAccount account = getUserAccount(peerNode);
- if (account != null && attr != null) {
- if (attr.uid == account.getEUID()) {
- return (attr.permissions & IFileSystem.S_IXUSR) != 0;
- } else if (attr.gid == account.getEGID()) {
- return (attr.permissions & IFileSystem.S_IXGRP) != 0;
- } else {
- return (attr.permissions & IFileSystem.S_IXOTH) != 0;
- }
- }
- return false;
- }
-
- /**
- * Test if this file is a windows system file.
- *
- * @return true if it is a windows system file.
- */
- public boolean isSystem() {
- return !isRoot() && isWindowsNode() && isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_SYSTEM);
- }
-
- /**
- * Get the type label of the file for displaying purpose.
- *
- * @return The type label text.
- */
- public String getFileType() {
- if (isRoot()) {
- return Messages.FSTreeNode_TypeLocalDisk;
- }
- if (isDirectory()) {
- return Messages.FSTreeNode_TypeFileFolder;
- }
- if (isSystem()) {
- return Messages.FSTreeNode_TypeSystemFile;
- }
- IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(name);
- if (contentType != null) {
- return contentType.getName();
- }
- int lastDot = name.lastIndexOf("."); //$NON-NLS-1$
- if (lastDot == -1) {
- return Messages.FSTreeNode_TypeUnknownFile;
- }
- return name.substring(lastDot + 1).toUpperCase() + " " + Messages.FSTreeNode_TypeFile; //$NON-NLS-1$
- }
-
- /**
- * Set the file's attributes and trigger property change event.
- *
- * @param attrs The new attributes.
- */
- public void setAttributes(FileAttrs attrs) {
- FileAttrs oldAttrs = this.attr;
- this.attr = attrs;
- if (attrs != oldAttrs) {
- firePropertyChange(new PropertyChangeEvent(this, "attributes", oldAttrs, attrs)); //$NON-NLS-1$
- }
- }
-
- /**
- * Get the local file's state of the specified tree node. The local file must exist
- * before calling this method to get its state.
- *
- * @param node The tree node whose local file state is going to retrieved.
- * @return The tree node's latest cache state.
- */
- public CacheState getCacheState() {
- File file = CacheManager.getCacheFile(this);
- if (!file.exists()) {
- return CacheState.consistent;
- }
- FileState digest = PersistenceManager.getInstance().getFileDigest(this);
- return digest.getCacheState();
- }
-
- /**
- * Set the file's new name and trigger property change event.
- *
- * @param name The new name.
- */
- public void setName(String name) {
- String oldName = this.name;
- this.name = name;
- if(name == null && oldName != null || name != null && !name.equals(oldName)) {
- firePropertyChange(new PropertyChangeEvent(this, "name", oldName, name)); //$NON-NLS-1$
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode#doCreateRefreshDoneOpenChannel(org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- protected DoneOpenChannel doCreateRefreshDoneOpenChannel(final ICallback callback) {
- final FileState digest = PersistenceManager.getInstance().getFileDigest(this);
- ICallback cb = new Callback(){
- @Override
- protected void internalDone(Object caller, IStatus status) {
- if (status.isOK() && caller instanceof OpTargetFileDigest) {
- digest.updateTargetDigest(((OpTargetFileDigest) caller).getDigest());
- }
- if (callback != null) {
- callback.done(caller, status);
- }
- }
- };
- return new RefreshStateDoneOpenChannel(this, cb);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode#doCreateQueryDoneOpenChannel()
- */
- @Override
- protected DoneOpenChannel doCreateQueryDoneOpenChannel(ICallback callback) {
- return new QueryDoneOpenChannel(this, callback);
- }
-
-// /**
-// * Override the queryChildren to refresh the second level children upon expanding.
-// */
-// @Override
-// public void queryChildren() {
-// queryChildren(new Callback(){
-// @Override
-// protected void internalDone(Object caller, IStatus status) {
-// refreshChildren();
-// }
-// });
-// }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode#getParent()
- */
- @Override
- public FSTreeNode getParent() {
- return (FSTreeNode) parent;
- }
+@Deprecated
+public interface FSTreeNode extends IFSTreeNode {
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode#refreshChildren()
- */
- @Override
- public void refreshChildren(ICallback callback) {
- List<FSTreeNode> children = getChildren();
- if(!children.isEmpty()) {
- ICallback proxy = new Callback(callback){
- @Override
- protected void internalDone(Object caller, IStatus status) {
- queryDone();
- }
- };
- final CallbackMonitor monitor = new CallbackMonitor(proxy);
- for(FSTreeNode child : children) {
- if((child.isRoot() || child.isDirectory()) && !child.childrenQueried && !child.childrenQueryRunning) {
- monitor.lock(child.uniqueId);
- }
- }
- for(FSTreeNode child : children) {
- if((child.isRoot() || child.isDirectory()) && !child.childrenQueried && !child.childrenQueryRunning) {
- final UUID uuid = child.uniqueId;
- child.queryChildren(new Callback(){
- @Override
- protected void internalDone(Object caller, IStatus status) {
- monitor.unlock(uuid, status);
- }
- });
- }
- }
- }
- else {
- if (callback != null) callback.done(this, Status.OK_STATUS);
- }
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java
index cc0a5056e..f2cb848a2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/ModelManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014, 2015 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
@@ -9,21 +9,46 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.model;
+import static java.text.MessageFormat.format;
+
+import java.io.File;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
+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.core.interfaces.IConnectable;
+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.IChannelManager.DoneOpenChannel;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.UserAccount;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDelete;
+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.OpUpload;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.TCFResult;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* Filesystem service model manager implementation.
*/
public class ModelManager {
- // Reference to the runtime models
- /* default */ static final Map<String, IRuntimeModel> runtimeModels = new HashMap<String, IRuntimeModel>();
+ static final Map<String, IRuntimeModel> fModels = Collections.synchronizedMap(new HashMap<String, IRuntimeModel>());
/**
* Returns the runtime model instance for the given peer model
@@ -36,48 +61,93 @@ public class ModelManager {
public static IRuntimeModel getRuntimeModel(final IPeerNode peerNode) {
Assert.isNotNull(peerNode);
- // The result reference holder
- final AtomicReference<IRuntimeModel> runtimeModel = new AtomicReference<IRuntimeModel>();
+ IRuntimeModel model = fModels.get(peerNode.getPeerId());
+ if (model != null)
+ return model;
+
+ if (peerNode.getConnectState() != IConnectable.STATE_CONNECTED)
+ return null;
+
+ final TCFResult<IRuntimeModel> result = new TCFResult<IRuntimeModel>();
// Create the runnable to execute
Runnable runnable = new Runnable() {
@Override
public void run() {
Assert.isTrue(Protocol.isDispatchThread());
- // Get the peer id
- 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(peerNode);
- if (candidate != null) runtimeModels.put(id, candidate);
+ IRuntimeModel model = fModels.get(peerNode.getPeerId());
+ if (model != null) {
+ result.setDone(model);
+ } else {
+ createRuntimeModel(peerNode, result);
}
- // Store to the result reference holder
- runtimeModel.set(candidate);
}
};
-
// Execute the runnable
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ } else {
+ Protocol.invokeAndWait(runnable);
+ result.waitDone(null);
+ }
- return runtimeModel.get();
+ return result.getValue();
}
- /**
- * Initialize the runtime model.
- * <p>
- * Must be called within the TCF dispatch thread.
- *
- * @param peerNode The peer model instance. Must not be <code>null</code>.
- * @return The runtime model.
- */
- protected static IRuntimeModel initializeRuntimeModel(IPeerNode peerNode) {
+ protected static void createRuntimeModel(final IPeerNode peerNode, final TCFResult<IRuntimeModel> result) {
Assert.isTrue(Protocol.isDispatchThread());
- IRuntimeModel runtimeModel = new RuntimeModel(peerNode);
- return runtimeModel;
+ Map<String, Boolean> flags = new HashMap<String, Boolean>();
+ flags.put(IChannelManager.FLAG_FORCE_NEW, Boolean.TRUE);
+ flags.put(IChannelManager.FLAG_NO_PATH_MAP, Boolean.TRUE);
+ flags.put(IChannelManager.FLAG_NO_VALUE_ADD, Boolean.FALSE);
+
+ Tcf.getChannelManager().openChannel(peerNode.getPeer(), flags, new DoneOpenChannel() {
+ @Override
+ public void doneOpenChannel(Throwable error, final IChannel channel) {
+ if (error != null) {
+ result.setError(format(Messages.ModelManager_errorOpenChannel, peerNode.getName()), error);
+ return;
+ }
+ if (result.checkCancelled()) {
+ Tcf.getChannelManager().closeChannel(channel);
+ return;
+ }
+ final IFileSystem fs = channel.getRemoteService(IFileSystem.class);
+ if (fs == null) {
+ Tcf.getChannelManager().closeChannel(channel);
+ result.setError(format(Messages.Operation_NoFileSystemError, peerNode.getName()), null);
+ return;
+ }
+
+ fs.user(new DoneUser() {
+ @Override
+ public void doneUser(IToken token, FileSystemException error, int uid, int euid, int gid,
+ int egid, String home) {
+ if (error != null) {
+ result.setError(format(Messages.ModelManager_errorNoUserAccount, peerNode.getName()), error);
+ Tcf.getChannelManager().closeChannel(channel);
+ return;
+ }
+ if (result.checkCancelled()) {
+ Tcf.getChannelManager().closeChannel(channel);
+ return;
+ }
+
+ String peerId = peerNode.getPeerId();
+ IRuntimeModel rt = fModels.get(peerId);
+ if (rt != null) {
+ Tcf.getChannelManager().closeChannel(channel);
+ } else {
+ UserAccount account = new UserAccount(uid, gid, euid, egid, home);
+ rt = new RuntimeModel(peerNode, channel, fs, account);
+ fModels.put(peerId, rt);
+ }
+ result.setDone(rt);
+ }
+ });
+ }
+ });
}
/**
@@ -96,13 +166,42 @@ public class ModelManager {
// Get the peer id
String id = peerNode.getPeerId();
// Lookup the runtime model instance
- IRuntimeModel candidate = runtimeModels.remove(id);
- // Dispose it
- if (candidate != null) candidate.dispose();
+ IRuntimeModel candidate = fModels.remove(id);
+ if (candidate != null) {
+ Tcf.getChannelManager().closeChannel(candidate.getChannel());
+ candidate.dispose();
+ }
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ } else {
+ Protocol.invokeAndWait(runnable);
+ }
+ }
+
+ public static File getCacheRoot() {
+ return CacheManager.getCacheRoot();
+ }
+
+ public static IOperation operationUpload(List<IFSTreeNode> nodes) {
+ OpUpload upload = new OpUpload(null);
+ for (IFSTreeNode node : nodes) {
+ upload.addUpload(node.getCacheFile(), (FSTreeNode) node);
+ }
+ return upload;
+ }
+
+ public static IResultOperation<IFSTreeNode> operationRestoreFromPath(String path) {
+ return new OpParsePath(path);
+ }
+
+ public static IOperation operationDelete(List<IFSTreeNode> nodes, IConfirmCallback readonlyCallback) {
+ return new OpDelete(nodes, readonlyCallback);
+ }
+
+ public static IOperation operationRefresh(List<IFSTreeNode> nodes, boolean recursive) {
+ return new OpRefresh(nodes, recursive);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java
index 359d8c413..33659d814 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,71 +9,87 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.model;
+import static org.eclipse.tcf.te.tcf.locator.model.ModelManager.getPeerModel;
+
+import java.beans.PropertyChangeEvent;
+import java.io.File;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IChannel.IChannelListener;
import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IFileSystem;
import org.eclipse.tcf.te.core.interfaces.IConnectable;
+import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
import org.eclipse.tcf.te.runtime.model.ContainerModelNode;
import org.eclipse.tcf.te.runtime.model.factory.Factory;
import org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactory;
import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelService;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.UserAccount;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpParsePath;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* The file system model implementation.
*/
-public final class RuntimeModel extends ContainerModelNode implements IRuntimeModel {
- // Flag to mark the model disposed
- private boolean disposed;
-
- // Reference to the model node factory
- private IFactory factory = null;
+public final class RuntimeModel extends ContainerModelNode implements IRuntimeModel, IChannelListener {
- // The root node of the peer model
- private FSTreeNode root;
- private IPeerNode peerNode;
+ private final IPeerNode fPeerNode;
+ private final FSTreeNode fRoot;
+ private final UserAccount fUserAccount;
+ private IChannel fChannel;
+ private IFileSystem fFileSystem;
/**
* Create a File System ModelManager.
*/
- public RuntimeModel(IPeerNode peerNode) {
- disposed = false;
- this.peerNode = peerNode;
+ public RuntimeModel(IPeerNode peerNode, IChannel channel, IFileSystem fileSystem, UserAccount userAccount) {
+ fPeerNode = peerNode;
+ fChannel = channel;
+ fFileSystem = fileSystem;
+ fUserAccount = userAccount;
+ fRoot = new FSTreeNode(this, Messages.FSTreeNodeContentProvider_rootNodeLabel);
+ channel.addChannelListener(this);
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.nodes.PropertiesContainer#checkThreadAccess()
- */
@Override
protected boolean checkThreadAccess() {
return Protocol.isDispatchThread();
}
- /* (non-Javadoc)
- * @see com.windriver.te.tcf.core.model.interfaces.IModel#dispose()
- */
+ @Override
+ public void onChannelOpened() {
+ }
+
+ @Override
+ public void congestionLevel(int level) {
+ }
+
+ @Override
+ public void onChannelClosed(Throwable error) {
+ ModelManager.disposeRuntimeModel(fPeerNode);
+ }
+
@Override
public void dispose() {
Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
- disposed = true;
+ fFileSystem = null;
}
- /* (non-Javadoc)
- * @see com.windriver.te.tcf.core.model.interfaces.IModel#isDisposed()
- */
@Override
public boolean isDisposed() {
Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
- return disposed;
+ return fFileSystem == null;
}
- /* (non-Javadoc)
- * @see com.windriver.te.tcf.core.model.interfaces.IModel#getService(java.lang.Class)
- */
@Override
@SuppressWarnings("unchecked")
public <V extends IModelService> V getService(Class<V> serviceInterface) {
@@ -81,10 +97,6 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo
return (V)getAdapter(serviceInterface);
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class adapter) {
if (IPeerNode.class.isAssignableFrom(adapter) || IConnectable.class.isAssignableFrom(adapter)) {
@@ -101,31 +113,18 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo
return super.getAdapter(adapter);
}
- /* (non-Javadoc)
- * @see com.windriver.te.tcf.core.model.interfaces.IModel#setFactory(com.windriver.te.tcf.core.model.interfaces.IModelNodeFactory)
- */
@Override
public void setFactory(IFactory factory) {
- Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
- this.factory = factory;
}
- /* (non-Javadoc)
- * @see com.windriver.te.tcf.core.model.interfaces.IModel#getFactory()
- */
@Override
public IFactory getFactory() {
- Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
- return factory != null ? factory : Factory.getInstance();
+ return Factory.getInstance();
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider#getPeerModel()
- */
@Override
public IPeerNode getPeerNode() {
- Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
- return peerNode;
+ return fPeerNode;
}
/* (non-Javadoc)
@@ -133,96 +132,58 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo
*/
@Override
public String toString() {
- if (disposed) {
+ if (isDisposed()) {
return "*DISPOSED* : " + super.toString(); //$NON-NLS-1$
}
return super.toString();
}
- /**
- * Get the root node of the peer model.
- *
- * @return The root node.
- */
@Override
public FSTreeNode getRoot() {
- if(root == null) {
- root = createRoot();
- }
- return root;
+ return fRoot;
}
- /**
- * Create a root node for the specified peer.
- *
- * @param peerNode The peer.
- */
- /* default */ FSTreeNode createRoot() {
- if (Protocol.isDispatchThread()) {
- return createRootNode(peerNode);
- }
- else {
- final AtomicReference<FSTreeNode> ref = new AtomicReference<FSTreeNode>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- ref.set(createRoot());
- }
- });
- return ref.get();
- }
+ public UserAccount getUserAccount() {
+ return fUserAccount;
}
- /**
- * Create a root node for the peer.
- *
- * @param peerNode The peer.
- * @return The root file system node.
- */
- public static FSTreeNode createRootNode(IPeerNode peerNode) {
- FSTreeNode node = new FSTreeNode();
- node.type = "FSRootNode"; //$NON-NLS-1$
- node.peerNode = peerNode;
- node.name = Messages.FSTreeNodeContentProvider_rootNode_label;
- return node;
- }
+ public void firePropertyChanged(PropertyChangeEvent propertyChangeEvent) {
+ IPropertyChangeProvider provider = (IPropertyChangeProvider) fPeerNode.getAdapter(IPropertyChangeProvider.class);
+ if (provider != null)
+ provider.firePropertyChange(propertyChangeEvent);
+ }
- /**
- * Create a file node under the folder specified folder using the new name.
- *
- * @param name The file's name.
- * @param folder The parent folder.
- * @return The file tree node.
- */
- public static FSTreeNode createFileNode(String name, FSTreeNode folder) {
- return createTreeNode(name, "FSFileNode", folder); //$NON-NLS-1$
- }
+ @Override
+ public IResultOperation<IFSTreeNode> operationRestoreFromPath(String path) {
+ return new OpParsePath(fPeerNode, path);
+ }
- /**
- * Create a folder node under the folder specified folder using the new name.
- *
- * @param name The folder's name.
- * @param folder The parent folder.
- * @return The folder tree node.
- */
- public static FSTreeNode createFolderNode(String name, FSTreeNode folder) {
- return createTreeNode(name, "FSDirNode", folder); //$NON-NLS-1$
- }
+ public static IPeerNode getPeerFromPath(String path) {
+ String cacheRoot = CacheManager.getCacheRoot().getAbsolutePath();
+ if (!path.startsWith(cacheRoot))
+ return null;
- /**
- * Create a tree node under the folder specified folder using the new name.
- *
- * @param name The tree node's name.
- * @param type The new node's type.
- * @param folder The parent folder.
- * @return The tree node.
- */
- private static FSTreeNode createTreeNode(String name, String type, FSTreeNode folder) {
- FSTreeNode node = new FSTreeNode();
- node.name = name;
- node.parent = folder;
- node.peerNode = folder.peerNode;
- node.type = type;
- return node;
- }
+ path = path.substring(cacheRoot.length() + 1);
+ int slash = path.indexOf(File.separator);
+ if (slash == -1)
+ return null;
+
+ String peerId = path.substring(0, slash);
+ peerId = peerId.replace(CacheManager.PATH_ESCAPE_CHAR, ':');
+
+ for (IPeerNode peer : getPeerModel().getPeerNodes()) {
+ if (peerId.equals(peer.getPeerId()))
+ return peer;
+ }
+ return null;
+ }
+
+ @Override
+ public IChannel getChannel() {
+ return fChannel;
+ }
+
+ public IFileSystem getFileSystem() {
+ return fFileSystem;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/UserAccount.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/UserAccount.java
deleted file mode 100644
index d501473e8..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/UserAccount.java
+++ /dev/null
@@ -1,95 +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
- * William Chen (Wind River) - [352302]Opening a file in an editor depending on
- * the client's permissions.
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.core.model;
-
-/**
- * The data model of a user account.
- */
-public class UserAccount {
- // The user's id.
- private int uid;
- // The user's group id.
- private int gid;
- // The user's effective id.
- private int euid;
- // The user's effective group id.
- private int egid;
- // The user's home directory.
- private String home;
-
- /**
- * Create a user account with given data.
- *
- * @param uid
- * The user's id
- * @param gid
- * The user's group id
- * @param euid
- * The user's effective id.
- * @param egid
- * The user's effective group id.
- * @param home
- * The user's home directory.
- */
- public UserAccount(int uid, int gid, int euid, int egid, String home) {
- this.uid = uid;
- this.gid = gid;
- this.euid = euid;
- this.egid = egid;
- this.home = home;
- }
-
- /**
- * Get the user's id.
- *
- * @return The user's id.
- */
- public int getUID() {
- return uid;
- }
-
- /**
- * Get the user's group id.
- *
- * @return The user's group id.
- */
- public int getGID() {
- return gid;
- }
-
- /**
- * Get the user's effective id.
- *
- * @return The user's effective id.
- */
- public int getEUID() {
- return euid;
- }
-
- /**
- * Get the user's effective group id.
- *
- * @return The user's effective group id.
- */
- public int getEGID() {
- return egid;
- }
-
- /**
- * Get the user's home directory.
- *
- * @return The user's home directory.
- */
- public String getHome() {
- return home;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
index b49b665e7..4be2d1d85 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -30,14 +30,14 @@ public class Messages extends NLS {
// **** Declare externalized string id's down here *****
- public static String FSTreeNodeContentProvider_rootNode_label;
+ public static String FSTreeNodeContentProvider_rootNodeLabel;
public static String FSTreeNode_TypeFile;
public static String FSTreeNode_TypeFileFolder;
public static String FSTreeNode_TypeLocalDisk;
public static String FSTreeNode_TypeSystemFile;
public static String FSTreeNode_TypeUnknownFile;
+ public static String FSTreeNodeWorkingCopy_commitOperation_name;
- public static String Operation_DeletingFileFailed;
public static String Operation_NotResponding;
public static String Operation_OpeningChannelFailureMessage;
public static String Operation_NoFileSystemError;
@@ -47,42 +47,53 @@ public class Messages extends NLS {
public static String Operation_CannotCreateDirectory;
public static String Operation_TimeoutOpeningChannel;
+ public static String OpCommitAttr_error_cannotSetAttributes;
+ public static String OpCommitAttr_name;
public static String OpCopy_Copying;
public static String OpCopy_CannotCopyFile;
public static String OpCopy_CopyingFile;
+ public static String OpCopy_error_noDirectory;
+ public static String OpCopy_error_noFile;
+ public static String OpCreate_error_existingFile;
public static String OpCreate_TaskName;
+ public static String OpCreateFile_error_create;
+ public static String OpCreateFolder_error_createFolder;
public static String TcfURLConnection_NoFileHandleReturned;
public static String TcfURLConnection_NoPeerFound;
public static String TcfURLConnection_NoSuchTcfAgent;
public static String OpDelete_Deleting;
- public static String OpDelete_PrepareToDelete;
+ public static String OpDelete_error_delete;
+ public static String OpDelete_error_readDir;
public static String OpDelete_RemovingFileFolder;
public static String OpDownload_Downloading;
- public static String OpDownload_DownloadingMultipleFiles;
public static String OpDownload_DownloadingSingleFile;
public static String OpMove_Moving;
- public static String OpMove_FileExistsError;
- public static String OpMove_FolderExistsError;
public static String OpMove_CannotMove;
public static String OpMove_MovingFile;
- public static String OpOutStreamOp_DownloadingProgress;
+ public static String OpParsePath_name;
- public static String OpRefresh_RefreshJobTitle;
+ public static String OpRefresh_errorGetRoots;
+ public static String OpRefresh_errorOpenDir;
+ public static String OpRefresh_errorReadAttributes;
+ public static String OpRefresh_name;
- public static String OpRename_CannotRename;
public static String OpRename_TitleRename;
- public static String OpStreamOp_SetReadOnlyFailed;
+ public static String CacheManager_SetReadOnlyFailed;
public static String OpStreamOp_Bytes;
public static String OpStreamOp_KBs;
public static String OpStreamOp_MBs;
+ public static String OpTargetFileDigest_error_download;
+ public static String OpTargetFileDigest_error_openFile;
+ public static String OpUpload_error_openFile;
+ public static String OpUpload_error_upload;
public static String OpUpload_UploadingProgress;
public static String OpUpload_UploadNFiles;
public static String OpUpload_UploadSingleFile;
@@ -118,4 +129,6 @@ public class Messages extends NLS {
public static String BlockingFileSystemProxy_TimeoutSymLink;
public static String BlockingFileSystemProxy_TimeoutCopying;
public static String BlockingFileSystemProxy_TimeoutGettingUser;
+ public static String ModelManager_errorNoUserAccount;
+ public static String ModelManager_errorOpenChannel;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
index ad4dd962c..51fded087 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+# Copyright (c) 2012, 2015 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
@@ -29,72 +29,90 @@ BlockingFileSystemProxy_TimeoutReadingLink=Timeout while reading the link for ''
BlockingFileSystemProxy_TimeoutSymLink=Timeout while creating a link ''{0}'' for ''{1}''.
BlockingFileSystemProxy_TimeoutCopying=Timeout while copying files from ''{0}'' to ''{1}''.
BlockingFileSystemProxy_TimeoutGettingUser=Timeout while getting the user data.
-FSTreeNodeContentProvider_rootNode_label=File System
+
+CacheManager_MkdirFailed=Making directory {0} failed
+CacheManager_SetReadOnlyFailed=Setting the read-only attribute of {0} failed\!
+
+FileTransferService_error_mkdirFailed=Failed to create directory structure to {0}.
+
+FSTreeNodeContentProvider_rootNodeLabel=File System
+
FSTreeNode_TypeFile=File
FSTreeNode_TypeFileFolder=File Folder
FSTreeNode_TypeLocalDisk=Local Disk
FSTreeNode_TypeSystemFile=System file
FSTreeNode_TypeUnknownFile=Unknown File
-Operation_DeletingFileFailed=Deleting {0} failed\!
+FSTreeNodeWorkingCopy_commitOperation_name=Commit changes to {0}
+
+ModelManager_errorNoUserAccount=Cannot obtain user account for {0}
+ModelManager_errorOpenChannel=Cannot open channel for {0}
+
Operation_NotResponding=The TCF agent on the target {0} is probably down. It is not responding.
Operation_OpeningChannelFailureMessage=We cannot open a TCF channel to the target: {0}. It is caused by {1}.
Operation_NoFileSystemError=This TCF agent, {0}, does not provide a file system service\!
Operation_CannotOpenDir=Cannot open directory {0} because {1}
+Operation_CannotCreateDirectory=Cannot create directory {0}
Operation_CopyNOfFile=Copy ({0}) of {1}
Operation_CopyOfFile=Copy of {0}
-Operation_CannotCreateDirectory=Cannot create the directory {0} because: {1}
Operation_TimeoutOpeningChannel=Timeout while opening a channel\!
+OpStreamOp_Bytes=\ bytes
+OpStreamOp_KBs=\ KBs
+OpStreamOp_MBs=\ MBs
-OpCopy_Copying=Copying {0} ...
-OpCopy_CannotCopyFile=Cannot copy file {0} because: {1}
+OpCommitAttr_error_cannotSetAttributes=Cannot set attributes
+OpCommitAttr_name=Set file attributes:
+
+OpCopy_Copying=Copying {0}
+OpCopy_CannotCopyFile=Cannot copy file {0}
OpCopy_CopyingFile=Copying files
+OpCopy_error_noDirectory={0} exists and is not a directory
+OpCopy_error_noFile={0} exists and is not a file
-OpCreate_TaskName=Creating {0}...
-
-TcfURLConnection_NoFileHandleReturned=No file handle returned\!
-TcfURLConnection_NoPeerFound=Could not find the specified target with the ID {0}
-TcfURLConnection_NoSuchTcfAgent=TCF agent is already disconnected\!
+OpCreate_error_existingFile=Cannot create {0}, a file or folder with the same name already exists
+OpCreate_TaskName=Creating {0}
+OpCreateFile_error_create=Error creating file {0}
+OpCreateFolder_error_createFolder=Error creating folder {0}
OpDelete_Deleting=Deleting files
-OpDelete_PrepareToDelete=Prepare to delete files ...
-OpDelete_RemovingFileFolder=Removing {0} ...
+OpDelete_error_delete=Cannot delete {0}
+OpDelete_error_readDir=Cannot list directory {0}
+OpDelete_RemovingFileFolder=Removing {0}
OpDownload_Downloading=Downloading file {0}:{1}/{2}
-OpDownload_DownloadingMultipleFiles=Downloading {0} files...
OpDownload_DownloadingSingleFile=Downloading file {0}...
-OpMove_Moving=Moving {0} ...
-OpMove_FileExistsError=Cannot replace {0}: There is already a file with the same name as the folder you are moving.
-OpMove_FolderExistsError=Cannot replace {0}: There is already a folder with the same name as the file you are moving.
-OpMove_CannotMove=Cannot move {0} because {1}
+OpMove_Moving=Moving {0}
+OpMove_CannotMove=Cannot move {0}
OpMove_MovingFile=Moving files
-OpOutStreamOp_DownloadingProgress=Downloading {0}/{1}.
+OpParsePath_name=Restoring {0}
-OpRefresh_RefreshJobTitle=Refresh {0}
+OpRefresh_errorGetRoots=Cannot obtain root directories for {0}
+OpRefresh_errorOpenDir=Cannot list directory {0}
+OpRefresh_errorReadAttributes=Cannot read attributes of {0}
+OpRefresh_name=Refresh {0}
-OpRename_CannotRename=Cannot rename {0} because {1}
OpRename_TitleRename=Rename
-OpStreamOp_SetReadOnlyFailed=Setting the read-only attribute of {0} failed\!
-OpStreamOp_Bytes=\ bytes
-OpStreamOp_KBs=\ KBs
-OpStreamOp_MBs=\ MBs
+OpTargetFileDigest_error_download=Cannot download {0}
+OpTargetFileDigest_error_openFile=Cannot open file {0}
+OpUpload_error_openFile=Cannot open file {0}
+OpUpload_error_upload=Cannot upload {0}
OpUpload_UploadingProgress=Uploading file {0}: {1}/{2}
OpUpload_UploadNFiles=Uploading {0} files...
-OpUpload_UploadSingleFile=Uploading file {0}...
+OpUpload_UploadSingleFile=Uploading file {0}
TcfInputStream_NoDataAvailable=No data available
TcfInputStream_StreamClosed=Stream is already closed\!
TcfOutputStream_StreamClosed=Stream is already closed\!
+TcfURLConnection_NoFileHandleReturned=No file handle returned\!
+TcfURLConnection_NoPeerFound=Could not find the specified target with the ID {0}
+TcfURLConnection_NoSuchTcfAgent=TCF agent is already disconnected\!
+
TcfURLStreamHandlerService_ErrorURLFormat=Error TCF URL format\!
TcfURLStreamHandlerService_IllegalCharacter=A Windows path does not permit character {0}.
TcfURLStreamHandlerService_OnlyDiskPartError=A Windows path should not contain only disk part.
-
-CacheManager_MkdirFailed=Making directory {0} failed
-
-FileTransferService_error_mkdirFailed=Failed to create directory structure to {0}. \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
index 418991906..ab8b976d4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -42,7 +42,6 @@ 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.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.util.TCFFileInputStream;
import org.eclipse.tcf.util.TCFFileOutputStream;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/Operation.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/Operation.java
new file mode 100644
index 000000000..2533ebdc9
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/Operation.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2015 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.services;
+
+import java.net.ConnectException;
+import java.util.concurrent.TimeoutException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.te.tcf.core.Tcf;
+import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
+import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFChannelException;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.BlockingFileSystemProxy;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+
+/**
+ * Operation is the base class of file system operation classes.
+ * @see IOperation
+ */
+public class Operation {
+ // The default timeout waiting for blocked invocations.
+ public static final long DEFAULT_TIMEOUT = 60000L;
+
+
+ private Operation() {
+ }
+
+ /**
+ * Open a channel connected to the target represented by the peer.
+ *
+ * @return The channel or null if the operation fails.
+ */
+ public static IChannel openChannel(final IPeer peer) throws TCFChannelException {
+ final TCFChannelException[] errors = new TCFChannelException[1];
+ final IChannel[] channels = new IChannel[1];
+ final Rendezvous rendezvous = new Rendezvous();
+ Tcf.getChannelManager().openChannel(peer, null, new DoneOpenChannel() {
+ @Override
+ public void doneOpenChannel(Throwable error, IChannel channel) {
+ if (error != null) {
+ if (error instanceof ConnectException) {
+ String message = NLS.bind(Messages.Operation_NotResponding, peer.getID());
+ errors[0] = new TCFChannelException(IStatus.ERROR, message);
+ }
+ else if(!(error instanceof OperationCanceledException)) {
+ String message = NLS.bind(Messages.Operation_OpeningChannelFailureMessage, peer.getID(), error.getMessage());
+ errors[0] = new TCFChannelException(IStatus.OK, message, error);
+ }
+ }
+ else {
+ channels[0] = channel;
+ }
+ rendezvous.arrive();
+ }
+ });
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new TCFChannelException(IStatus.ERROR, Messages.Operation_TimeoutOpeningChannel);
+ }
+ if (errors[0] != null) {
+ throw errors[0];
+ }
+ return channels[0];
+ }
+
+ /**
+ * Get a blocking file system service from the channel. The
+ * returned file system service is a service that delegates the
+ * method call to the file system proxy. If the method returns
+ * asynchronously with a callback, it will block the call until
+ * the callback returns.
+ * <p>
+ * <em>Note: All the method of the returned file system
+ * service must be called outside of the dispatching thread.</em>
+ *
+ * @param channel The channel to get the file system service.
+ * @return The blocking file system service.
+ */
+ public static IFileSystem getBlockingFileSystem(final IChannel channel) {
+ if(Protocol.isDispatchThread()) {
+ IFileSystem service = channel.getRemoteService(IFileSystem.class);
+ return new BlockingFileSystemProxy(service);
+ }
+ final IFileSystem[] service = new IFileSystem[1];
+ Protocol.invokeAndWait(new Runnable(){
+ @Override
+ public void run() {
+ service[0] = getBlockingFileSystem(channel);
+ }});
+ return service[0];
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.jdt.core.prefs b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.jdt.core.prefs
index 086868ad1..430409041 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.jdt.core.prefs
@@ -1,5 +1,10 @@
-#Fri Oct 07 16:14:06 CEST 2011
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
@@ -15,9 +20,10 @@ org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.discouragedReference=error
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
@@ -31,7 +37,9 @@ org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
@@ -40,12 +48,18 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warni
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
@@ -55,10 +69,12 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
@@ -77,6 +93,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.6
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF
index a3e424fbf..45931577b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF
@@ -26,7 +26,8 @@ Require-Bundle: org.eclipse.compare;bundle-version="3.5.300",
org.eclipse.tcf.te.ui.swt;bundle-version="1.3.0",
org.eclipse.tcf.te.ui.views;bundle-version="1.3.0",
org.eclipse.tcf.te.ui.controls;bundle-version="1.3.0",
- org.eclipse.tcf.te.runtime.services;bundle-version="1.3.0"
+ org.eclipse.tcf.te.runtime.services;bundle-version="1.3.0",
+ org.eclipse.tcf.te.tcf.core.model;bundle-version="1.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
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 d06c202bb..393e9eb49 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
@@ -26,16 +26,16 @@
name="%navigatorContent.name"
priority="normal">
<triggerPoints>
- <instanceof
- value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
- </instanceof>
- <test
- property="org.eclipse.tcf.te.tcf.locator.hasRemoteService"
- value="FileSystem">
- </test>
+ <or>
+ <and>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ <test property="org.eclipse.tcf.te.tcf.locator.hasRemoteService" value="FileSystem"/>
+ </and>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
+ </or>
</triggerPoints>
<possibleChildren>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</possibleChildren>
<commonSorter
class="org.eclipse.tcf.te.tcf.filesystem.ui.controls.FSTreeViewerSorter"
@@ -46,7 +46,7 @@
id="org.eclipse.tcf.te.tcf.filesystem.dropAssistant">
<possibleDropTargets>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof></possibleDropTargets>
</dropAssistant>
<commonWizard
@@ -54,7 +54,7 @@
wizardId="org.eclipse.tcf.te.tcf.filesystem.wizards.NewFileWizard">
<enablement>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isDirectory">
@@ -68,7 +68,7 @@
wizardId="org.eclipse.tcf.te.tcf.filesystem.wizards.NewFolderWizard">
<enablement>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isDirectory">
@@ -138,7 +138,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -169,7 +169,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile"/>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isReadable">
@@ -195,7 +195,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -237,7 +237,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -260,7 +260,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -283,7 +283,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -313,7 +313,7 @@
ifEmpty="false"
operator="and">
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -340,7 +340,7 @@
ifEmpty="false"
operator="and">
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -366,7 +366,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -397,7 +397,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -428,7 +428,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -459,7 +459,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -494,7 +494,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -516,7 +516,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -544,7 +544,7 @@
<iterate operator="and" ifEmpty="false">
<and>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<not>
<test
@@ -568,7 +568,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile"/>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isReadable">
@@ -594,7 +594,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -635,7 +635,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<not>
<test
@@ -663,7 +663,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<not>
<test
@@ -691,7 +691,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<not>
<test
@@ -718,7 +718,7 @@
<with variable="selection">
<count value="+"/>
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<not>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isSystemRoot">
@@ -748,7 +748,7 @@
ifEmpty="false"
operator="and">
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
@@ -773,7 +773,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -804,7 +804,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -835,7 +835,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -866,7 +866,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<test
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile">
@@ -900,7 +900,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<not>
<test
@@ -927,7 +927,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<not>
<test
@@ -961,7 +961,7 @@
<enabledWhen>
<and>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
<not>
<test
@@ -1048,7 +1048,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test forcePluginActivation="true"
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile"/>
<test forcePluginActivation="true"
@@ -1065,7 +1065,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test forcePluginActivation="true"
property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile"/>
<test forcePluginActivation="true"
@@ -1091,7 +1091,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1101,7 +1101,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.getCacheState"
value="outdated"/>
@@ -1126,7 +1126,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1136,7 +1136,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.getCacheState"
value="modified"/>
@@ -1161,7 +1161,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1171,7 +1171,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.getCacheState"
value="conflict"/>
@@ -1196,7 +1196,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1206,7 +1206,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isFile"/>
<or>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.getCacheState"
@@ -1237,7 +1237,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1245,7 +1245,7 @@
<enabledWhen>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<not>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isRoot"/>
</not>
@@ -1283,7 +1283,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1291,7 +1291,7 @@
<enabledWhen>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isReadable"/>
<not>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isRoot"/>
@@ -1316,7 +1316,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1325,7 +1325,7 @@
<and>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<not>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isSystemRoot"/>
</not>
@@ -1348,7 +1348,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1356,7 +1356,7 @@
<enabledWhen>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<not>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isSystemRoot"/>
</not>
@@ -1394,7 +1394,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1403,7 +1403,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<not>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isSystemRoot"/>
</not>
@@ -1438,7 +1438,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1447,7 +1447,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<or>
<and>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isDirectory"/>
@@ -1473,7 +1473,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1482,7 +1482,7 @@
<with variable="selection">
<count value="1"/>
<iterate>
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<or>
<and>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isDirectory"/>
@@ -1516,7 +1516,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1524,7 +1524,7 @@
<enabledWhen>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<not>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isSystemRoot"/>
</not>
@@ -1562,7 +1562,7 @@
</with>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
</iterate>
</with>
</and>
@@ -1570,7 +1570,7 @@
<enabledWhen>
<with variable="selection">
<iterate ifEmpty="false" operator="and">
- <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/>
<or>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isSystemRoot"/>
<test property="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode.isRoot"/>
@@ -1672,7 +1672,7 @@
<!-- Adapter contributions -->
<extension point="org.eclipse.core.runtime.adapters">
<factory
- adaptableType="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"
+ adaptableType="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"
class="org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory">
<adapter type="org.eclipse.ui.IActionFilter"/>
<adapter type="org.eclipse.jface.viewers.ILabelProvider"/>
@@ -1707,7 +1707,7 @@
</count>
<iterate>
<instanceof
- value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode">
</instanceof>
</iterate>
</with>
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 00e34dac5..8246f28ee 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,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -11,7 +11,7 @@ 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.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
@@ -51,8 +51,8 @@ public class FSNavigatorContentProvider extends NavigatorContentProvider {
*/
@Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode)parentElement;
+ if (parentElement instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode)parentElement;
if (node.isFile()) return NO_ELEMENTS;
}
return super.getChildren(parentElement);
@@ -63,8 +63,8 @@ public class FSNavigatorContentProvider extends NavigatorContentProvider {
*/
@Override
public boolean hasChildren(final Object element) {
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode)element;
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode)element;
if(node.isFile()) {
return false;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSTreeViewerSorter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSTreeViewerSorter.java
index 2d53be057..1b72f6241 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSTreeViewerSorter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/FSTreeViewerSorter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -10,7 +10,7 @@
package org.eclipse.tcf.te.tcf.filesystem.ui.controls;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementComparator;
import org.eclipse.tcf.te.ui.trees.TreeViewerSorterCaseInsensitive;
@@ -32,7 +32,7 @@ public class FSTreeViewerSorter extends TreeViewerSorterCaseInsensitive {
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
- if (e1 instanceof FSTreeNode && e2 instanceof FSTreeNode) {
+ if (e1 instanceof IFSTreeNode && e2 instanceof IFSTreeNode) {
return comparator.compare(e1, e2);
}
return super.compare(viewer, e1, e2);
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 04416adba..73a90afae 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,15 +9,12 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.controls;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ITreeViewerListener;
import org.eclipse.jface.viewers.TreeExpansionEvent;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
@@ -32,17 +29,18 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl
*/
@Override
public Object getParent(Object element) {
- if (element instanceof AbstractTreeNode) {
- AbstractTreeNode node = (AbstractTreeNode) element;
- AbstractTreeNode parent = node.getParent();
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) element;
+ IFSTreeNode parent = node.getParent();
if (parent != null) {
- if (parent.isSystemRoot()) {
+ if (parent.isFileSystem()) {
if (isRootNodeVisible()) return parent;
return null;
}
return parent;
}
- if (isRootNodeVisible()) return node.peerNode;
+ if (isRootNodeVisible())
+ return node.getPeerNode();
}
return null;
}
@@ -61,13 +59,14 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl
*/
@Override
public void treeExpanded(TreeExpansionEvent event) {
- Object object = event.getElement();
- if(object instanceof AbstractTreeNode) {
- AbstractTreeNode parent = (AbstractTreeNode) object;
- if (parent.childrenQueried && !parent.childrenQueryRunning) {
- parent.refreshChildren();
- }
- }
+// Object object = event.getElement();
+// if(object instanceof IFSTreeNode) {
+// IFSTreeNode parent = (IFSTreeNode) object;
+// IFSTreeNode[] children = parent.getChildren();
+// if (children == null) {
+// parent.operationRefresh(false).runInJob(null);
+// }
+// }
}
/*
@@ -100,55 +99,48 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl
if (parentElement instanceof IPeerNode) {
final IPeerNode peerNode = (IPeerNode)parentElement;
IRuntimeModel model = ModelManager.getRuntimeModel(peerNode);
+ if (model == null)
+ return NO_ELEMENTS;
+
if (isRootNodeVisible()) {
- AbstractTreeNode root = model.getRoot();
- if(!root.childrenQueried && !root.childrenQueryRunning) {
- root.queryChildren();
- }
+ IFSTreeNode root = model.getRoot();
return new Object[] { root };
}
return getChildren(model.getRoot());
- } else if (parentElement instanceof AbstractTreeNode) {
- AbstractTreeNode node = (AbstractTreeNode)parentElement;
- List<Object> current = new ArrayList<Object>(node.getChildren());
- if (!node.childrenQueried) {
- current.add(getPending(node));
- if (!node.childrenQueryRunning) {
- node.queryChildren();
- }
+ } else if (parentElement instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode)parentElement;
+ if (!(node.isDirectory() || node.isFileSystem()))
+ return NO_ELEMENTS;
+
+ IFSTreeNode[] children = node.getChildren();
+ if (children == null) {
+ node.operationRefresh(false).runInJob(null);
+ return new Object[] {getPending(node)};
}
- return current.toArray();
+ return children;
}
return NO_ELEMENTS;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
@Override
public boolean hasChildren(final Object element) {
Assert.isNotNull(element);
- boolean hasChildren = false;
-
- if (element instanceof AbstractTreeNode) {
- AbstractTreeNode node = (AbstractTreeNode)element;
- if(node.isSystemRoot()) {
- hasChildren = true;
- }
- else {
- hasChildren = !node.childrenQueried || super.hasChildren(element);
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode)element;
+ if (node.isFileSystem() || node.isDirectory()) {
+ return node.getChildren() == null || super.hasChildren(element);
}
+ return false;
}
- else if (element instanceof IPeerNode) {
+
+ if (element instanceof IPeerNode) {
IPeerNode peerNode = (IPeerNode) element;
IRuntimeModel model = ModelManager.getRuntimeModel(peerNode);
- AbstractTreeNode root = model.getRoot();
- hasChildren = root != null ? hasChildren(root) : true;
+ return model != null;
}
-
- return hasChildren;
+ return false;
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/TreeContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/TreeContentProvider.java
index 3aa693cad..0957cfb96 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/TreeContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/TreeContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,8 +9,6 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.controls;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -35,7 +33,7 @@ import org.eclipse.tcf.te.ui.trees.Pending;
/**
* The base tree content provider that defines several default methods.
*/
-public abstract class TreeContentProvider implements ITreeContentProvider, PropertyChangeListener {
+public abstract class TreeContentProvider implements ITreeContentProvider {
/**
* Static reference to the return value representing no elements.
@@ -75,13 +73,6 @@ public abstract class TreeContentProvider implements ITreeContentProvider, Prope
return pending;
}
- /*
- * (non-Javadoc)
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- }
/*
* (non-Javadoc)
@@ -91,7 +82,6 @@ public abstract class TreeContentProvider implements ITreeContentProvider, Prope
public void dispose() {
for(IPropertyChangeProvider provider : providers) {
provider.removePropertyChangeListener(commonViewerListener);
- provider.removePropertyChangeListener(this);
}
commonViewerListener.cancel();
providers.clear();
@@ -144,10 +134,20 @@ public abstract class TreeContentProvider implements ITreeContentProvider, Prope
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (commonViewerListener != null) {
+ for (IPropertyChangeProvider provider : providers) {
+ provider.removePropertyChangeListener(commonViewerListener);
+ }
+ }
+
Assert.isTrue(viewer instanceof TreeViewer);
this.viewer = (TreeViewer) viewer;
this.commonViewerListener = new CommonViewerListener(this.viewer, this);
peerNode = getPeerNode(newInput);
+
+ for (IPropertyChangeProvider provider : providers) {
+ provider.addPropertyChangeListener(commonViewerListener);
+ }
}
protected IPeerNode getPeerNode(Object input) {
@@ -168,7 +168,6 @@ public abstract class TreeContentProvider implements ITreeContentProvider, Prope
if (commonViewerListener != null) {
provider.addPropertyChangeListener(commonViewerListener);
}
- provider.addPropertyChangeListener(this);
providers.add(provider);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSFolderSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSFolderSelectionDialog.java
index 4ce589429..4d028048b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSFolderSelectionDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/dialogs/FSFolderSelectionDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -38,8 +38,8 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel;
import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.filesystem.ui.controls.FSTreeContentProvider;
@@ -65,7 +65,7 @@ import org.eclipse.ui.dialogs.ISelectionStatusValidator;
* ElementTreeSelectionDialog.setInput</code> to specify the peer model of the remote target. In
* order to validate the destination folder, you should also specify the nodes to be moved. The file
* selection dialog is of single selection. You can get the selected result by calling
- * <code>getFirstResult</code>. The type of selected folder is an instance of FSTreeNode.
+ * <code>getFirstResult</code>. The type of selected folder is an instance of IFSTreeNode.
* </p>
* <p>
* The following is a snippet of example code:
@@ -76,17 +76,17 @@ import org.eclipse.ui.dialogs.ISelectionStatusValidator;
* dialog.setMovedNodes(nodes);
* if (dialog.open() == Window.OK) {
* Object obj = dialog.getFirstResult();
- * Assert.isTrue(obj instanceof FSTreeNode);
- * FSTreeNode folder = (FSTreeNode) obj;
+ * Assert.isTrue(obj instanceof IFSTreeNode);
+ * IFSTreeNode folder = (IFSTreeNode) obj;
* // Use folder ...
* }
* </pre>
*
* @see MoveFilesHandler
*/
-public class FSFolderSelectionDialog extends ElementTreeSelectionDialog {
+public final class FSFolderSelectionDialog extends ElementTreeSelectionDialog {
// The nodes that are being moved.
- private List<FSTreeNode> movedNodes;
+ private List<IFSTreeNode> movedNodes;
private final int mode;
public static final int MODE_ALL = 0;
@@ -144,8 +144,8 @@ public class FSFolderSelectionDialog extends ElementTreeSelectionDialog {
static class DirectoryFilter extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) element;
if(node.isFile()) return false;
}
return true;
@@ -186,7 +186,7 @@ public class FSFolderSelectionDialog extends ElementTreeSelectionDialog {
*
* @param movedNodes The nodes.
*/
- public void setMovedNodes(List<FSTreeNode> movedNodes) {
+ public void setMovedNodes(List<IFSTreeNode> movedNodes) {
this.movedNodes = movedNodes;
}
@@ -251,8 +251,8 @@ public class FSFolderSelectionDialog extends ElementTreeSelectionDialog {
Iterator<Object> it = ((IStructuredSelection)sel).iterator();
while (it.hasNext()) {
Object node = it.next();
- if (node instanceof FSTreeNode) {
- refreshNode((FSTreeNode)node);
+ if (node instanceof IFSTreeNode) {
+ refreshNode((IFSTreeNode)node);
}
else {
refreshModel();
@@ -265,34 +265,20 @@ public class FSFolderSelectionDialog extends ElementTreeSelectionDialog {
}
}
- protected void refreshNode(final FSTreeNode treeNode) {
- if (!treeNode.childrenQueryRunning) {
- treeNode.childrenQueried = false;
- treeNode.clearChildren();
- treeNode.refresh(new Callback() {
- @Override
- protected void internalDone(Object caller, IStatus status) {
- getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- getTreeViewer().refresh(treeNode, true);
- getTreeViewer().setSelection(getTreeViewer().getSelection());
- }
- });
- }
- });
- }
+ protected void refreshNode(final IFSTreeNode treeNode) {
+ treeNode.operationRefresh(true).runInJob(null);
}
protected void refreshModel() {
Object input = getTreeViewer().getInput();
if (input instanceof IPeerNode) {
- refreshNode(ModelManager.getRuntimeModel((IPeerNode)input).getRoot());
+ IRuntimeModel rtm = ModelManager.getRuntimeModel((IPeerNode)input);
+ if (rtm != null)
+ refreshNode(rtm.getRoot());
}
}
- private final static IStatus ok = new Status(IStatus.OK, UIPlugin.getUniqueIdentifier(), null);
private final static IStatus error = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), null);
private final static IStatus errorNotWritable = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), Messages.FSFolderSelectionDialog_notWritable_error);
private final static IStatus warningNotWritable = new Status(IStatus.WARNING, UIPlugin.getUniqueIdentifier(), Messages.FSFolderSelectionDialog_notWritable_warning);
@@ -307,23 +293,20 @@ public class FSFolderSelectionDialog extends ElementTreeSelectionDialog {
if (selection == null || selection.length == 0) {
return error;
}
- if (!(selection[0] instanceof FSTreeNode)) {
+ if (!(selection[0] instanceof IFSTreeNode)) {
return error;
}
- FSTreeNode target = (FSTreeNode) selection[0];
+ IFSTreeNode target = (IFSTreeNode) selection[0];
if (movedNodes != null) {
- for (FSTreeNode node : movedNodes) {
+ for (IFSTreeNode node : movedNodes) {
if (node == target || node.isAncestorOf(target)) {
return error;
}
}
}
if(mode != MODE_ALL && !target.isWritable()) {
- if (target.attr == null) {
- refreshNode(target);
- }
return mode == MODE_ONLY_WRITABLE ? errorNotWritable : warningNotWritable;
}
- return ok;
+ return Status.OK_STATUS;
}
}
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 5b2629c27..e461296af 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -25,8 +25,8 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.filesystem.ui.controls.FSTreeContentProvider;
@@ -122,15 +122,15 @@ public class FSOpenFileDialog extends ElementTreeSelectionDialog {
Object element = null;
IRuntimeModel model = ModelManager.getRuntimeModel((IPeerNode)viewer.getInput());
if (model != null) {
- FSTreeNode root = model.getRoot();
+ IFSTreeNode root = model.getRoot();
ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider();
Object[] elements = contentProvider.getElements(root);
String segment = path.getDevice() != null ? path.getDevice() : path.segmentCount() > 0 ? path.segment(0) : null;
if (segment != null) {
for (Object elem : elements) {
- if (!(elem instanceof FSTreeNode)) break;
- FSTreeNode child = (FSTreeNode)elem;
- String name = child.name;
+ if (!(elem instanceof IFSTreeNode)) break;
+ IFSTreeNode child = (IFSTreeNode)elem;
+ String name = child.getName();
if (name.endsWith("\\") || name.endsWith("/")) name = name.substring(0, name.length() - 1); //$NON-NLS-1$ //$NON-NLS-2$
boolean matches = child.isWindowsNode() ? name.equalsIgnoreCase(segment) : name.equals(segment);
if (matches) {
@@ -178,11 +178,11 @@ public class FSOpenFileDialog extends ElementTreeSelectionDialog {
*
* @return The matching file system node or <code>null</code>.
*/
- private FSTreeNode findRecursive(FSTreeNode parent, IPath path, int index) {
+ private IFSTreeNode findRecursive(IFSTreeNode parent, IPath path, int index) {
Assert.isNotNull(parent);
Assert.isNotNull(path);
- FSTreeNode node = null;
+ IFSTreeNode node = null;
ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider();
Object[] elements = contentProvider.getElements(parent);
@@ -196,9 +196,9 @@ public class FSOpenFileDialog extends ElementTreeSelectionDialog {
String segment = path.segment(index);
for (Object element : elements) {
- if (!(element instanceof FSTreeNode)) break;
- FSTreeNode child = (FSTreeNode)element;
- String name = child.name;
+ if (!(element instanceof IFSTreeNode)) break;
+ IFSTreeNode child = (IFSTreeNode)element;
+ String name = child.getName();
if (name.endsWith("\\") || name.endsWith("/")) name = name.substring(0, name.length() - 1); //$NON-NLS-1$ //$NON-NLS-2$
boolean matches = child.isWindowsNode() ? name.equalsIgnoreCase(segment) : name.equals(segment);
if (matches) {
@@ -251,10 +251,10 @@ public class FSOpenFileDialog extends ElementTreeSelectionDialog {
if (selection == null || selection.length == 0) {
return error;
}
- if (!(selection[0] instanceof FSTreeNode)) {
+ if (!(selection[0] instanceof IFSTreeNode)) {
return error;
}
- FSTreeNode target = (FSTreeNode) selection[0];
+ IFSTreeNode target = (IFSTreeNode) selection[0];
if(!target.isFile()) {
return error;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/HiddenFilesViewerFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/HiddenFilesViewerFilter.java
index fcd306e6c..a2d9f8530 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/HiddenFilesViewerFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/HiddenFilesViewerFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.filters;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* A filter implementation filtering hidden files or directories.
@@ -24,12 +24,12 @@ public class HiddenFilesViewerFilter extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
// The element needs to be a tree node, but not a root node
- if (element instanceof FSTreeNode && !((FSTreeNode)element).isRoot()) {
- FSTreeNode node = (FSTreeNode) element;
+ if (element instanceof IFSTreeNode && !((IFSTreeNode)element).isRootDirectory()) {
+ IFSTreeNode node = (IFSTreeNode) element;
if(node.isWindowsNode()) {
return !node.isHidden();
}
- return !node.name.startsWith("."); //$NON-NLS-1$
+ return !node.getName().startsWith("."); //$NON-NLS-1$
}
// Let pass all other elements unharmed
return true;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/SystemFilesViewerFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/SystemFilesViewerFilter.java
index fe805de7e..8335384c2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/SystemFilesViewerFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/filters/SystemFilesViewerFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.filters;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* A filter implementation filtering system files or directories.
@@ -24,9 +24,9 @@ public class SystemFilesViewerFilter extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
// The element needs to be a tree node, but not a root node
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode)element;
- return !node.isSystem();
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode)element;
+ return !node.isSystemFile();
}
// Let pass all other elements unharmed
return true;
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 6f2cf59af..2c7e59a06 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -17,7 +17,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
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;
@@ -29,20 +29,20 @@ import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.IPersistableElement;
/**
- * The adapter factory of <code>FSTreeNode</code> over <code>IActionFilter</code>
+ * The adapter factory of <code>IFSTreeNode</code> over <code>IActionFilter</code>
*/
public class FSTreeNodeAdapterFactory implements IAdapterFactory {
private static ILabelProvider nodeLabelProvider = new FSTreeElementLabelProvider();
// The fFilters map caching fFilters for FS nodes.
- private Map<FSTreeNode, NodeStateFilter> filters;
+ private Map<IFSTreeNode, NodeStateFilter> filters;
public static class FSTreeNodePeerNodeProvider extends PlatformObject implements IPeerNodeProvider {
- private final FSTreeNode node;
+ private final IFSTreeNode node;
/**
* Constructor
*/
- public FSTreeNodePeerNodeProvider(FSTreeNode node) {
+ public FSTreeNodePeerNodeProvider(IFSTreeNode node) {
Assert.isNotNull(node);
this.node = node;
}
@@ -52,7 +52,7 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory {
*
* @return The associated file system tree node.
*/
- public final FSTreeNode getFSTreeNode() {
+ public final IFSTreeNode getFSTreeNode() {
return node;
}
@@ -61,7 +61,7 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory {
*/
@Override
public final IPeerNode getPeerNode() {
- return node.peerNode;
+ return node.getPeerNode();
}
}
@@ -69,7 +69,7 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory {
* Constructor.
*/
public FSTreeNodeAdapterFactory() {
- this.filters = Collections.synchronizedMap(new HashMap<FSTreeNode, NodeStateFilter>());
+ this.filters = Collections.synchronizedMap(new HashMap<IFSTreeNode, NodeStateFilter>());
}
/*
@@ -78,8 +78,8 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory {
*/
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adaptableObject instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) adaptableObject;
+ if (adaptableObject instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) adaptableObject;
if (adapterType == IActionFilter.class) {
NodeStateFilter filter = filters.get(node);
if (filter == null) {
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 3b3a67e01..0e1c6b4c7 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -9,40 +9,42 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
+import static org.eclipse.tcf.te.tcf.locator.model.ModelManager.getPeerModel;
+
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-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.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager;
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.ModelManager;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IMemento;
/**
- * The element factory for FSTreeNode used to restore FSTreeNodes persisted
+ * The element factory for IFSTreeNode used to restore FSTreeNodes persisted
* for expanded states.
*/
public class FSTreeNodeFactory implements IElementFactory {
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
- */
@Override
public IAdaptable createElement(IMemento memento) {
String peerId = memento.getString("peerId"); //$NON-NLS-1$
- IPeerNode peerNode = ModelManager.getPeerModel().getService(IPeerModelLookupService.class).lkupPeerModelById(peerId);
- if(peerNode != null) {
- String path = memento.getString("path"); //$NON-NLS-1$
- if(path == null) {
- return org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager.getRuntimeModel(peerNode).getRoot();
- }
- OpParsePath op = new OpParsePath(peerNode, path);
- IOpExecutor executor = new NullOpExecutor();
- IStatus status = executor.execute(op);
- if(status.isOK()) {
- return op.getResult();
+ if (peerId == null)
+ return null;
+
+ for (IPeerNode peerNode : getPeerModel().getPeerNodes()) {
+ if (peerNode.getPeerId().equals(peerId)) {
+ IRuntimeModel rtm = ModelManager.getRuntimeModel(peerNode);
+ if (rtm != null) {
+ String path = memento.getString("path"); //$NON-NLS-1$
+ if (path == null) {
+ return rtm.getRoot();
+ }
+ IResultOperation<IFSTreeNode> op = rtm.operationRestoreFromPath(path);
+ if (op.run(null).isOK()) {
+ return op.getResult();
+ }
+ }
+ return null;
}
}
return null;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeLoader.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeLoader.java
index e04fc7740..5f766df5f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeLoader.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeLoader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -12,64 +12,41 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.NullOpExecutor;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRefreshRoots;
-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.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.ui.interfaces.ILazyLoader;
/**
- * The implementation of ILazyLoader for FSTreeNode check its data availability
+ * The implementation of ILazyLoader for IFSTreeNode check its data availability
* and load its children if not ready.
*/
public class FSTreeNodeLoader implements ILazyLoader {
// The node to be checked.
- private FSTreeNode node;
+ private IFSTreeNode node;
/**
* Constructor
- *
+ *
* @param node The file/folder node.
*/
- public FSTreeNodeLoader(FSTreeNode node) {
+ public FSTreeNodeLoader(IFSTreeNode node) {
this.node = node;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ILazyLoader#isDataLoaded()
- */
@Override
public boolean isDataLoaded() {
- return node.isFile() || (node.isSystemRoot() || node.isDirectory()) && node.childrenQueried;
+ return node.getChildren() != null;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ILazyLoader#loadData(org.eclipse.core.runtime.IProgressMonitor)
- */
@Override
public void loadData(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- if(node.isFile()) return;
- if (node.isSystemRoot()) {
- new NullOpExecutor().execute(new OpRefreshRoots(node));
- }
- else {
- new Operation().getChildren(node);
- }
- }
- catch (TCFException e) {
- throw new InvocationTargetException(e);
- }
+ node.operationRefresh(false).run(monitor);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ILazyLoader#isLeaf()
- */
@Override
public boolean isLeaf() {
- return node.isFile();
+ IFSTreeNode[] children = node.getChildren();
+ if (children != null) {
+ return children.length == 0;
+ }
+ return node.isFile();
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java
index 1ca440246..528fe7c62 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -12,18 +12,18 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
import java.util.List;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpClipboard;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
-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.operations.FsClipboard;
import org.eclipse.ui.IActionFilter;
/**
- * This action filter wraps an FSTreeNode and test its attribute of "cache.state".
+ * This action filter wraps an IFSTreeNode and test its attribute of "cache.state".
* It serves as the expression filter of decorations of Target Explorer.
*/
public class NodeStateFilter implements IActionFilter {
- private FSTreeNode node;
+ private IFSTreeNode node;
/**
* Constructor.
@@ -31,7 +31,7 @@ public class NodeStateFilter implements IActionFilter {
* @param node
* The wrapped tree node. Must not be <code>null</code>.
*/
- public NodeStateFilter(FSTreeNode node) {
+ public NodeStateFilter(IFSTreeNode node) {
Assert.isNotNull(node);
this.node = node;
}
@@ -50,11 +50,11 @@ public class NodeStateFilter implements IActionFilter {
return value.equals(state.name());
}
else if (name.equals("edit.cut")) { //$NON-NLS-1$
- OpClipboard cb = UIPlugin.getClipboard();
+ FsClipboard cb = UIPlugin.getClipboard();
if (!cb.isEmpty()) {
if (cb.isCutOp()) {
- List<FSTreeNode> files = cb.getFiles();
- for (FSTreeNode file : files) {
+ List<IFSTreeNode> files = cb.getFiles();
+ for (IFSTreeNode file : files) {
if (node == file) return true;
}
}
@@ -63,12 +63,12 @@ public class NodeStateFilter implements IActionFilter {
else if (name.equals("hidden")) { //$NON-NLS-1$
if (value == null) value = "true"; //$NON-NLS-1$
boolean result = false;
- if (!node.isRoot()) {
+ if (!node.isRootDirectory()) {
if (node.isWindowsNode()) {
result = node.isHidden();
}
else {
- result = node.name.startsWith("."); //$NON-NLS-1$
+ result = node.getName().startsWith("."); //$NON-NLS-1$
}
}
return Boolean.toString(result).equals(value);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PersistableNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PersistableNode.java
index 8cc6698d4..0366e967c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PersistableNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/PersistableNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -9,23 +9,23 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPersistableElement;
/**
- * The adapter class of FSTreeNode for IPersistableElement, used to
- * persist an FSTreeNode.
+ * The adapter class of IFSTreeNode for IPersistableElement, used to
+ * persist an IFSTreeNode.
*/
public class PersistableNode implements IPersistableElement {
// The node to be persisted.
- private FSTreeNode node;
+ private IFSTreeNode node;
/**
* Create an instance.
- *
+ *
* @param node The node to be persisted.
*/
- public PersistableNode(FSTreeNode node) {
+ public PersistableNode(IFSTreeNode node) {
this.node = node;
}
@@ -35,9 +35,9 @@ public class PersistableNode implements IPersistableElement {
*/
@Override
public void saveState(IMemento memento) {
- memento.putString("peerId", node.peerNode.getPeerId()); //$NON-NLS-1$
+ memento.putString("peerId", node.getPeerNode().getPeerId()); //$NON-NLS-1$
String path = null;
- if (!node.isSystemRoot()) path = node.getLocation();
+ if (!node.isFileSystem()) path = node.getLocation();
if (path != null) memento.putString("path", path); //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java
index 74ec4d7d8..139f28625 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -21,13 +21,9 @@ import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.util.SafeRunnable;
-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.internal.operations.OpUpload;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor;
import org.eclipse.ui.IEditorInput;
@@ -44,12 +40,12 @@ import org.eclipse.ui.handlers.HandlerUtil;
*/
public class SaveAllListener implements IExecutionListener {
// Dirty nodes that should be saved and synchronized.
- List<FSTreeNode> fDirtyNodes;
+ List<IFSTreeNode> fDirtyNodes;
/**
* Create the listener listening to command "SAVE ALL".
*/
public SaveAllListener() {
- this.fDirtyNodes = new ArrayList<FSTreeNode>();
+ this.fDirtyNodes = new ArrayList<IFSTreeNode>();
}
/* (non-Javadoc)
@@ -59,29 +55,15 @@ public class SaveAllListener implements IExecutionListener {
public void postExecuteSuccess(String commandId, Object returnValue) {
if (!fDirtyNodes.isEmpty()) {
if (UIPlugin.isAutoSaving()) {
- FSTreeNode[] nodes = fDirtyNodes.toArray(new FSTreeNode[fDirtyNodes.size()]);
- IOpExecutor executor = new UiExecutor();
- executor.execute(new OpUpload(nodes));
- }
- else {
- SafeRunner.run(new SafeRunnable(){
- @Override
- public void handleException(Throwable e) {
- // Ignore exception
- }
- @Override
- public void run() throws Exception {
- for (FSTreeNode dirtyNode : fDirtyNodes) {
- dirtyNode.refresh();
- }
- }});
+ UiExecutor.execute(ModelManager.operationUpload(fDirtyNodes));
+ } else {
+ for (IFSTreeNode dirtyNode : fDirtyNodes) {
+ dirtyNode.operationRefresh(false).runInJob(null);
+ }
}
}
}
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IExecutionListener#preExecute(java.lang.String, org.eclipse.core.commands.ExecutionEvent)
- */
@Override
public void preExecute(String commandId, ExecutionEvent event) {
fDirtyNodes.clear();
@@ -92,7 +74,7 @@ public class SaveAllListener implements IExecutionListener {
IEditorPart[] editors = page.getDirtyEditors();
for (IEditorPart editor : editors) {
IEditorInput input = editor.getEditorInput();
- FSTreeNode node = null;
+ IFSTreeNode node = null;
if (input instanceof IURIEditorInput) {
//Get the file that is being edited.
IURIEditorInput fileInput = (IURIEditorInput) input;
@@ -102,15 +84,15 @@ public class SaveAllListener implements IExecutionListener {
File localFile = store.toLocalFile(0, new NullProgressMonitor());
if (localFile != null) {
// Get the file's mapped FSTreeNode.
- OpParsePath parser = new OpParsePath(localFile.getCanonicalPath());
- new NullOpExecutor().execute(parser);
+ IResultOperation<IFSTreeNode> parser = ModelManager.operationRestoreFromPath(localFile.getCanonicalPath());
+ parser.run(null);
node = parser.getResult();
if (node != null) {
// If it is a modified node, add it to the dirty node list.
fDirtyNodes.add(node);
}
}
- }catch(Exception e){}
+ } catch(Exception e){}
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java
index 670beb8fb..ad75ae799 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -21,11 +21,9 @@ import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.util.SafeRunnable;
-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.internal.operations.OpUpload;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor;
import org.eclipse.ui.IEditorInput;
@@ -38,7 +36,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
*/
public class SaveListener implements IExecutionListener {
// Dirty node that should be committed or merged.
- FSTreeNode dirtyNode;
+ IFSTreeNode dirtyNode;
/**
* Create a SaveListener listening to command "SAVE".
@@ -53,8 +51,7 @@ public class SaveListener implements IExecutionListener {
public void postExecuteSuccess(String commandId, Object returnValue) {
if (dirtyNode != null) {
if (UIPlugin.isAutoSaving()) {
- IOpExecutor executor = new UiExecutor();
- executor.execute(new OpUpload(dirtyNode));
+ UiExecutor.execute(dirtyNode.operationUploadContent(dirtyNode.getCacheFile()));
}
else {
SafeRunner.run(new SafeRunnable(){
@@ -64,7 +61,8 @@ public class SaveListener implements IExecutionListener {
}
@Override
public void run() throws Exception {
- if (dirtyNode != null) dirtyNode.refresh();
+ if (dirtyNode != null)
+ dirtyNode.operationRefresh(false).runInJob(null);
}
});
}
@@ -85,8 +83,8 @@ public class SaveListener implements IExecutionListener {
IFileStore store = EFS.getStore(uri);
File localFile = store.toLocalFile(0, new NullProgressMonitor());
if (localFile != null) {
- OpParsePath parser = new OpParsePath(localFile.getCanonicalPath());
- new NullOpExecutor().execute(parser);
+ IResultOperation<IFSTreeNode> parser = ModelManager.operationRestoreFromPath(localFile.getCanonicalPath());
+ parser.run(null);
dirtyNode = parser.getResult();
}
}catch(Exception e){
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellModifier.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellModifier.java
index b1da8c4ad..b76b4f015 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellModifier.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellModifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -12,11 +12,8 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.celleditor;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.swt.widgets.Item;
-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.OpRename;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.RenameCallback;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor;
/**
* FSCellModifier is an <code>ICellModifier</code> of the file system tree of the target explorer.
@@ -38,9 +35,9 @@ public class FSCellModifier implements ICellModifier {
if (element instanceof Item) {
element = ((Item) element).getData();
}
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
- if (!node.isRoot()) {
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) element;
+ if (!node.isRootDirectory()) {
return node.isWindowsNode() && !node.isReadOnly() || !node.isWindowsNode() && node.isWritable();
}
}
@@ -58,9 +55,9 @@ public class FSCellModifier implements ICellModifier {
if (element instanceof Item) {
element = ((Item) element).getData();
}
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
- return node.name;
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) element;
+ return node.getName();
}
}
return null;
@@ -77,13 +74,11 @@ public class FSCellModifier implements ICellModifier {
if (element instanceof Item) {
element = ((Item) element).getData();
}
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) element;
Assert.isTrue(value != null && value instanceof String);
String newName = (String) value;
- // Rename the node with the new name using an FSRename.
- IOpExecutor executor = new JobExecutor(new RenameCallback());
- executor.execute(new OpRename(node, newName));
+ UiExecutor.execute(node.operationRename(newName));
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellValidator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellValidator.java
index 85b3de181..4bb211780 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellValidator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/celleditor/FSCellValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,13 +9,11 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.celleditor;
-import java.util.List;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
/**
@@ -48,12 +46,12 @@ public class FSCellValidator implements ICellEditorValidator {
public String isValid(Object value) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Object element = selection.getFirstElement();
- Assert.isTrue(element instanceof FSTreeNode);
- FSTreeNode node = (FSTreeNode) element;
+ Assert.isTrue(element instanceof IFSTreeNode);
+ IFSTreeNode node = (IFSTreeNode) element;
if (value == null) return Messages.FSRenamingAssistant_SpecifyNonEmptyName;
String text = value.toString().trim();
if (text.length() == 0) return Messages.FSRenamingAssistant_SpecifyNonEmptyName;
- if (hasChild(node, text)) {
+ if (hasSibbling(node, text)) {
return Messages.FSRenamingAssistant_NameAlreadyExists;
}
String formatRegex = node.isWindowsNode() ? WIN_FILENAME_REGEX : UNIX_FILENAME_REGEX;
@@ -69,13 +67,19 @@ public class FSCellValidator implements ICellEditorValidator {
* @param name The name.
* @return true if it has a child with the name.
*/
- private boolean hasChild(FSTreeNode folder, String name) {
- List<FSTreeNode> nodes = folder.getParent().getChildren();
- for (FSTreeNode node : nodes) {
+ private boolean hasSibbling(IFSTreeNode folder, String name) {
+ IFSTreeNode[] nodes = folder.getParent().getChildren();
+ if (nodes == null) {
+ return false;
+ }
+ for (IFSTreeNode node : nodes) {
if (node.isWindowsNode()) {
- if (node.name.equalsIgnoreCase(name)) return true;
+ if (node.getName().equalsIgnoreCase(name)) {
+ return true;
+ }
+ } else if (node.getName().equals(name)) {
+ return true;
}
- else if (node.name.equals(name)) return true;
}
return false;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeComparator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeComparator.java
index 29374e19c..343e2aba7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeComparator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,7 +9,7 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* The comparator for the tree column "Date Accessed".
@@ -19,12 +19,12 @@ public class AccessTimeComparator extends FSTreeNodeComparator {
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.FSTreeNodeComparator#doCompare(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode, org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.FSTreeNodeComparator#doCompare(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode, org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public int doCompare(FSTreeNode node1, FSTreeNode node2) {
- long atime1 = node1.attr != null ? node1.attr.atime : 0;
- long atime2 = node2.attr != null ? node2.attr.atime : 0;
+ public int doCompare(IFSTreeNode node1, IFSTreeNode node2) {
+ long atime1 = node1.getAccessTime();
+ long atime2 = node2.getAccessTime();
return atime1 < atime2 ? -1 : (atime1 > atime2 ? 1 : 0);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeLabelProvider.java
index ab84b5d73..68bc0cc85 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/AccessTimeLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* The label provider for the tree column "Date Accessed".
@@ -26,11 +26,12 @@ public class AccessTimeLabelProvider extends LabelProvider {
*/
@Override
public String getText(Object element) {
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
- if (node.attr != null) {
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) element;
+ long atime = node.getAccessTime();
+ if (atime != 0) {
SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yyyy h:mm aa"); //$NON-NLS-1$
- return dateFormat.format(new Date(node.attr.atime));
+ return dateFormat.format(new Date(atime));
}
}
return ""; //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/CacheFileImageUpdater.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/CacheFileImageUpdater.java
index 24f70fb77..2d1286bfa 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/CacheFileImageUpdater.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/CacheFileImageUpdater.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -11,8 +11,8 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
import java.io.File;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager;
/**
* The image update adapter that updates the images of the file which
@@ -21,33 +21,33 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
public class CacheFileImageUpdater implements ImageUpdateAdapter {
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getImageKey(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getImageKey(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public String getImageKey(FSTreeNode node) {
+ public String getImageKey(IFSTreeNode node) {
return node.getLocationURL().toExternalForm();
}
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getMirrorFile(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getMirrorFile(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public File getMirrorFile(FSTreeNode node) {
- return CacheManager.getCacheFile(node);
+ public File getMirrorFile(IFSTreeNode node) {
+ return node.getCacheFile();
}
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getImgFile(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getImgFile(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public File getImageFile(FSTreeNode node) {
- File cacheFile = CacheManager.getCacheFile(node);
+ public File getImageFile(IFSTreeNode node) {
+ File cacheFile = node.getCacheFile();
File parentDir = cacheFile.getParentFile();
if (!parentDir.exists() && !parentDir.mkdirs()) {
- parentDir = CacheManager.getCacheRoot();
+ parentDir = ModelManager.getCacheRoot();
}
- return new File(parentDir, node.name + ".png"); //$NON-NLS-1$
+ return new File(parentDir, node.getName() + ".png"); //$NON-NLS-1$
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/DefaultImageProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/DefaultImageProvider.java
index 2f3b78a81..07bc7e7b5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/DefaultImageProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/DefaultImageProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.ImageConsts;
import org.eclipse.ui.IEditorRegistry;
@@ -20,7 +20,7 @@ import org.eclipse.ui.PlatformUI;
/**
* The default implementation of ImageProvider, defining the images
- * based on predefined images based on the node simulator.
+ * based on predefined images based on the node simulator.
*/
public class DefaultImageProvider implements ImageProvider {
// The editor registry used to search a file's image.
@@ -28,14 +28,14 @@ public class DefaultImageProvider implements ImageProvider {
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageProvider#getImage(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageProvider#getImage(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public Image getImage(FSTreeNode node) {
- if (node.isSystemRoot()) {
+ public Image getImage(IFSTreeNode node) {
+ if (node.isFileSystem()) {
return UIPlugin.getImage(ImageConsts.ROOT);
}
- else if (node.isRoot()) {
+ else if (node.isRootDirectory()) {
return UIPlugin.getImage(ImageConsts.ROOT_DRIVE);
}
else if (node.isDirectory()) {
@@ -50,13 +50,13 @@ public class DefaultImageProvider implements ImageProvider {
/**
* Get a predefined image for the tree node. These images are retrieved from
* editor registry.
- *
+ *
* @param node The file tree node.
* @return The editor image for this simulator.
*/
- protected Image getPredefinedImage(FSTreeNode node) {
+ protected Image getPredefinedImage(IFSTreeNode node) {
Image image;
- String key = node.name;
+ String key = node.getName();
image = UIPlugin.getImage(key);
if (image == null) {
ImageDescriptor descriptor = getEditorRegistry().getImageDescriptor(key);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementComparator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementComparator.java
index 5ad79dca1..7be26ef0e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementComparator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,7 +9,7 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* The comparator for the tree column "name".
@@ -19,12 +19,12 @@ public class FSTreeElementComparator extends FSTreeNodeComparator {
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.FSTreeNodeComparator#doCompare(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode, org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.FSTreeNodeComparator#doCompare(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode, org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public int doCompare(FSTreeNode node1, FSTreeNode node2) {
- String name1 = node1.name;
- String name2 = node2.name;
+ public int doCompare(IFSTreeNode node1, IFSTreeNode node2) {
+ String name1 = node1.getName();
+ String name2 = node2.getName();
if (name1 != null && name2 != null) {
if (name1.startsWith(".") && !name2.startsWith(".")) return -1; //$NON-NLS-1$ //$NON-NLS-2$
if (!name1.startsWith(".") && name2.startsWith(".")) return 1; //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementLabelProvider.java
index 3ae7d9ae4..f9c4c993a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeElementLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
import org.eclipse.tcf.te.runtime.utils.Host;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.ui.trees.PendingAwareLabelProvider;
@@ -41,8 +41,8 @@ public class FSTreeElementLabelProvider extends PendingAwareLabelProvider {
*/
@Override
public String getText(Object element) {
- if (element instanceof FSTreeNode) {
- return ((FSTreeNode) element).name;
+ if (element instanceof IFSTreeNode) {
+ return ((IFSTreeNode) element).getName();
}
else if (element instanceof IModelNode) {
return ((IModelNode)element).getName();
@@ -57,8 +57,8 @@ public class FSTreeElementLabelProvider extends PendingAwareLabelProvider {
*/
@Override
public Image getImage(Object element) {
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) element;
return imgProvider.getImage(node);
}
else if (element instanceof IModelNode) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeNodeComparator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeNodeComparator.java
index 4aaad28d0..d9fea2ab4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeNodeComparator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FSTreeNodeComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
import java.io.Serializable;
import java.util.Comparator;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* The base comparator for all the file system tree column.
@@ -26,30 +26,19 @@ public abstract class FSTreeNodeComparator implements Comparator<Object>, Serial
*/
@Override
public final int compare(Object o1, Object o2) {
- if (!(o1 instanceof FSTreeNode) || !(o2 instanceof FSTreeNode)) return 0;
+ if (!(o1 instanceof IFSTreeNode) || !(o2 instanceof IFSTreeNode))
+ return 0;
- FSTreeNode node1 = (FSTreeNode)o1;
- FSTreeNode node2 = (FSTreeNode)o2;
-
- // Get the type labels
- String type1 = node1.type;
- String type2 = node2.type;
+ IFSTreeNode node1 = (IFSTreeNode)o1;
+ IFSTreeNode node2 = (IFSTreeNode)o2;
// Group directories and files always together before sorting by name
- if ((node1.isRoot() || node1.isDirectory()) && !(node2.isRoot() || node2.isDirectory())) {
- return -1;
- }
-
- if ((node2.isRoot() || node2.isDirectory()) && !(node1.isRoot() || node1.isDirectory())) {
- return 1;
- }
-
- // If the nodes are of the same type and one entry starts
- // with a '.', it comes before the one without a '.'
- if (type1 != null && type2 != null && type1.equals(type2)) {
- return doCompare(node1, node2);
- }
- return 0;
+ boolean d1 = node1.isDirectory();
+ boolean d2 = node2.isDirectory();
+ if (d1 != d2)
+ return d1 ? -1 : 1;
+
+ return doCompare(node1, node2);
}
/**
@@ -59,5 +48,5 @@ public abstract class FSTreeNodeComparator implements Comparator<Object>, Serial
* @param node2 The second node.
* @return The comparison result.
*/
- public abstract int doCompare(FSTreeNode node1, FSTreeNode node2);
+ public abstract int doCompare(IFSTreeNode node1, IFSTreeNode node2);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileExtBasedImageUpdater.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileExtBasedImageUpdater.java
index 90ca5dbe7..c1fd7e4d9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileExtBasedImageUpdater.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileExtBasedImageUpdater.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
import java.io.File;
import java.io.IOException;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* The image update adapter that updates the images of the file which does
@@ -21,33 +21,33 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
public class FileExtBasedImageUpdater implements ImageUpdateAdapter {
// The label provider update daemon
private LabelProviderUpdateDaemon updateDaemon;
-
+
/**
* Create an instance with the specified daemon.
- *
+ *
* @param daemon The label provider update daemon.
*/
public FileExtBasedImageUpdater(LabelProviderUpdateDaemon daemon) {
this.updateDaemon = daemon;
}
-
+
/**
* Get the node's file extension or null if there is no extension.
- *
+ *
* @param node The file tree node.
* @return The file's extension or null.
*/
- private String getFileExt(FSTreeNode node) {
- String name = node.name;
+ private String getFileExt(IFSTreeNode node) {
+ String name = node.getName();
String ext = "noext"; //$NON-NLS-1$
int index = name.lastIndexOf("."); //$NON-NLS-1$
if (index != -1) ext = name.substring(index + 1);
return ext;
}
-
+
/**
* Get the directory to store the temporary mirror files.
- *
+ *
* @return The directory to contain the mirror files.
*/
private File getMirrorDir() {
@@ -61,20 +61,20 @@ public class FileExtBasedImageUpdater implements ImageUpdateAdapter {
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getImageKey(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getImageKey(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public String getImageKey(FSTreeNode node) {
+ public String getImageKey(IFSTreeNode node) {
String ext = getFileExt(node);
return "EXT_IMAGE@" + ext; //$NON-NLS-1$
}
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getMirrorFile(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getMirrorFile(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public File getMirrorFile(FSTreeNode node) {
+ public File getMirrorFile(IFSTreeNode node) {
String ext = getFileExt(node);
File mrrDir = getMirrorDir();
File file = new File(mrrDir, "mirror" + "." + ext); //$NON-NLS-1$ //$NON-NLS-2$
@@ -90,10 +90,10 @@ public class FileExtBasedImageUpdater implements ImageUpdateAdapter {
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getImgFile(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.ImageUpdateAdapter#getImgFile(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public File getImageFile(FSTreeNode node) {
+ public File getImageFile(IFSTreeNode node) {
String ext = getFileExt(node);
return updateDaemon.getTempImg(ext);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeComparator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeComparator.java
index 8b53a6bed..2cd986ee6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeComparator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -9,7 +9,7 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* The comparator for the tree column "simulator".
@@ -19,12 +19,12 @@ public class FileTypeComparator extends FSTreeNodeComparator {
/*
* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.FSTreeNodeComparator#doCompare(org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode, org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode)
+ * @see org.eclipse.tcf.te.tcf.filesystem.internal.columns.FSTreeNodeComparator#doCompare(org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode, org.eclipse.tcf.te.tcf.filesystem.model.IFSTreeNode)
*/
@Override
- public int doCompare(FSTreeNode node1, FSTreeNode node2) {
- String type1 = node1.getFileType();
- String type2 = node2.getFileType();
+ public int doCompare(IFSTreeNode node1, IFSTreeNode node2) {
+ String type1 = node1.getFileTypeLabel();
+ String type2 = node2.getFileTypeLabel();
return type1.compareTo(type2);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeLabelProvider.java
index d97fa3d31..32a2feaa1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/FileTypeLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2015 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
@@ -10,22 +10,22 @@
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* The label provider for the tree column "simulator".
*/
public class FileTypeLabelProvider extends LabelProvider {
-
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(Object element) {
- if (element instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) element;
- return node.getFileType();
+ if (element instanceof IFSTreeNode) {
+ IFSTreeNode node = (IFSTreeNode) element;
+ return node.getFileTypeLabel();
}
return super.getText(element);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageProvider.java
index 9ec98b0c8..68d83c05e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -10,19 +10,19 @@
package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* An image provider provides platform specific images for each files/folders.
- * It is used by FSTreeElementLabelProvider to provide the images of a file
+ * It is used by FSTreeElementLabelProvider to provide the images of a file
* node.
*/
public interface ImageProvider {
/**
* Get the image display for the specified file node.
- *
+ *
* @param node The file node.
* @return The image that represents the file node.
*/
- Image getImage(FSTreeNode node);
+ Image getImage(IFSTreeNode node);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageUpdateAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageUpdateAdapter.java
index 1457868ad..1a3e81dd4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageUpdateAdapter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/ImageUpdateAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -11,7 +11,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns;
import java.io.File;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode;
/**
* The interface to adapt the process of providing the image for two kinds of
@@ -20,27 +20,26 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
public interface ImageUpdateAdapter {
/**
- * Get an extension key as the image registry key for the
+ * Get an extension key as the image registry key for the
* specified node.
- *
+ *
* @param node The node to get the key for.
* @return The key used to cache the image descriptor in the registry.
*/
- public String getImageKey(FSTreeNode node);
-
+ public String getImageKey(IFSTreeNode node);
+
/**
* Return a mirror file that will be used to retrieve the image from.
- *
+ *
* @param node The file system tree node.
* @return The corresponding mirror file.
*/
- public File getMirrorFile(FSTreeNode node);
+ public File getMirrorFile(IFSTreeNode node);
/**
* Get the image file object for the specified temporary file name.
- *
- * @param tmpName The temporary file name.
+ *
* @return The file object.
*/
- public File getImageFile(FSTreeNode node);
+ public File getImageFile(IFSTreeNode node);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/LabelProviderUpdateDaemon.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/LabelProviderUpdateDaemon.java
index 5f5e04860..1c7a6a5e5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/LabelProviderUpdateDaemon.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/LabelProviderUpdateDaemon.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 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
@@ -30,8 +30,8 @@ import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-impo