diff --git a/releng/org.eclipse.rse.build/maps/rse.map b/releng/org.eclipse.rse.build/maps/rse.map
index 1502d484dab..c4ebb3b362e 100644
--- a/releng/org.eclipse.rse.build/maps/rse.map
+++ b/releng/org.eclipse.rse.build/maps/rse.map
@@ -33,7 +33,7 @@ plugin@org.eclipse.rse.efs.ui=v20080606,:pserver:anonymous:none@dev.eclipse.org:
plugin@org.eclipse.rse.examples.daytime=v20080604,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/examples/org.eclipse.rse.examples.daytime
plugin@org.eclipse.rse.examples.tutorial=v20080604,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/examples/org.eclipse.rse.examples.tutorial
plugin@org.eclipse.rse.files.ui=v200902011800,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui
-plugin@org.eclipse.rse.importexport=v200902011800,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.importexport
+plugin@org.eclipse.rse.importexport=v200902061200,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.importexport
plugin@org.eclipse.rse.processes.ui=v200902011800,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.processes.ui
plugin@org.eclipse.rse.remotecdt=v200902011800,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/examples/org.eclipse.rse.remotecdt
plugin@org.eclipse.rse.sdk=v200902011800,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.sdk
diff --git a/rse/plugins/org.eclipse.rse.importexport/.classpath b/rse/plugins/org.eclipse.rse.importexport/.classpath
index ce73933404a..64c5e31b7a2 100644
--- a/rse/plugins/org.eclipse.rse.importexport/.classpath
+++ b/rse/plugins/org.eclipse.rse.importexport/.classpath
@@ -1,7 +1,7 @@
null
*/
@@ -773,8 +820,8 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste
if (root.getLocation().isPrefixOf(testPath)) return "workspace root"; //UniversalSystemPlugin.getString("IFSexport.rootName"); //$NON-NLS-1$
IProject[] projects = root.getProjects();
for (int i = 0; i < projects.length; i++) {
- IPath loc = projects[i].getLocation();
- if (loc != null && loc.isPrefixOf(testPath))
+ IPath loc = projects[i].getLocation();
+ if (loc != null && loc.isPrefixOf(testPath))
return projects[i].getName();
}
return null;
@@ -877,8 +924,8 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste
if (msgLine != null)
msgLine.setErrorMessage(exc);
else {
- String msgTxt = CommonMessages.MSG_ERROR_UNEXPECTED;
- SystemMessage msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
+ String msgTxt = CommonMessages.MSG_ERROR_UNEXPECTED;
+ SystemMessage msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
ICommonMessageIds.MSG_ERROR_UNEXPECTED,
IStatus.ERROR, msgTxt, exc);
@@ -899,7 +946,7 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste
// ((SystemDialogPageMessageLine)msgLine).internalSetErrorMessage(message);
}
- /**
+ /**
* ISystemMessageLine method.
* If the message line currently displays an error,
* the message is stored and will be shown after a call to clearErrorMessage
@@ -923,6 +970,6 @@ class RemoteExportWizardPage1 extends WizardExportResourcesPage implements Liste
if (msgLine != null) msgLine.setMessage(message);
// super.setMessage(message);
// if (msgLine!=null)
- // ((SystemDialogPageMessageLine)msgLine).internalSetMessage(message);
+ // ((SystemDialogPageMessageLine)msgLine).internalSetMessage(message);
}
}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportActionDelegate.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportActionDelegate.java
index 09dfd07eae4..832d73aa6c8 100644
--- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportActionDelegate.java
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileExportActionDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,10 +11,10 @@
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
+ * Takuya Miyamoto - [185925] Integrate Platform/Team Synchronization
*******************************************************************************/
package org.eclipse.rse.internal.importexport.files;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@@ -26,18 +26,16 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.IAction;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.rse.internal.importexport.IRemoteImportExportConstants;
import org.eclipse.rse.internal.importexport.RemoteImportExportPlugin;
import org.eclipse.rse.internal.importexport.RemoteImportExportProblemDialog;
import org.eclipse.rse.internal.importexport.RemoteImportExportResources;
-import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.rse.internal.synchronize.SynchronizeData;
+import org.eclipse.rse.internal.synchronize.provisional.ISynchronizeOperation;
+import org.eclipse.rse.internal.synchronize.provisional.SynchronizeOperation;
+import org.eclipse.rse.internal.synchronize.provisional.Synchronizer;
/**
- * This class is a remote file export action.
+ * This class is a remote file export action.
*/
public class RemoteFileExportActionDelegate extends RemoteFileImportExportActionDelegate {
/**
@@ -50,7 +48,7 @@ public class RemoteFileExportActionDelegate extends RemoteFileImportExportAction
if (length < 1) {
return;
}
- // create read multi status
+ // create read multi status
String message;
if (length > 1) {
message = RemoteImportExportResources.IMPORT_EXPORT_ERROR_CREATE_FILES_FAILED;
@@ -127,30 +125,38 @@ public class RemoteFileExportActionDelegate extends RemoteFileImportExportAction
}
private IStatus export(RemoteFileExportData[] exportDatas) {
- IStatus status = null;
- for (int i = 0; i < exportDatas.length; i++) {
- RemoteFileExportOperation op = new RemoteFileExportOperation(exportDatas[i], new RemoteFileOverwriteQuery());
- try {
- PlatformUI.getWorkbench().getProgressService().run(true, true, op);
- status = op.getStatus();
- } catch (InvocationTargetException e) {
- SystemBasePlugin.logError("Error occured trying to export", e); //$NON-NLS-1$
- status = new Status(IStatus.ERROR, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, "", e); //$NON-NLS-1$
- } catch (InterruptedException e) {
- SystemBasePlugin.logError("Error occured trying to export", e); //$NON-NLS-1$
- status = new Status(IStatus.OK, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, "", e); //$NON-NLS-1$
- }
- if (!status.isOK()) {
- String msgTxt = NLS.bind(RemoteImportExportResources.FILEMSG_EXPORT_FAILED, status);
-
- SystemMessage msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
- IRemoteImportExportConstants.FILEMSG_EXPORT_FAILED,
- IStatus.ERROR, msgTxt);
+// IStatus status = null;
+// for (int i = 0; i < exportDatas.length; i++) {
+// RemoteFileExportOperation op = new RemoteFileExportOperation(exportDatas[i], new RemoteFileOverwriteQuery());
+// try {
+// PlatformUI.getWorkbench().getProgressService().run(true, true, op);
+// status = op.getStatus();
+// } catch (InvocationTargetException e) {
+// SystemBasePlugin.logError("Error occured trying to export", e); //$NON-NLS-1$
+// status = new Status(IStatus.ERROR, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, "", e); //$NON-NLS-1$
+// } catch (InterruptedException e) {
+// SystemBasePlugin.logError("Error occured trying to export", e); //$NON-NLS-1$
+// status = new Status(IStatus.OK, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, "", e); //$NON-NLS-1$
+// }
+// if (!status.isOK()) {
+// String msgTxt = NLS.bind(RemoteImportExportResources.FILEMSG_EXPORT_FAILED, status);
+//
+// SystemMessage msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
+// IRemoteImportExportConstants.FILEMSG_EXPORT_FAILED,
+// IStatus.ERROR, msgTxt);
+//
+// SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
+// dlg.openWithDetails();
+// return null;
+// }
+// }
+// return null;
- SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
- dlg.openWithDetails();
- return null;
- }
+ // Add re-running synchronize operation
+ for (int i = 0; i < exportDatas.length; i++) {
+ SynchronizeData data = new SynchronizeData(exportDatas[i]);
+ data.setSynchronizeType(ISynchronizeOperation.SYNC_MODE_UI_REVIEW);
+ new Synchronizer(data).run(new SynchronizeOperation());
}
return null;
}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportActionDelegate.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportActionDelegate.java
index eb7cfdc8b3f..1abb83c4bdb 100644
--- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportActionDelegate.java
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteFileImportActionDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,10 +11,10 @@
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
+ * Takuya Miyamoto - [185925] Integrate Platform/Team Synchronization
*******************************************************************************/
package org.eclipse.rse.internal.importexport.files;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@@ -26,18 +26,17 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.IAction;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.rse.internal.importexport.IRemoteImportExportConstants;
import org.eclipse.rse.internal.importexport.RemoteImportExportPlugin;
import org.eclipse.rse.internal.importexport.RemoteImportExportProblemDialog;
import org.eclipse.rse.internal.importexport.RemoteImportExportResources;
-import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.SystemBasePlugin;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.rse.internal.synchronize.SynchronizeData;
+import org.eclipse.rse.internal.synchronize.provisional.ISynchronizeOperation;
+import org.eclipse.rse.internal.synchronize.provisional.SynchronizeOperation;
+import org.eclipse.rse.internal.synchronize.provisional.Synchronizer;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
/**
- * This class is a remote file import action.
+ * This class is a remote file import action.
*/
public class RemoteFileImportActionDelegate extends RemoteFileImportExportActionDelegate {
/**
@@ -50,7 +49,7 @@ public class RemoteFileImportActionDelegate extends RemoteFileImportExportAction
if (length < 1) {
return;
}
- // create read multi status
+ // create read multi status
String message;
if (length > 1) {
message = RemoteImportExportResources.IMPORT_EXPORT_ERROR_CREATE_FILES_FAILED;
@@ -127,36 +126,51 @@ public class RemoteFileImportActionDelegate extends RemoteFileImportExportAction
}
private IStatus importFiles(RemoteFileImportData[] importDatas) {
- IStatus status = null;
+// IStatus status = null;
+// for (int i = 0; i < importDatas.length; i++) {
+// RemoteFileImportOperation op = new RemoteFileImportOperation(importDatas[i], FileSystemStructureProvider.INSTANCE, new RemoteFileOverwriteQuery());
+// try {
+// PlatformUI.getWorkbench().getProgressService().run(true, true, op);
+// status = op.getStatus();
+// } catch (InvocationTargetException e) {
+// SystemBasePlugin.logError("Error occured trying to import", e); //$NON-NLS-1$
+// status = new Status(IStatus.ERROR, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, "", e); //$NON-NLS-1$
+// } catch (InterruptedException e) {
+// SystemBasePlugin.logError("Error occured trying to import", e); //$NON-NLS-1$
+// status = new Status(IStatus.OK, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, "", e); //$NON-NLS-1$
+// }
+// if (!status.isOK()) {
+// String msgTxt = NLS.bind(RemoteImportExportResources.FILEMSG_IMPORT_FAILED, status);
+// Throwable e = status.getException();
+// SystemMessage msg = null;
+// if (e != null){
+// msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
+// IRemoteImportExportConstants.FILEMSG_IMPORT_FAILED,
+// IStatus.ERROR, msgTxt, e);
+// } else {
+// msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
+// IRemoteImportExportConstants.FILEMSG_IMPORT_FAILED,
+// IStatus.ERROR, msgTxt);
+// }
+//
+// SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
+// dlg.openWithDetails();
+// return null;
+// }
+// }
+// return null;
+
for (int i = 0; i < importDatas.length; i++) {
- RemoteFileImportOperation op = new RemoteFileImportOperation(importDatas[i], FileSystemStructureProvider.INSTANCE, new RemoteFileOverwriteQuery());
try {
- PlatformUI.getWorkbench().getProgressService().run(true, true, op);
- status = op.getStatus();
- } catch (InvocationTargetException e) {
- SystemBasePlugin.logError("Error occured trying to import", e); //$NON-NLS-1$
- status = new Status(IStatus.ERROR, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, "", e); //$NON-NLS-1$
- } catch (InterruptedException e) {
- SystemBasePlugin.logError("Error occured trying to import", e); //$NON-NLS-1$
- status = new Status(IStatus.OK, RemoteImportExportPlugin.getDefault().getBundle().getSymbolicName(), 0, "", e); //$NON-NLS-1$
- }
- if (!status.isOK()) {
- String msgTxt = NLS.bind(RemoteImportExportResources.FILEMSG_IMPORT_FAILED, status);
- Throwable e = status.getException();
- SystemMessage msg = null;
- if (e != null){
- msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
- IRemoteImportExportConstants.FILEMSG_IMPORT_FAILED,
- IStatus.ERROR, msgTxt, e);
- } else {
- msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
- IRemoteImportExportConstants.FILEMSG_IMPORT_FAILED,
- IStatus.ERROR, msgTxt);
- }
-
- SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
- dlg.openWithDetails();
- return null;
+ SynchronizeData data = new SynchronizeData(importDatas[i]);
+ data.setSynchronizeType(ISynchronizeOperation.SYNC_MODE_UI_REVIEW);
+ new Synchronizer(data).run(new SynchronizeOperation());
+ } catch (SystemMessageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
}
return null;
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteImportWizardPage1.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteImportWizardPage1.java
index 63a066e6c62..82bf433f3e1 100644
--- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteImportWizardPage1.java
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteImportWizardPage1.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,10 +14,12 @@
* David McKnight (IBM) - [219792] use background query when doing import
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
* David McKnight (IBM) - [219792][importexport][ftp] RSE hangs on FTP import
+ * Takuya Miyamoto - [185925] Integrate Platform/Team Synchronization
*******************************************************************************/
package org.eclipse.rse.internal.importexport.files;
import java.io.File;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,6 +33,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -56,10 +59,16 @@ import org.eclipse.rse.internal.importexport.RemoteImportExportPlugin;
import org.eclipse.rse.internal.importexport.RemoteImportExportResources;
import org.eclipse.rse.internal.importexport.RemoteImportExportUtil;
import org.eclipse.rse.internal.importexport.SystemImportExportResources;
+import org.eclipse.rse.internal.synchronize.RSESyncUtils;
+import org.eclipse.rse.internal.synchronize.SynchronizeData;
+import org.eclipse.rse.internal.synchronize.provisional.ISynchronizeOperation;
+import org.eclipse.rse.internal.synchronize.provisional.SynchronizeOperation;
+import org.eclipse.rse.internal.synchronize.provisional.Synchronizer;
import org.eclipse.rse.services.clientserver.messages.CommonMessages;
import org.eclipse.rse.services.clientserver.messages.ICommonMessageIds;
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.SystemWidgetHelpers;
@@ -97,13 +106,13 @@ import org.eclipse.ui.model.WorkbenchContentProvider;
* Page 1 of the base resource import-from-file-system Wizard
*/
class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listener, ISystemWizardPage {
-
+
private class DummyProvider implements ISelectionProvider {
public void addSelectionChangedListener(
ISelectionChangedListener listener) {
// TODO Auto-generated method stub
-
+
}
public ISelection getSelection() {
@@ -114,15 +123,15 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
public void removeSelectionChangedListener(
ISelectionChangedListener listener) {
// TODO Auto-generated method stub
-
+
}
public void setSelection(ISelection selection) {
// TODO Auto-generated method stub
-
- }
+
+ }
}
-
+
private class QueryAllJob extends Job
{
private Object _fileSystemObject;
@@ -137,7 +146,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
_element = element;
}
-
+
public IStatus run(IProgressMonitor monitor){
_isActive = true;
query(_fileSystemObject, _element, monitor);
@@ -150,33 +159,33 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
});
return Status.OK_STATUS;
}
-
+
public boolean isActive()
{
return _isActive;
}
-
-
+
+
private void query(Object parent, MinimizedFileSystemElement element, IProgressMonitor monitor){
-
+
if (monitor.isCanceled()){
return;
}
-
+
List children = _provider.getChildren(parent);
if (children == null) children = new ArrayList(1);
Iterator childrenEnum = children.iterator();
-
+
List resultsToQuery = new ArrayList();
-
+
while (childrenEnum.hasNext()) {
Object child = childrenEnum.next();
String elementLabel = _provider.getLabel(child);
//Create one level below
MinimizedFileSystemElement result = new MinimizedFileSystemElement(elementLabel, element, _provider.isFolder(child));
result.setFileSystemObject(child);
-
+
if (child instanceof UniFilePlus){
if (((UniFilePlus)child).isDirectory()){
resultsToQuery.add(result);
@@ -189,31 +198,31 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
Display.getDefault().asyncExec(new Runnable(){
public void run(){
DummyProvider provider = new DummyProvider();
-
+
ISelection sel1 = new StructuredSelection(_element.getParent());
SelectionChangedEvent evt1 = new SelectionChangedEvent(provider, sel1);
selectionGroup.selectionChanged(evt1);
-
- ISelection sel2 = new StructuredSelection(_element);
+
+ ISelection sel2 = new StructuredSelection(_element);
SelectionChangedEvent evt2 = new SelectionChangedEvent(provider, sel2);
selectionGroup.selectionChanged(evt2);
}
});
}
-
+
for (int i = 0; i < resultsToQuery.size(); i++) {
MinimizedFileSystemElement celement = (MinimizedFileSystemElement)resultsToQuery.get(i);
query(celement.getFileSystemObject(), celement, monitor);
celement.setPopulated(true);
}
-
+
element.setPopulated(true);
}
-
+
}
-
-
-
+
+
+
private Object sourceDirectory = null;
private String helpId;
private Composite parentComposite;
@@ -222,6 +231,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
private String pendingString, pendingErrorString;
protected Composite sourceComposite;
protected Combo sourceNameField;
+ protected Button reviewSynchronizeCheckbox;
protected Button overwriteExistingResourcesCheckbox;
protected Button createContainerStructureButton;
protected Button createOnlySelectedButton;
@@ -235,10 +245,10 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
protected Button deselectAllButton;
// a boolean to indicate if the user has typed anything
private boolean entryChanged = false;
-
+
private QueryAllJob _queryAllJob;
private MinimizedFileSystemElement _fileSystemTree;
-
+
// input object
protected Object inputObject = null;
// flag to indicate whether initial selection was used to set source field
@@ -285,14 +295,14 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
* including button presses and registers
* default buttons with its shell.
* The button id is stored as the buttons client data.
- * Note that the parent's layout is assumed to be a GridLayout and
+ * Note that the parent's layout is assumed to be a GridLayout and
* the number of columns in this layout is incremented.
* Subclasses may override.
*
IDialogConstants.*_ID
constants
+ * IDialogConstants.*_ID
constants
* for standard dialog button ids)
* @param label the label from the button
* @param defaultButton true
if the button is to be the
@@ -396,13 +406,13 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
// SystemWidgetHelpers.setWizardPageMnemonics((Composite)c);
// parentComposite = (Composite)c;
// if (helpId != null)
- // SystemWidgetHelpers.setHelp(parentComposite, helpId);
+ // SystemWidgetHelpers.setHelp(parentComposite, helpId);
// }
// else if (c instanceof Button)
// {
// Mnemonics ms = new Mnemonics();
// ms.setMnemonic((Button)c);
- // }
+ // }
// configureMessageLine();
}
@@ -410,6 +420,9 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
* Create the import options specification widgets.
*/
protected void createOptionsGroupButtons(Group optionsGroup) {
+ reviewSynchronizeCheckbox = SystemWidgetHelpers.createCheckBox(optionsGroup, 1, null, SystemImportExportResources.RESID_FILEIMPORT_REVIEW_LABEL,
+ SystemImportExportResources.RESID_FILEIMPORT_REVIEW_TOOLTIP);
+ reviewSynchronizeCheckbox.addListener(SWT.Selection, this);
overwriteExistingResourcesCheckbox = SystemWidgetHelpers.createCheckBox(optionsGroup, 1, null, SystemImportExportResources.RESID_FILEIMPORT_OPTION_OVERWRITE_LABEL,
SystemImportExportResources.RESID_FILEIMPORT_OPTION_OVERWRITE_TOOLTIP);
createContainerStructureButton = SystemWidgetHelpers.createRadioButton(optionsGroup, null, SystemImportExportResources.RESID_FILEIMPORT_OPTION_CREATEALL_LABEL,
@@ -516,24 +529,24 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
protected MinimizedFileSystemElement createRootElement(Object fileSystemObject, IImportStructureProvider provider) {
boolean isContainer = provider.isFolder(fileSystemObject);
String elementLabel = provider.getLabel(fileSystemObject);
-
+
// Use an empty label so that display of the element's full name
// doesn't include a confusing label
MinimizedFileSystemElement dummyParent = new MinimizedFileSystemElement("", null, true); //$NON-NLS-1$
MinimizedFileSystemElement result = new MinimizedFileSystemElement(elementLabel, dummyParent, isContainer);
result.setFileSystemObject(fileSystemObject);
-
+
if (_queryAllJob == null){
_queryAllJob = new QueryAllJob(fileSystemObject, provider, result);
_queryAllJob.schedule();
}
-
+
////Get the files for the element so as to build the first level
//result.getFiles(provider);
return dummyParent;
}
-
+
/**
* Create the import source specification widgets
@@ -562,8 +575,8 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
if (((File) sourceDirectory).isDirectory()) return true;
String msgTxt = RemoteImportExportResources.FILEMSG_FOLDER_IS_FILE;
String msgDetails = NLS.bind(RemoteImportExportResources.FILEMSG_FOLDER_IS_FILE_DETAILS, ((File)sourceDirectory).getAbsolutePath());
-
- SystemMessage msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
+
+ SystemMessage msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
IRemoteImportExportConstants.FILEMSG_FOLDER_IS_FILE,
IStatus.ERROR, msgTxt, msgDetails);
setErrorMessage(msg);
@@ -586,18 +599,18 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
IStatus status = op.getStatus();
if (!status.isOK()) {
String msgTxt = NLS.bind(RemoteImportExportResources.FILEMSG_IMPORT_FAILED, status);
-
+
SystemMessage msg = null;
if (status.getException() != null){
- msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
+ msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
IRemoteImportExportConstants.FILEMSG_IMPORT_FAILED,
IStatus.ERROR, msgTxt, status.getException());
} else {
- msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
+ msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
IRemoteImportExportConstants.FILEMSG_IMPORT_FAILED,
IStatus.ERROR, msgTxt);
}
-
+
SystemMessageDialog dlg = new SystemMessageDialog(getContainer().getShell(), msg);
dlg.openWithDetails();
return false;
@@ -642,13 +655,53 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
data.setCreateSelectionOnly(createOnlySelectedButton.getSelection());
data.setSaveSettings(saveSettingsButton.getSelection());
data.setDescriptionFilePath(getDescriptionLocation());
- boolean ret = executeImportOperation(new RemoteFileImportOperation(data, FileSystemStructureProvider.INSTANCE, this));
- return ret;
+
+ if (!reviewSynchronizeCheckbox.getSelection()) {
+ boolean ret = executeImportOperation(new RemoteFileImportOperation(data, FileSystemStructureProvider.INSTANCE, this));
+ return ret;
+ } else {
+ // run synchronization
+ SynchronizeData data2 = null;
+ try {
+ data2 = new SynchronizeData(data);
+ } catch (SystemMessageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (reviewSynchronizeCheckbox.getSelection()) {
+ data2.setSynchronizeType(ISynchronizeOperation.SYNC_MODE_UI_REVIEW_INITIAL);
+ }
+
+ boolean ret = false;
+
+ try {
+ ret = new Synchronizer(data2).run(new SynchronizeOperation());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // save description after synchronize operation
+ try {
+ if (data.isSaveSettings()) {
+ RSESyncUtils.saveDescription(data);
+ }
+ } catch (CoreException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ return ret;
+ }
}
String msgTxt = RemoteImportExportResources.FILEMSG_IMPORT_NONE_SELECTED;
String msgDetails = RemoteImportExportResources.FILEMSG_IMPORT_NONE_SELECTED_DETAILS;
-
- SystemMessage msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
+
+ SystemMessage msg = new SimpleSystemMessage(RemoteImportExportPlugin.PLUGIN_ID,
IRemoteImportExportConstants.FILEMSG_IMPORT_NONE_SELECTED,
IStatus.ERROR, msgTxt, msgDetails);
setErrorMessage(msg);
@@ -657,9 +710,9 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
-
+
/**
- * Returns a content provider for FileSystemElement
s that returns
+ * Returns a content provider for FileSystemElement
s that returns
* only files as children.
*/
protected ITreeContentProvider getFileProvider() {
@@ -693,7 +746,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
protected MinimizedFileSystemElement getFileSystemTree() {
File sourceDirectory = getSourceDirectory();
if (sourceDirectory == null) return null;
-
+
if (_fileSystemTree == null){
_fileSystemTree = selectFiles(sourceDirectory, FileSystemStructureProvider.INSTANCE);
}
@@ -701,7 +754,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
}
/**
- * Returns a content provider for FileSystemElement
s that returns
+ * Returns a content provider for FileSystemElement
s that returns
* only folders as children.
*/
protected ITreeContentProvider getFolderProvider() {
@@ -740,13 +793,13 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
}
/**
- * Returns this page's collection of currently-specified resources to be
- * imported. This is the primary resource selection facility accessor for
+ * Returns this page's collection of currently-specified resources to be
+ * imported. This is the primary resource selection facility accessor for
* subclasses.
*
* Added here to allow access for inner classes.
*
- * @return a collection of resources currently selected
+ * @return a collection of resources currently selected
* for export (element type: IResource
)
*/
protected List getSelectedResources() {
@@ -839,7 +892,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
action.setShowNewConnectionPrompt(true);
action.setShowPropertySheet(true, false);
action.setFoldersOnly(true);
- action.run();
+ action.run();
IRemoteFile folder = action.getSelectedFolder();
if (folder != null) {
clearErrorMessage();
@@ -946,7 +999,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
RemoteImportWizard parentWizard = (RemoteImportWizard) getWizard();
boolean isInitializingFromImportData = parentWizard.getInitializeFromImportData();
if (!isInitializingFromImportData) {
- // radio buttons and checkboxes
+ // radio buttons and checkboxes
overwriteExistingResourcesCheckbox.setSelection(settings.getBoolean(STORE_OVERWRITE_EXISTING_RESOURCES_ID));
boolean createStructure = settings.getBoolean(STORE_CREATE_CONTAINER_STRUCTURE_ID);
createContainerStructureButton.setSelection(createStructure);
@@ -1013,7 +1066,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
if (sourceNames == null) sourceNames = new String[0];
sourceNames = addToHistory(sourceNames, getSourceDirectoryName());
settings.put(STORE_SOURCE_NAMES_ID, sourceNames);
- // radio buttons and checkboxes
+ // radio buttons and checkboxes
settings.put(STORE_OVERWRITE_EXISTING_RESOURCES_ID, overwriteExistingResourcesCheckbox.getSelection());
settings.put(STORE_CREATE_CONTAINER_STRUCTURE_ID, createContainerStructureButton.getSelection());
settings.put(STORE_CREATE_DESCRIPTION_FILE_ID, isSaveSettings());
@@ -1131,7 +1184,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
};
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InterruptedException {
-
+
String msg = RemoteImportExportResources.FILEMSG_IMPORT_FILTERING;
monitor.beginTask(msg, IProgressMonitor.UNKNOWN);
getSelectedResources(filter, monitor);
@@ -1147,13 +1200,13 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
//Got interrupted. Do nothing.
return;
}
- // make sure that all paint operations caused by closing the progress
- // dialog get flushed, otherwise extra pixels will remain on the screen until
+ // make sure that all paint operations caused by closing the progress
+ // dialog get flushed, otherwise extra pixels will remain on the screen until
// updateSelections is completed
getShell().update();
// The updateSelections method accesses SWT widgets so cannot be executed
// as part of the above progress dialog operation since the operation forks
- // a new process.
+ // a new process.
updateSelections(selectionMap);
}
@@ -1219,13 +1272,13 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
//Got interrupted. Do nothing.
return;
}
- // make sure that all paint operations caused by closing the progress
- // dialog get flushed, otherwise extra pixels will remain on the screen until
+ // make sure that all paint operations caused by closing the progress
+ // dialog get flushed, otherwise extra pixels will remain on the screen until
// updateSelections is completed
getShell().update();
// The updateSelections method accesses SWT widgets so cannot be executed
// as part of the above progress dialog operation since the operation forks
- // a new process.
+ // a new process.
updateSelections(selectionMap);
}
@@ -1270,6 +1323,12 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
descFilePathField.setEnabled(isSaveSettings);
descFileBrowseButton.setEnabled(isSaveSettings);
}
+
+ // if review is selected, the other options are grayed out without save settings
+ boolean isReview = reviewSynchronizeCheckbox.getSelection();
+ overwriteExistingResourcesCheckbox.setEnabled(!isReview);
+ createContainerStructureButton.setEnabled(!isReview);
+ createOnlySelectedButton.setEnabled(!isReview);
// this calls to determine whether page can be completed
super.updateWidgetEnablements();
}
@@ -1371,7 +1430,7 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
* Returns whether the source location conflicts
* with the destination resource. This will occur if
* the source is already under the destination.
- *
+ *
* @param sourcePath the path to check
* @return true
if there is a conflict, false
if not
*/
@@ -1403,14 +1462,14 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
public boolean performFinish() {
return finish();
}
-
+
public void cancel() {
if (_queryAllJob != null && _queryAllJob.isActive()){
_queryAllJob.cancel();
}
}
-
-
+
+
/* (non-Javadoc)
* @see com.ibm.etools.systems.core.ui.wizards.ISystemWizardPage#setHelp(java.lang.String)
@@ -1429,14 +1488,14 @@ class RemoteImportWizardPage1 extends WizardResourceImportPage implements Listen
// ----------------
// INTERNAL METHODS
- // ----------------
+ // ----------------
/**
* Internal method false
.
+ *
+ * @param resources
+ * the resources to be checked out
+ * @param depth
+ * the depth of the checkout
+ * @param progress
+ * a progress monitor
+ * @throws TeamException
+ */
+ public void checkout(IResource[] resources, int depth, IProgressMonitor progress) throws TeamException {
+ try {
+ progress = Policy.monitorFor(progress);
+ progress.beginTask(Policy.bind("FileSystemSimpleAccessOperations.1"), resources.length); //$NON-NLS-1$
+ for (int i = 0; i < resources.length; i++) {
+ Policy.checkCanceled(progress);
+ resources[i].accept(new IResourceVisitor() {
+ public boolean visit(IResource resource) throws CoreException {
+ if (resource.getType() == IResource.FILE) {
+ // TODO: lock the file on the' server'.
+ resource.getResourceAttributes().setReadOnly(false);
+ }
+ return true;
+ }
+ }, depth, false /* include phantoms */);
+ progress.worked(1);
+ }
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ } finally {
+ progress.done();
+ }
+ }
+
+ /**
+ * Check-in the given resources to the given depth by replacing the remote
+ * (i.e. file system) contents with the local workspace contents.
+ *
+ * @param resources
+ * the resources
+ * @param depth
+ * the depth of the operation
+ * @param overrideIncoming
+ * indicate whether incoming remote changes should be replaced
+ * @param progress
+ * a progress monitor
+ * @throws TeamException
+ */
+ public void checkin(IResource[] resources, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
+ try {
+ // ensure the progress monitor is not null
+ progress = Policy.monitorFor(progress);
+ progress.beginTask(Policy.bind("PutAction.working"), 100); //$NON-NLS-1$
+ // Refresh the subscriber so we have the latest remote state
+ FileSystemSubscriber.getInstance().refresh(resources, depth, new SubProgressMonitor(progress, 30));
+ internalPut(resources, depth, overrideIncoming, new SubProgressMonitor(progress, 70));
+ } finally {
+ progress.done();
+ }
+ }
+
+ /**
+ * Check-in the given resources to the given depth by replacing the remote
+ * (i.e. file system) contents with the local workspace contents.
+ *
+ * @param traversals
+ * the traversals that cover the resources to check in
+ * @param overrideIncoming
+ * indicate whether incoming remote changes should be replaced
+ * @param progress
+ * a progress monitor
+ * @throws TeamException
+ */
+ public void checkin(ResourceTraversal[] traversals, boolean overrideIncoming, IProgressMonitor monitor) throws TeamException {
+ try {
+ // ensure the progress monitor is not null
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 100 * traversals.length);
+ for (int i = 0; i < traversals.length; i++) {
+ ResourceTraversal traversal = traversals[i];
+ checkin(traversal.getResources(), traversal.getDepth(), overrideIncoming, new SubProgressMonitor(monitor, 100));
+ // update to the latest state
+ FileSystemSubscriber.getInstance().refresh(traversal.getResources(), traversal.getDepth(), null);
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /**
+ * Return whether the local resource is checked out. A resource is checked
+ * out if it is a file that is not read-only. Folders are always checked
+ * out.
+ *
+ * @param resource
+ * the resource
+ * @return whether the resource is checked out and can be modified
+ */
+ public boolean isCheckedOut(IResource resource) {
+ if (resource.getType() != IResource.FILE) {
+ return true;
+ }
+ return !resource.getResourceAttributes().isReadOnly();
+ // return !resource.isReadOnly();
+ }
+
+ /*
+ * Get the resource variant for the given resource.
+ */
+ private FileSystemResourceVariant getExportResourceVariant(IResource resource) {
+ // return
+ // (FileSystemResourceVariant)provider.getResourceVariant(resource);
+ return (FileSystemResourceVariant) getProvider(resource).getExportResourceVariant(resource);
+ }
+
+ private FileSystemResourceVariant getImportResourceVariant(IResource resource){
+ return (FileSystemResourceVariant) getProvider(resource).getImportResourcevariant(resource);
+ }
+
+ private void internalGet(IResource[] resources, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
+ // Traverse the resources and get any that are out-of-sync
+ // System.out.println("get operation");
+ progress.beginTask(Policy.bind("GetAction.working"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ for (int i = 0; i < resources.length; i++) {
+ Policy.checkCanceled(progress);
+ if (resources[i].getType() == IResource.FILE) {
+ internalGet((IFile) resources[i], overrideOutgoing, progress);
+ } else if (depth != IResource.DEPTH_ZERO) {
+ internalGet((IContainer) resources[i], depth, overrideOutgoing, progress);
+ }
+ progress.worked(1);
+ }
+ }
+
+ /*
+ * Get the folder and its children to the depth specified.
+ */
+ private void internalGet(IContainer container, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
+ try {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ // Make the local folder state match the remote folder state
+ List toDelete = new ArrayList();
+ if (container.getType() == IResource.FOLDER) {
+ IFolder folder = (IFolder) container;
+// FileSystemResourceVariant remote = getExportResourceVariant(container);
+ FileSystemResourceVariant remote = getImportResourceVariant(container);
+ if (!folder.exists() && remote != null) {
+ // Create the local folder
+// folder.create(false, true, progress);
+ folder.create(true, true, progress);
+ folder.getResourceAttributes().setReadOnly(false);
+ synchronizer.setBaseBytes(folder, remote.asBytes());
+ } else if (folder.exists() && remote == null) {
+ // Schedule the folder for removal but delay in
+ // case the folder contains outgoing changes
+ toDelete.add(folder);
+ }
+ }
+
+ // Get the children
+ IResource[] children = synchronizer.members(container);
+ if (children.length > 0) {
+ internalGet(children, depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, overrideOutgoing, progress);
+ }
+
+ // Remove any empty folders
+ for (Iterator iter = toDelete.iterator(); iter.hasNext();) {
+ IFolder folder = (IFolder) iter.next();
+ if (folder.members().length == 0) {
+ folder.delete(false, true, progress);
+ synchronizer.flush(folder, IResource.DEPTH_INFINITE);
+ }
+ }
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /*
+ * Get the file if it is out-of-sync.
+ */
+ private void internalGet(IFile localFile, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ IResourceVariantComparator comparator = FileSystemSubscriber.getInstance().getResourceComparator();
+// FileSystemResourceVariant remote = getExportResourceVariant(localFile);
+ FileSystemResourceVariant remote = getImportResourceVariant(localFile);
+ byte[] baseBytes = synchronizer.getBaseBytes(localFile);
+ FileSystemProvider provider = getProvider(localFile);
+ IResourceVariant base = provider.getResourceVariant(localFile, baseBytes);
+//
+// if (!synchronizer.hasSyncBytes(localFile) || (isLocallyModified(localFile) && !overrideOutgoing)) {
+// // Do not overwrite the local modification
+// return;
+// }
+ if (base != null && remote == null) {
+ // The remote no longer exists so remove the local
+ try {
+ localFile.delete(false, true, progress);
+ synchronizer.flush(localFile, IResource.DEPTH_ZERO);
+ return;
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ }
+ }
+ if (!synchronizer.isLocallyModified(localFile) && base != null && remote != null && comparator.compare(base, remote)) {
+ // The base and remote are the same and there's no local changes
+ // so nothing needs to be done
+ return;
+ }
+ try {
+// UniFilePlus remoteFile = (UniFilePlus) provider.getExportFile(localFile);
+ UniFilePlus remoteFile = (UniFilePlus) provider.getImportFile(localFile);
+ if(!remoteFile.exists()){
+ localFile.delete(true, null);
+ synchronizer.flush(localFile, IResource.DEPTH_ZERO);
+ }else{
+ if(localFile.exists()){
+ localFile.delete(true, null);
+ }
+ try {
+ // Copy from the remote file to the local file:
+
+// if(!localFile.getParent().exists()){
+// IPath parentPath = localFile.getFullPath().removeLastSegments(1);
+// ContainerGenerator generator = new ContainerGenerator(parentPath);
+// IContainer container = generator.generateContainer(null);
+// container.getResourceAttributes().setReadOnly(false);
+// }
+ createParentFolderRecursively(localFile);
+ remoteFile.getRemoteFile().getParentRemoteFileSubSystem().download(remoteFile.getRemoteFile(), localFile.getLocation().toOSString(), localFile.getCharset(), progress);
+// remoteFile.getRemoteFile().getParentRemoteFileSubSystem().download(remoteFile.getRemoteFile(), parent.getLocation().toOSString(), localFile.getCharset(), progress);
+
+ // Mark as read-only to force a checkout before editing
+ //System.out.println(localFile.getLocation() + " : accessible = " + localFile.isAccessible()+", existing = "+localFile.exists());
+ if(localFile.isAccessible()){
+ localFile.getResourceAttributes().setReadOnly(true);
+ }
+ // update sync status
+ synchronizer.setBaseBytes(localFile, remote.asBytes());
+ } catch (SystemMessageException e) {
+ e.printStackTrace();
+ }
+ }
+ } catch (CoreException e) {
+ throw FileSystemPlugin.wrapException(e);
+ }
+ }
+
+ // actual put operation for files
+ private void internalPut(IResource[] resources, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
+ try {
+ // ensure the progress monitor is not null
+ progress = Policy.monitorFor(progress);
+ progress.beginTask(Policy.bind("PutAction.working"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ for (int i = 0; i < resources.length; i++) {
+ Policy.checkCanceled(progress);
+ if (resources[i].getType() == IResource.FILE) {
+ internalPut((IFile) resources[i], overrideIncoming, progress);
+ } else if (depth > 0) { // Assume that resources are either
+ // files or containers.
+ internalPut((IContainer) resources[i], depth, overrideIncoming, progress);
+ }
+ progress.worked(1);
+ }
+ progress.done();
+ } catch (TeamException e) {
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Put the file if the sync state allows it.
+ *
+ * @param localFile
+ * the local file
+ * @param overrideIncoming
+ * whether incoming changes should be overwritten
+ * @param progress
+ * a progress monitor
+ * @return whether the put succeeded (i.e. the local matches the remote)
+ * @throws TeamException
+ */
+ private boolean internalPut(IFile localFile, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ IResourceVariantComparator comparator = FileSystemSubscriber.getInstance().getResourceComparator();
+ FileSystemResourceVariant remote = getExportResourceVariant(localFile);
+ byte[] baseBytes = synchronizer.getBaseBytes(localFile);
+ FileSystemProvider provider = getProvider(localFile);
+ IResourceVariant base = provider.getResourceVariant(localFile, baseBytes);
+
+ // Check whether we are overriding a remote change
+ if (base == null && remote != null && !overrideIncoming) {
+ // The remote is an incoming (or conflicting) addition.
+ // Do not replace unless we are overriding
+ return false;
+ } else if (base != null && remote == null) {
+ // The remote is an incoming deletion
+ if (!localFile.exists()) {
+ // Conflicting deletion. Clear the synchronizer.
+ synchronizer.flush(localFile, IResource.DEPTH_ZERO);
+ } else if (!overrideIncoming) {
+ // Do not override the incoming deletion
+ return false;
+ }
+ } else if (base != null && remote != null) {
+ boolean same = comparator.compare(base, remote);
+ if (!isLocallyModified(localFile) && same) {
+ // The base and remote are the same and there's no local changes
+ // so nothing needs to be done
+ return true;
+ }
+ if (!same && !overrideIncoming) {
+ // The remote has changed. Only override if specified
+ return false;
+ }
+ }
+
+ // Handle an outgoing deletion
+ UniFilePlus remoteFile = (UniFilePlus) provider.getExportFile(localFile);
+ if (!localFile.exists()) {
+ remoteFile.delete();
+ synchronizer.flush(localFile, IResource.DEPTH_ZERO);
+ } else {
+ // Otherwise, upload the contents
+ try {
+ // Copy from the local file to the remote file:
+ try {
+ if (!remoteFile.getParentFile().exists()) {
+ remoteFile.getParentFile().mkdirs();
+ }
+ remoteFile.getRemoteFile().getParentRemoteFileSubSystem().upload(localFile.getLocation().toOSString(), remoteFile.getRemoteFile(), localFile.getCharset(), progress);
+ // Mark the file as read-only to require another checkout
+ localFile.getResourceAttributes().setReadOnly(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ // Update the synchronizer base bytes
+ remote = getExportResourceVariant(localFile);
+ synchronizer.setBaseBytes(localFile, remote.asBytes());
+ } catch (CoreException e) {
+ throw FileSystemPlugin.wrapException(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return true;
+ }
+
+ private boolean isLocallyModified(IFile localFile) throws TeamException {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ if (!localFile.exists()) {
+ // Extra check for bug 141415
+ return synchronizer.getBaseBytes(localFile) != null;
+ }
+ return synchronizer.isLocallyModified(localFile);
+ }
+
+ /*
+ * Get the folder and its children to the depth specified.
+ */
+ private void internalPut(IContainer container, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
+ try {
+ ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
+ FileSystemProvider provider = getProvider(container);
+ // Make the local folder state match the remote folder state
+ List toDelete = new ArrayList();
+ if (container.getType() == IResource.FOLDER) {
+ IFolder folder = (IFolder) container;
+ UniFilePlus diskFile = (UniFilePlus) provider.getExportFile(container);
+ FileSystemResourceVariant remote = getExportResourceVariant(container);
+ if (!folder.exists() && remote != null) {
+ // Schedule the folder for removal but delay in
+ // case the folder contains incoming changes
+ toDelete.add(diskFile);
+ } else if (folder.exists() && remote == null) {
+ // Create the remote directory and sync up the local
+ diskFile.mkdir();
+ synchronizer.setBaseBytes(folder, provider.getExportResourceVariant(folder).asBytes());
+ }
+ } else if (container.getType() == IResource.PROJECT) {
+ IProject project = (IProject) container;
+ UniFilePlus remoteProjectFolder = (UniFilePlus) provider.getExportFile(project);
+ FileSystemResourceVariant remoteResourceVariant = getExportResourceVariant(container);
+ if (project.exists() && remoteResourceVariant == null) {
+ remoteProjectFolder.mkdir();
+ synchronizer.setBaseBytes(project, provider.getExportResourceVariant(project).asBytes());
+ }
+ }
+
+ // Get the children
+ IResource[] children = synchronizer.members(container);
+ if (children.length > 0) {
+ internalPut(children, depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, overrideIncoming, progress);
+ }
+
+ // Remove any empty folders
+ for (Iterator iter = toDelete.iterator(); iter.hasNext();) {
+ File diskFile = (File) iter.next();
+ if (diskFile.listFiles().length == 0) {
+ diskFile.delete();
+ synchronizer.flush(container, IResource.DEPTH_INFINITE);
+ }
+ }
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void createParentFolderRecursively(IResource resource) throws CoreException{
+ if(!resource.getParent().exists()){
+ ContainerGenerator generator = new ContainerGenerator(resource.getParent().getFullPath());
+ IContainer parent = generator.generateContainer(null);
+ createParentFolderRecursively(parent);
+ }
+ }
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemPlugin.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemPlugin.java
new file mode 100644
index 00000000000..9708405bc9f
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemPlugin.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemPlugin
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.rse.internal.synchronize.RSESyncUtils;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * This is the plugin class for the file system examples. It provides the
+ * following:
+ *
+ * RepositoryProvider
that uses the file system to act as the
+ * repository. See the plugin.xml file for the xml required to register this
+ * provider with the Team extension point
+ * org.eclipse.team.core.repository
. The plugin.xml file also
+ * contains examples of how to filter menu items using a repository provider's
+ * ID.
+ *
+ * + * This example provider illustrates the following: + *
RepositoyProvider
+ * SimpleAccessOperations
for
+ * performing simple file operations
+ * + * Additional functionality that will be illustrated in the future include: + *
getProject()
, we don't know the root location so there is
+ * nothing we can do yet.
+ *
+ * @see org.eclipse.team.core.RepositoryProvider#configureProject()
+ */
+ @Override
+ public void configureProject() throws CoreException {
+ FileSystemSubscriber.getInstance().handleRootChanged(getProject(), true /* added */);
+ }
+
+ /**
+ * This method is invoked when the provider is unmapped from its project.
+ *
+ * @see org.eclipse.core.resources.IProjectNature#deconfigure()
+ */
+ public void deconfigure() throws CoreException {
+ // Clear the persistant property containing the location
+ getProject().setPersistentProperty(FILESYSTEM_REPO_LOC, null);
+ FileSystemSubscriber.getInstance().handleRootChanged(getProject(), false /* removed */);
+ }
+
+ /**
+ * Return the provider ID as specified in the plugin.xml
+ *
+ * @see RepositoryProvider#getID()
+ */
+ @Override
+ public String getID() {
+ return RSESyncUtils.PROVIDER_ID;
+ }
+
+ /**
+ * Set the file system location for the provider. This mist be invoked after
+ * the provider is mapped and configured but before the provider is used to
+ * perform any operations.
+ *
+ * @param location
+ * the path representing the location where the project contents will
+ * be stored.
+ * @throws TeamException
+ */
+ public void setTargetLocation(String location) throws TeamException {
+ // location = transformRSEtoNormal(location);
+
+ // set the instance variable to the provided path
+ rootPath = new Path(location);
+
+ // ensure that the location is a folder (if it exists)
+ File file = new File(location);
+ if (file.exists() && !file.isDirectory()) {
+ throw new TeamException(Policy.bind("FileSystemProvider.mustBeFolder", location)); //$NON-NLS-1$
+ }
+
+ // record the location as a persistent property so it will be remembered
+ // across platform invocations
+ try {
+ getProject().setPersistentProperty(FILESYSTEM_REPO_LOC, location);
+ } catch (CoreException e) {
+ throw FileSystemPlugin.wrapException(e);
+ }
+ }
+
+ /**
+ * Returns the folder in the file system to which the provider is connected.
+ * Return null
if there is no location or there was a problem
+ * determining it.
+ *
+ * @return IPath The path to the root of the repository.
+ */
+ public IPath getRoot() {
+ if (rootPath == null) {
+ try {
+ String location = getProject().getPersistentProperty(FILESYSTEM_REPO_LOC);
+ if (location == null) {
+ return null;
+ }
+ rootPath = new Path(location);
+ } catch (CoreException e) {
+ // log the problem and carry on
+ FileSystemPlugin.log(e);
+ return null;
+ }
+ }
+ // System.out.println(root);
+ return rootPath;
+ }
+
+ /**
+ * Return an object that provides the operations for transferring data to
+ * and from the provider's location.
+ */
+ public FileSystemOperations getOperations() {
+ return new FileSystemOperations(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.RepositoryProvider#getFileModificationValidator()
+ */
+ @Override
+ public IFileModificationValidator getFileModificationValidator() {
+ return getFileModificationValidator2();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.RepositoryProvider#getFileModificationValidator2()
+ */
+ @Override
+ public FileModificationValidator getFileModificationValidator2() {
+ return new org.eclipse.rse.internal.synchronize.filesystem.FileModificationValidator(this);
+ }
+
+ /**
+ * Return the resource variant for the local resource using the bytes to
+ * identify the variant.
+ *
+ * @param resource
+ * the resource
+ * @param bytes
+ * the bytes that identify the resource variant
+ * @return the resource variant handle
+ */
+ public IResourceVariant getResourceVariant(IResource resource, byte[] bytes) {
+ // Takuya: it's important if resource exist or not.
+ if (bytes == null)
+ return null;
+ UniFilePlus file = (UniFilePlus) getExportFile(resource);
+ if (file == null)
+ return null;
+ return new FileSystemResourceVariant(file, bytes);
+ }
+
+ /**
+ * Return the resource variant for the local resource.
+ *
+ * @param resource
+ * the resource
+ * @return the resource variant
+ */
+ public IResourceVariant getExportResourceVariant(IResource resource) {
+ // Takuya: it's important if resource exist or not.
+ UniFilePlus file = (UniFilePlus) getExportFile(resource);
+ if (file == null || !file.exists())
+ return null;
+ return new FileSystemResourceVariant(file);
+ }
+
+ public IResourceVariant getImportResourcevariant(IResource resource){
+ UniFilePlus file = (UniFilePlus) getImportFile(resource);
+ if (file == null || !file.exists())
+ return null;
+ return new FileSystemResourceVariant(file);
+ }
+
+ /**
+ * Return the java.io.File
that the given resource maps to.
+ * Return null
if the resource is not a child of this
+ * provider's project.
+ * The path of return file is targetRootPath/project/relativePath.
+ *
+ * @param resource
+ * the resource
+ * @return the file that the resource maps to.
+ */
+ public File getExportFile(IResource resource) {
+ UniFilePlus file = null;
+ try {
+ if (resource.getProject().equals(getProject())) {
+ UniFilePlus root = getRemoteRootFolder();
+ String relativePath = transformInDependency(root.getRemoteFile().getHost(), resource.getFullPath().toString());
+ // MOB BUGBUG//IRemoteFile remoteFile =
+ // root.getRemoteFile().getParentRemoteFileSubSystem
+ // ().getRemoteFileObject(root.getRemoteFile(),relativePath,
+ // null);
+ IRemoteFile remoteFile = root.getRemoteFile().getParentRemoteFileSubSystem().getRemoteFileObject(root.getRemoteFile().getAbsolutePath() + relativePath, null);
+ file = new UniFilePlus(remoteFile);
+
+ }
+ } catch (SystemMessageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return file;
+ }
+
+ public File getImportFile(IResource resource){
+ UniFilePlus file = null;
+ try {
+ if (resource.getProject().equals(getProject())) {
+ UniFilePlus root = getRemoteRootFolder();
+ String relativePath = transformInDependency(root.getRemoteFile().getHost(), IPath.SEPARATOR + resource.getProjectRelativePath().toString());
+ IRemoteFile remoteFile = root.getRemoteFile().getParentRemoteFileSubSystem().getRemoteFileObject(root.getRemoteFile().getAbsolutePath() + relativePath, null);
+ file = new UniFilePlus(remoteFile);
+
+ }
+ } catch (SystemMessageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return file;
+ }
+
+
+ /**
+ * return whether the resource is file or not
+ *
+ * @param resource
+ * @return
+ */
+ private boolean isFile(IResource resource) {
+ return new File(this.transformRSEtoNormal(resource.getLocation().toString())).isFile();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.RepositoryProvider#getRuleFactory()
+ */
+ @Override
+ public IResourceRuleFactory getRuleFactory() {
+ return RESOURCE_RULE_FACTORY;
+ }
+
+ @Override
+ public IFileHistoryProvider getFileHistoryProvider() {
+ return null;
+ }
+
+ private String transformRSEtoNormal(String original) {
+ if (original.indexOf(":") == -1) {
+ return original;
+ }
+
+ String transformed = "";
+ String[] str = original.split(":");
+
+ // Windows
+ if (str.length > 2) {
+ transformed += str[1] + ":" + str[2];
+ }
+ // Linux
+ else {
+ transformed += str[1];
+ }
+
+ return transformed;
+
+ }
+
+ /**
+ * get the handle fo remote root directory which is specified by IHost and
+ * absolute path as the member value of this class.
+ *
+ * @return
+ */
+ public UniFilePlus getRemoteRootFolder() {
+ if (remoteRoot == null) {
+ IPath remoteRootDir = getRoot();
+ String remoteRootDirString = transformRSEtoNormal(remoteRootDir.toString());
+ IHost conn = Utilities.parseForSystemConnection(remoteRootDir.toString());
+ String absolutePath = transformInDependency(conn, remoteRootDirString);
+ return /* remoteRoot = */new UniFilePlus(Utilities.getIRemoteFile(conn, absolutePath));
+ }
+
+ return remoteRoot;
+ }
+
+ private String transformInDependency(IHost host, String original) {
+ String ret = "";
+ IRSESystemType type = host.getSystemType();
+ if (host.getSystemType().isWindows()) {
+ ret = original.replace("/", "\\");
+ } else {
+ ret = original.replace("\\", "/");
+ }
+ return ret;
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemProviderType.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemProviderType.java
new file mode 100644
index 00000000000..f72431fc410
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/FileSystemProviderType.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemProviderType
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem;
+
+import org.eclipse.team.core.ProjectSetCapability;
+import org.eclipse.team.core.RepositoryProviderType;
+
+/**
+ * The file system repository provider types
+ */
+public class FileSystemProviderType extends RepositoryProviderType {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.RepositoryProviderType#getProjectSetCapability()
+ */
+ @Override
+ public ProjectSetCapability getProjectSetCapability() {
+ // Create an empty project set capability to test backwards
+ // compatibility
+ return new ProjectSetCapability() {
+ };
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/Policy.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/Policy.java
new file mode 100644
index 00000000000..babc51217c1
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/Policy.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / Policy
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+
+/**
+ * This class is a clone of the Policy classes many Eclipse plugin use to
+ * provide NLSing of strings and aid in proper progress monitoring.
+ */
+public class Policy {
+
+ private static ResourceBundle bundle = null;
+ //private static final String bundleName = "org.eclipse.rse.internal.synchronize.filesystem.messages"; //$NON-NLS-1$
+ private static final String bundleName = Policy.class.getPackage().getName() + ".messages";
+
+ /*
+ * Returns a resource bundle, creating one if it none is available.
+ */
+ private static ResourceBundle getResourceBundle() {
+ // thread safety
+ ResourceBundle tmpBundle = bundle;
+ if (tmpBundle != null)
+ return tmpBundle;
+ // always create a new classloader to be passed in
+ // in order to prevent ResourceBundle caching
+ return bundle = ResourceBundle.getBundle(bundleName);
+ // return bundle = ResourceBundle.getBundle("");
+ }
+
+ /**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given string.
+ */
+ public static String bind(String id, String binding) {
+ return bind(id, new String[] { binding });
+ }
+
+ /**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given strings.
+ */
+ public static String bind(String id, String binding1, String binding2) {
+ return bind(id, new String[] { binding1, binding2 });
+ }
+
+ /**
+ * Gets a string from the resource bundle. We don't want to crash because of
+ * a missing String. Returns the key if not found.
+ */
+ public static String bind(String key) {
+ try {
+ return getResourceBundle().getString(key);
+ } catch (MissingResourceException e) {
+ return key;
+ } catch (NullPointerException e) {
+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Gets a string from the resource bundle and binds it with the given
+ * arguments. If the key is not found, return the key.
+ */
+ public static String bind(String key, Object[] args) {
+ try {
+ return MessageFormat.format(bind(key), args);
+ } catch (MissingResourceException e) {
+ return key;
+ } catch (NullPointerException e) {
+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Progress monitor helpers
+ */
+ public static void checkCanceled(IProgressMonitor monitor) {
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
+ }
+
+ public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
+ if (monitor == null)
+ return new NullProgressMonitor();
+ return monitor;
+ }
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/messages.properties b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/messages.properties
new file mode 100644
index 00000000000..14e6d00cced
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/messages.properties
@@ -0,0 +1,42 @@
+###############################################################################
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+# Takuya Miyamoto - Adapted from org.eclipse.rse.team.example / messages.properties
+###############################################################################
+fileSystem.propertyLocation=Location:
+
+FileSystemMainPage.location=Location:
+FileSystemMainPage.browseDir=&Browse...
+FileSystemMainPage.notValidLocation=Location must be an existing directory
+
+fsMainPage.name=Select a file system location
+fsMainPage.description=This location will be used to share resources with a team
+
+ConfigurationWizard.errorTitle=Error configuring the provider.
+ConfigurationWizard.error=File System provider could not be created
+
+ConfigurationWizard.name=File System Repository
+ConfigurationWizard.description=File System Repository Properties
+
+DisconnectAction.errorTitle=Error Disconnecting
+
+PutAction.working=Putting resources...
+PutAction.problemMessage=A problem occured putting the resources.
+
+GetAction.working=Getting resources...
+GetAction.problemMessage=A problem occured getting the resources.
+
+ReplaceAction.working=Replacing resources...
+ReplaceAction.problemMessage=A problem occured replacing the resources.
+
+FileSystemProvider.mustBeFolder=Target location ''{0}'' is a file and must be a folder.
+RemoteResource.mustBeFolder=Resource ''{0}'' is a file so it cannot have entries
+FileSystemRemoteResource.0=This resource is a container so it cannot have data.
+FileSystemSimpleAccessOperations.1=Checking resources out...
+FileSystemSimpleAccessOperations.3=Re-locking resources...
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemMergeContext.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemMergeContext.java
new file mode 100644
index 00000000000..14975a566d4
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemMergeContext.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemMergeContext
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem.subscriber;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.rse.internal.synchronize.RSESyncUtils;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.diff.IThreeWayDiff;
+import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
+import org.eclipse.team.core.mapping.provider.MergeStatus;
+import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
+import org.eclipse.team.core.subscribers.SubscriberMergeContext;
+
+/**
+ * A merge context for merging file system changes.
+ */
+public class FileSystemMergeContext extends SubscriberMergeContext {
+
+ /**
+ * Create the file system merge context for the given scope manager.
+ *
+ * @param manager
+ * the scope manager
+ */
+ public FileSystemMergeContext(ISynchronizationScopeManager manager) {
+ super(FileSystemSubscriber.getInstance(), manager);
+ initialize();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.mapping.provider.MergeContext#makeInSync(org.eclipse
+ * .team.core.diff.IDiff, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void makeInSync(IDiff diff, IProgressMonitor monitor) throws CoreException {
+ IResource resource = ResourceDiffTree.getResourceFor(diff);
+ FileSystemSubscriber.getInstance().makeInSync(resource);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.mapping.IMergeContext#markAsMerged(org.eclipse.
+ * team.core.diff.IDiff, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void markAsMerged(IDiff diff, boolean inSyncHint, IProgressMonitor monitor) throws CoreException {
+ // TODO if inSyncHint is true, we should test to see if the contents
+ // match
+ IResource resource = ResourceDiffTree.getResourceFor(diff);
+ FileSystemSubscriber.getInstance().markAsMerged(resource, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.mapping.IMergeContext#reject(org.eclipse.team.core
+ * .diff.IDiff, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void reject(IDiff diff, IProgressMonitor monitor) throws CoreException {
+ markAsMerged(diff, false, monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.mapping.provider.MergeContext#getMergeRule(org.
+ * eclipse.team.core.diff.IDiff)
+ */
+ @Override
+ public ISchedulingRule getMergeRule(IDiff node) {
+ return ResourceDiffTree.getResourceFor(node).getProject();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.mapping.provider.MergeContext#merge(org.eclipse
+ * .team.core.diff.IDiff, boolean,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public IStatus merge(IDiff diff, boolean ignoreLocalChanges, IProgressMonitor monitor) throws CoreException {
+ // Only attempt the merge for non-conflicts. The reason we do this
+ // is because the file system provider doesn't really have the proper
+ // base
+ // so merging conflicts doesn't work properly
+ if (!ignoreLocalChanges) {
+ IResource resource = ResourceDiffTree.getResourceFor(diff);
+ if (diff instanceof IThreeWayDiff && resource instanceof IFile) {
+ IThreeWayDiff twd = (IThreeWayDiff) diff;
+ if (twd.getDirection() == IThreeWayDiff.CONFLICTING) {
+ // return new MergeStatus(FileSystemPlugin.ID,
+ // "Cannot merge conflicting files", new IFile[] {
+ // (IFile)resource });
+ return new MergeStatus(RSESyncUtils.PLUGIN_ID, "Cannot merge conflicting files", new IFile[] { (IFile) resource });
+ }
+ }
+ }
+ return super.merge(diff, ignoreLocalChanges, monitor);
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemRemoteTree.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemRemoteTree.java
new file mode 100644
index 00000000000..c87aed48f7d
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemRemoteTree.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemRemoteTree
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem.subscriber;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.internal.synchronize.RSESyncUtils;
+import org.eclipse.rse.internal.synchronize.filesystem.FileSystemProvider;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.core.variants.ThreeWayRemoteTree;
+
+/**
+ * The file system three-way remote resource variant tree that provides the
+ * ability to traverse the file system for the creation of resource variants.
+ */
+public class FileSystemRemoteTree extends ThreeWayRemoteTree {
+
+ /**
+ * Create the file system remote resource variant tree
+ *
+ * @param subscriber
+ * the file system subscriber
+ */
+ public FileSystemRemoteTree(FileSystemSubscriber subscriber) {
+ super(subscriber);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.variants.AbstractResourceVariantTree#fetchMembers
+ * (org.eclipse.team.core.variants.IResourceVariant,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IResourceVariant[] fetchMembers(IResourceVariant variant, IProgressMonitor progress) throws TeamException {
+ return ((FileSystemResourceVariant) variant).members();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.variants.AbstractResourceVariantTree#fetchVariant
+ * (org.eclipse.core.resources.IResource, int,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException {
+ try {
+ RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), RSESyncUtils.PROVIDER_ID);
+ if (provider != null) {
+ return ((FileSystemProvider) provider).getExportResourceVariant(resource);
+ }
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemResourceVariant.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemResourceVariant.java
new file mode 100644
index 00000000000..07e8195517a
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemResourceVariant.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemResourceVariant
+ *******************************************************************************/
+
+package org.eclipse.rse.internal.synchronize.filesystem.subscriber;
+
+import java.io.InputStream;
+import java.util.Date;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rse.internal.importexport.files.UniFilePlus;
+import org.eclipse.rse.internal.synchronize.RSESyncUtils;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.variants.CachedResourceVariant;
+
+public class FileSystemResourceVariant extends CachedResourceVariant {
+
+ private UniFilePlus ioFile;
+ private byte[] bytes;
+
+ /**
+ * Create a resource variant for the given file. The bytes will be
+ * calculated when they are accessed.
+ *
+ * @param file
+ * the file
+ */
+ public FileSystemResourceVariant(UniFilePlus file) {
+ this.ioFile = file;
+ }
+
+ /**
+ * Create a resource variant for the given file and sync bytes.
+ *
+ * @param file
+ * the file
+ * @param bytes
+ * the timestamp bytes
+ */
+ public FileSystemResourceVariant(UniFilePlus file, byte[] bytes) {
+ this.ioFile = file;
+ this.bytes = bytes;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.variants.CachedResourceVariant#fetchContents(org
+ * .eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void fetchContents(IProgressMonitor monitor) throws TeamException {
+ setContents(getContents(), monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.variants.CachedResourceVariant#getCachePath()
+ */
+ @Override
+ protected String getCachePath() {
+ // append the timestamp to the file path to give each variant a unique
+ // path
+ return getFilePath() + " " + ioFile.lastModified(); //$NON-NLS-1$
+ }
+
+ private String getFilePath() {
+ return ioFile.getCanonicalPath();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.variants.CachedResourceVariant#getCacheId()
+ */
+ @Override
+ protected String getCacheId() {
+ // return FileSystemPlugin.ID;
+ return RSESyncUtils.PLUGIN_ID;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.variants.IResourceVariant#getName()
+ */
+ public String getName() {
+ return ioFile.getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.variants.IResourceVariant#isContainer()
+ */
+ public boolean isContainer() {
+ return ioFile.isDirectory();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.variants.IResourceVariant#getContentIdentifier()
+ */
+ public String getContentIdentifier() {
+ // Use the modification timestamp as the content identifier
+ return new Date(ioFile.lastModified()).toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.variants.IResourceVariant#asBytes()
+ */
+ // TODO By using byte[] which this method return, ResourceComparator run
+ // comparison.
+ // so, this method provide how to compare with which value.
+ public byte[] asBytes() {
+ if (bytes == null) {
+ // For simplicity, convert the timestamp to it's string
+ // representation.
+ // A more optimal storage format would be the 8 bytes that make up
+ // the long.
+ bytes = Long.toString(ioFile.lastModified()).getBytes();
+ }
+ return bytes;
+ }
+
+ /**
+ * Return the files contained by the file of this resource variant.
+ *
+ * @return the files contained by the file of this resource variant.
+ */
+ public FileSystemResourceVariant[] members() {
+ if (isContainer()) {
+ UniFilePlus[] members = (UniFilePlus[]) ioFile.listFiles();
+ FileSystemResourceVariant[] result = new FileSystemResourceVariant[members.length];
+ for (int i = 0; i < members.length; i++) {
+ result[i] = new FileSystemResourceVariant(members[i]);
+ }
+ return result;
+ }
+ return new FileSystemResourceVariant[0];
+ }
+
+ /**
+ * @return
+ */
+ public InputStream getContents() throws TeamException {
+ // Takuya: modified for managing remote resource
+ try {
+ return ioFile.getInputStream();
+ } catch (SystemMessageException e) {
+ throw new TeamException("Failed to fetch contents for " + getFilePath(), e); //$NON-NLS-1$
+ }
+ }
+
+ public UniFilePlus getFile() {
+ return ioFile;
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSubscriber.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSubscriber.java
new file mode 100644
index 00000000000..ad5b1e17883
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSubscriber.java
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemSubscriber
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem.subscriber;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.rse.internal.synchronize.RSEResourceVariantComparator;
+import org.eclipse.rse.internal.synchronize.RSESyncUtils;
+import org.eclipse.rse.internal.synchronize.filesystem.FileSystemProvider;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.core.variants.ThreeWayRemoteTree;
+import org.eclipse.team.core.variants.ThreeWaySubscriber;
+import org.eclipse.team.core.variants.ThreeWaySynchronizer;
+
+/**
+ * This is an example file system subscriber that overrides ThreeWaySubscriber.
+ * It uses a repository provider (FileSystemProvider
) to determine
+ * and manage the roots and to create resource variants. It also makes use of a
+ * file system specific remote tree (FileSystemRemoteTree
) for
+ * provided the remote tree access and refresh.
+ *
+ * @see ThreeWaySubscriber
+ * @see ThreeWaySynchronizer
+ * @see FileSystemProvider
+ * @see FileSystemRemoteTree
+ */
+public class FileSystemSubscriber extends ThreeWaySubscriber {
+
+ private static FileSystemSubscriber instance;
+
+ /**
+ * Return the file system subscriber singleton.
+ *
+ * @return the file system subscriber singleton.
+ */
+ public static synchronized FileSystemSubscriber getInstance() {
+ if (instance == null) {
+ instance = new FileSystemSubscriber();
+ }
+ return instance;
+ }
+
+ /**
+ * Create the file system subscriber.
+ */
+ private FileSystemSubscriber() {
+ super(new ThreeWaySynchronizer(new QualifiedName(RSESyncUtils.PLUGIN_ID, "workpsace-sync"))); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.variants.ThreeWaySubscriber#getResourceVariant(
+ * org.eclipse.core.resources.IResource, byte[])
+ */
+ @Override
+ public IResourceVariant getResourceVariant(IResource resource, byte[] bytes) throws TeamException {
+ RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), RSESyncUtils.PROVIDER_ID);
+ if (provider != null) {
+ return ((FileSystemProvider) provider).getResourceVariant(resource, bytes);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.variants.ThreeWaySubscriber#createRemoteTree()
+ */
+ @Override
+ protected ThreeWayRemoteTree createRemoteTree() {
+ return new FileSystemRemoteTree(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.subscribers.Subscriber#getName()
+ */
+ @Override
+ public String getName() {
+ return "Synchronize"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.subscribers.Subscriber#roots()
+ */
+ @Override
+ public IResource[] roots() {
+ List result = new ArrayList();
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ if (project.isAccessible()) {
+ RepositoryProvider provider = RepositoryProvider.getProvider(project, RSESyncUtils.PROVIDER_ID);
+ if (provider != null) {
+ result.add(project);
+ }
+ }
+ }
+ return (IProject[]) result.toArray(new IProject[result.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.variants.ThreeWaySubscriber#handleRootChanged(org
+ * .eclipse.core.resources.IResource, boolean)
+ */
+ @Override
+ public void handleRootChanged(IResource resource, boolean added) {
+ // Override to allow FileSystemProvider to signal the addition and
+ // removal of roots
+ super.handleRootChanged(resource, added);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.variants.ResourceVariantTreeSubscriber#getSyncInfo
+ * (org.eclipse.core.resources.IResource,
+ * org.eclipse.team.core.variants.IResourceVariant,
+ * org.eclipse.team.core.variants.IResourceVariant)
+ */
+ @Override
+ protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException {
+ // Override to use a custom sync info
+// FileSystemSyncInfo info = new FileSystemSyncInfo(local, base, remote, this.getResourceComparator());
+ FileSystemSyncInfo info = new FileSystemSyncInfo(local, base, remote, new RSEResourceVariantComparator(getSynchronizer()));
+ info.init();
+ return info;
+ }
+
+ /**
+ * Make the resource in-sync.
+ *
+ * @param resource
+ * the resource
+ * @throws TeamException
+ */
+ public void makeInSync(IResource resource) throws TeamException {
+ ThreeWaySynchronizer synchronizer = getSynchronizer();
+ byte[] remoteBytes = synchronizer.getRemoteBytes(resource);
+ if (remoteBytes == null) {
+ if (!resource.exists())
+ synchronizer.flush(resource, IResource.DEPTH_ZERO);
+ } else {
+ synchronizer.setBaseBytes(resource, remoteBytes);
+ }
+ }
+
+ /**
+ * Make the change an outgoing change
+ *
+ * @param resource
+ * @throws TeamException
+ */
+ public void markAsMerged(IResource resource, IProgressMonitor monitor) throws TeamException {
+ makeInSync(resource);
+ try {
+ resource.touch(monitor);
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ }
+ }
+
+
+
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSyncInfo.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSyncInfo.java
new file mode 100644
index 00000000000..f23fdde8a6a
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/subscriber/FileSystemSyncInfo.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemSyncInfo
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem.subscriber;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.core.variants.IResourceVariantComparator;
+
+/**
+ * Provide a custom sync info that will report files that exist both locally and
+ * remotely as in-sync and will return a null base if there is an incoming
+ * change.
+ */
+public class FileSystemSyncInfo extends SyncInfo {
+
+ public FileSystemSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator) {
+ super(local, base, remote, comparator);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.core.subscribers.SyncInfo#calculateKind(org.eclipse.
+ * core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected int calculateKind() throws TeamException {
+ if (getLocal().getType() != IResource.FILE) {
+ if (getLocal().exists() && getRemote() != null) {
+ return IN_SYNC;
+ }
+ }
+ return super.calculateKind();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.core.synchronize.SyncInfo#getBase()
+ */
+ @Override
+ public IResourceVariant getBase() {
+ // If the kind has been set and there is an incoming change
+ // return null as the base since the server does not keep the
+ // base contents
+ // if ((getKind() & INCOMING) > 0) {
+ // return null;
+ // }
+ return super.getBase();
+ }
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/CompoundResourceTraversal.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/CompoundResourceTraversal.java
new file mode 100644
index 00000000000..f1ee6a50df4
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/CompoundResourceTraversal.java
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / CompoundResourceTraversal
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem.ui;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Helper class that accumulates several traversals in order to generate a final
+ * set of traversals and to perform certain queries on a set of traversals.
+ *
+ * TODO: This class was copied from the Team Core plugin since it was an
+ * internal class. It should probably be made API at some point.
+ */
+public class CompoundResourceTraversal {
+
+ private Set deepFolders = new HashSet();
+ private Set shallowFolders = new HashSet();
+ private Set zeroFolders = new HashSet();
+ private Set files = new HashSet();
+
+ public void addTraversals(ResourceTraversal[] traversals) {
+ for (int i = 0; i < traversals.length; i++) {
+ ResourceTraversal traversal = traversals[i];
+ addTraversal(traversal);
+ }
+ }
+
+ public void addTraversal(ResourceTraversal traversal) {
+ IResource[] resources = traversal.getResources();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ addResource(resource, traversal.getDepth());
+ }
+ }
+
+ public void addResource(IResource resource, int depth) {
+ if (resource.getType() == IResource.FILE) {
+ if (!isCovered(resource, IResource.DEPTH_ZERO))
+ files.add(resource);
+ }
+ switch (depth) {
+ case IResource.DEPTH_INFINITE:
+ addDeepFolder(resource);
+ break;
+ case IResource.DEPTH_ONE:
+ addShallowFolder(resource);
+ break;
+ case IResource.DEPTH_ZERO:
+ addZeroFolder(resource);
+ break;
+ }
+ }
+
+ private void addShallowFolder(IResource resource) {
+ if (!isCovered(resource, IResource.DEPTH_ONE)) {
+ shallowFolders.add(resource);
+ removeDescendants(resource, IResource.DEPTH_ONE);
+ }
+ }
+
+ public boolean isCovered(IResource resource, int depth) {
+ IPath fullPath = resource.getFullPath();
+ // Regardless of the depth, look for a deep folder that covers the
+ // resource
+ for (Iterator iter = deepFolders.iterator(); iter.hasNext();) {
+ IResource deepFolder = (IResource) iter.next();
+ if (deepFolder.getFullPath().isPrefixOf(fullPath)) {
+ return true;
+ }
+ }
+ // For files, look in the shallow folders and files
+ if (resource.getType() == IResource.FILE) {
+ return (shallowFolders.contains(resource.getParent()) || files.contains(resource));
+ }
+ // For folders, look in appropriate sets
+ switch (depth) {
+ case IResource.DEPTH_ONE:
+ return (shallowFolders.contains(resource));
+ case IResource.DEPTH_ZERO:
+ return (shallowFolders.contains(resource.getParent()) || zeroFolders.contains(resource));
+ }
+ return false;
+ }
+
+ private void addZeroFolder(IResource resource) {
+ if (!isCovered(resource, IResource.DEPTH_ZERO))
+ zeroFolders.add(resource);
+ }
+
+ private void addDeepFolder(IResource resource) {
+ if (!isCovered(resource, IResource.DEPTH_INFINITE)) {
+ deepFolders.add(resource);
+ removeDescendants(resource, IResource.DEPTH_INFINITE);
+ }
+ }
+
+ private void removeDescendants(IResource resource, int depth) {
+ IPath fullPath = resource.getFullPath();
+ // First, remove any files that are now covered
+ for (Iterator iter = files.iterator(); iter.hasNext();) {
+ IResource child = (IResource) iter.next();
+ switch (depth) {
+ case IResource.DEPTH_INFINITE:
+ if (fullPath.isPrefixOf(child.getFullPath())) {
+ iter.remove();
+ }
+ break;
+ case IResource.DEPTH_ONE:
+ if (fullPath.equals(child.getFullPath().removeLastSegments(1))) {
+ iter.remove();
+ }
+ break;
+ }
+ }
+ // Now, remove any shallow folders
+ if (depth == IResource.DEPTH_INFINITE) {
+ for (Iterator iter = shallowFolders.iterator(); iter.hasNext();) {
+ IResource child = (IResource) iter.next();
+ if (fullPath.isPrefixOf(child.getFullPath())) {
+ iter.remove();
+ }
+ }
+ }
+ // Finally, remove any zero folders
+ for (Iterator iter = zeroFolders.iterator(); iter.hasNext();) {
+ IResource child = (IResource) iter.next();
+ switch (depth) {
+ case IResource.DEPTH_INFINITE:
+ if (fullPath.isPrefixOf(child.getFullPath())) {
+ iter.remove();
+ }
+ break;
+ case IResource.DEPTH_ONE:
+ // TODO: Is a zero folder covered by a shallow folder?
+ if (fullPath.equals(child.getFullPath().removeLastSegments(1))) {
+ iter.remove();
+ }
+ break;
+ }
+ }
+ }
+
+ public void add(CompoundResourceTraversal compoundTraversal) {
+ addResources((IResource[]) compoundTraversal.deepFolders.toArray(new IResource[compoundTraversal.deepFolders.size()]), IResource.DEPTH_INFINITE);
+ addResources((IResource[]) compoundTraversal.shallowFolders.toArray(new IResource[compoundTraversal.shallowFolders.size()]), IResource.DEPTH_ONE);
+ addResources((IResource[]) compoundTraversal.zeroFolders.toArray(new IResource[compoundTraversal.zeroFolders.size()]), IResource.DEPTH_ZERO);
+ addResources((IResource[]) compoundTraversal.files.toArray(new IResource[compoundTraversal.files.size()]), IResource.DEPTH_ZERO);
+ }
+
+ public void addResources(IResource[] resources, int depth) {
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ addResource(resource, depth);
+ }
+
+ }
+
+ /**
+ * Return the resources contained in the given traversals that are not
+ * covered by this traversal
+ *
+ * @param traversals
+ * the traversals being testes
+ * @return the resources contained in the given traversals that are not
+ * covered by this traversal
+ */
+ public IResource[] getUncoveredResources(ResourceTraversal[] traversals) {
+ CompoundResourceTraversal newTraversals = new CompoundResourceTraversal();
+ newTraversals.addTraversals(traversals);
+ return getUncoveredResources(newTraversals);
+ }
+
+ /*
+ * Return any resources in the other traversal that are not covered by this
+ * traversal
+ */
+ private IResource[] getUncoveredResources(CompoundResourceTraversal otherTraversal) {
+ Set result = new HashSet();
+ for (Iterator iter = otherTraversal.files.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (!isCovered(resource, IResource.DEPTH_ZERO)) {
+ result.add(resource);
+ }
+ }
+ for (Iterator iter = otherTraversal.zeroFolders.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (!isCovered(resource, IResource.DEPTH_ZERO)) {
+ result.add(resource);
+ }
+ }
+ for (Iterator iter = otherTraversal.shallowFolders.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (!isCovered(resource, IResource.DEPTH_ONE)) {
+ result.add(resource);
+ }
+ }
+ for (Iterator iter = otherTraversal.deepFolders.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (!isCovered(resource, IResource.DEPTH_INFINITE)) {
+ result.add(resource);
+ }
+ }
+ return (IResource[]) result.toArray(new IResource[result.size()]);
+ }
+
+ public ResourceTraversal[] asTraversals() {
+ List result = new ArrayList();
+ if (!files.isEmpty() || !zeroFolders.isEmpty()) {
+ Set combined = new HashSet();
+ combined.addAll(files);
+ combined.addAll(zeroFolders);
+ result.add(new ResourceTraversal((IResource[]) combined.toArray(new IResource[combined.size()]), IResource.DEPTH_ZERO, IResource.NONE));
+ }
+ if (!shallowFolders.isEmpty()) {
+ result.add(new ResourceTraversal((IResource[]) shallowFolders.toArray(new IResource[shallowFolders.size()]), IResource.DEPTH_ONE, IResource.NONE));
+ }
+ if (!deepFolders.isEmpty()) {
+ result.add(new ResourceTraversal((IResource[]) deepFolders.toArray(new IResource[deepFolders.size()]), IResource.DEPTH_INFINITE, IResource.NONE));
+ }
+ return (ResourceTraversal[]) result.toArray(new ResourceTraversal[result.size()]);
+ }
+
+ public IResource[] getRoots() {
+ List result = new ArrayList();
+ result.addAll(files);
+ result.addAll(zeroFolders);
+ result.addAll(shallowFolders);
+ result.addAll(deepFolders);
+ return (IResource[]) result.toArray(new IResource[result.size()]);
+ }
+
+ public ResourceTraversal[] getUncoveredTraversals(ResourceTraversal[] traversals) {
+ CompoundResourceTraversal other = new CompoundResourceTraversal();
+ other.addTraversals(traversals);
+ return getUncoveredTraversals(other);
+ }
+
+ public ResourceTraversal[] getUncoveredTraversals(CompoundResourceTraversal otherTraversal) {
+ CompoundResourceTraversal uncovered = new CompoundResourceTraversal();
+ for (Iterator iter = otherTraversal.files.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (!isCovered(resource, IResource.DEPTH_ZERO)) {
+ uncovered.addResource(resource, IResource.DEPTH_ZERO);
+ }
+ }
+ for (Iterator iter = otherTraversal.zeroFolders.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (!isCovered(resource, IResource.DEPTH_ZERO)) {
+ uncovered.addResource(resource, IResource.DEPTH_ZERO);
+ }
+ }
+ for (Iterator iter = otherTraversal.shallowFolders.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (!isCovered(resource, IResource.DEPTH_ONE)) {
+ uncovered.addResource(resource, IResource.DEPTH_ONE);
+ }
+ }
+ for (Iterator iter = otherTraversal.deepFolders.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ if (!isCovered(resource, IResource.DEPTH_INFINITE)) {
+ uncovered.addResource(resource, IResource.DEPTH_INFINITE);
+ }
+ }
+ return uncovered.asTraversals();
+ }
+
+ public void clear() {
+ deepFolders.clear();
+ shallowFolders.clear();
+ zeroFolders.clear();
+ files.clear();
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/FileSystemOperation.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/FileSystemOperation.java
new file mode 100644
index 00000000000..f3ccfeaa66a
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/FileSystemOperation.java
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemOperation
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem.ui;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.rse.internal.synchronize.RSESyncUtils;
+import org.eclipse.rse.internal.synchronize.filesystem.FileSystemProvider;
+import org.eclipse.rse.internal.synchronize.filesystem.subscriber.FileSystemSubscriber;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.mapping.ISynchronizationScope;
+import org.eclipse.team.core.subscribers.SubscriberScopeManager;
+import org.eclipse.team.ui.synchronize.ModelOperation;
+import org.eclipse.ui.IWorkbenchPart;
+
+public abstract class FileSystemOperation extends ModelOperation {
+
+ /**
+ * Create a scope manager for the file system example.
+ *
+ * @param name
+ * the name of the manager
+ * @param inputMappings
+ * the input mappings
+ * @return a scope manager
+ */
+ public static SubscriberScopeManager createScopeManager(String name, ResourceMapping[] inputMappings) {
+ return new SubscriberScopeManager(name, inputMappings, FileSystemSubscriber.getInstance(), true);
+ }
+
+ /**
+ * Create a file system operation.
+ *
+ * @param part
+ * the part from which the operation was launched
+ * @param manager
+ * the scope manager that provides the input to the operation
+ */
+ protected FileSystemOperation(IWorkbenchPart part, SubscriberScopeManager manager) {
+ super(part, manager);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.ui.synchronize.ModelOperation#execute(org.eclipse.core
+ * .runtime.IProgressMonitor)
+ */
+ @Override
+ protected void execute(IProgressMonitor monitor) throws InvocationTargetException {
+ try {
+ Map providerToTraversals = getProviderToTraversalsMap();
+ monitor.beginTask(getTaskName(), providerToTraversals.size() * 100);
+ monitor.setTaskName(getTaskName());
+ for (Iterator iter = providerToTraversals.keySet().iterator(); iter.hasNext();) {
+ FileSystemProvider provider = (FileSystemProvider) iter.next();
+ ResourceTraversal[] traversals = getTraversals(providerToTraversals, provider);
+ execute(provider, traversals, new SubProgressMonitor(monitor, 100));
+ }
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /**
+ * Return a map of FileSystemProvider to ResourceTraversals.
+ *
+ * @return a map of FileSystemProvider to ResourceTraversals
+ */
+ private Map getProviderToTraversalsMap() {
+ HashMap result = new HashMap();
+ ISynchronizationScope scope = getScope();
+ ResourceMapping[] mappings = scope.getMappings();
+ for (int i = 0; i < mappings.length; i++) {
+ ResourceMapping mapping = mappings[i];
+ ResourceTraversal[] traversals = scope.getTraversals(mapping);
+ for (int j = 0; j < traversals.length; j++) {
+ ResourceTraversal traversal = traversals[j];
+ IResource[] resources = traversal.getResources();
+ for (int k = 0; k < resources.length; k++) {
+ IResource resource = resources[k];
+ recordResourceAndDepth(result, resource, traversal.getDepth());
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return the file system provider associated with the given project or
+ * null
if the project is not mapped to the file system
+ * provider.
+ *
+ * @param project
+ * the project
+ * @return the file system provider associated with the given project
+ */
+ protected FileSystemProvider getProviderFor(IProject project) {
+ return (FileSystemProvider) RepositoryProvider.getProvider(project, RSESyncUtils.PROVIDER_ID);
+ }
+
+ private void recordResourceAndDepth(HashMap providerToTraversals, IResource resource, int depth) {
+ FileSystemProvider provider = getProviderFor(resource.getProject());
+ if (provider != null) {
+ CompoundResourceTraversal traversal = (CompoundResourceTraversal) providerToTraversals.get(provider);
+ if (traversal == null) {
+ traversal = new CompoundResourceTraversal();
+ providerToTraversals.put(provider, traversal);
+ }
+ traversal.addResource(resource, depth);
+ }
+ }
+
+ /**
+ * Return the traversals that were accumulated for the given provider by the
+ * {@link #getProviderToTraversalsMap()} method.
+ *
+ * @param providerToTraversals
+ * the provider to traversals map
+ * @param provider
+ * the provider
+ * @return the traversals for the given provider
+ */
+ private ResourceTraversal[] getTraversals(Map providerToTraversals, FileSystemProvider provider) {
+ CompoundResourceTraversal traversal = (CompoundResourceTraversal) providerToTraversals.get(provider);
+ return traversal.asTraversals();
+ }
+
+ /**
+ * Execute the operation for the given provider and traversals.
+ *
+ * @param provider
+ * the provider
+ * @param traversals
+ * the traversals to be operated on
+ * @param monitor
+ * a progress monitor
+ * @throws CoreException
+ */
+ protected abstract void execute(FileSystemProvider provider, ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * Return the task name for this operation.
+ *
+ * @return the task name for this operation
+ */
+ protected abstract String getTaskName();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.ui.TeamOperation#canRunAsJob()
+ */
+ @Override
+ protected boolean canRunAsJob() {
+ return true;
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/FileSystemSynchronizeParticipant.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/FileSystemSynchronizeParticipant.java
new file mode 100644
index 00000000000..a3977ca0f31
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/synchronize/filesystem/ui/FileSystemSynchronizeParticipant.java
@@ -0,0 +1,274 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Takuya Miyamoto - Adapted from org.eclipse.team.examples.filesystem / FileSystemSynchronizeParticipant
+ *******************************************************************************/
+package org.eclipse.rse.internal.synchronize.filesystem.ui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.rse.internal.synchronize.filesystem.FileSystemPlugin;
+import org.eclipse.rse.internal.synchronize.filesystem.subscriber.FileSystemMergeContext;
+import org.eclipse.rse.internal.synchronize.filesystem.subscriber.FileSystemSubscriber;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
+import org.eclipse.team.core.mapping.provider.MergeContext;
+import org.eclipse.team.core.mapping.provider.SynchronizationContext;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.TeamUI;
+import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
+import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipantActionGroup;
+
+/**
+ * This is an example synchronize participant for the file system provider. It
+ * will allow showing synchronization state for local resources mapped to a
+ * remote file system location.
+ *
+ * @since 3.0
+ */
+public class FileSystemSynchronizeParticipant extends ModelSynchronizeParticipant {
+
+ /**
+ * The participant id for the org.eclipse.team.ui.synchronizeParticipant
+ * extension point.
+ */
+ public static final String ID = "org.eclipse.rse.internal.synchronize.filesystem.participant"; //$NON-NLS-1$
+
+ /**
+ * The viewer id for the org.eclipse.ui.navigator.viewer extension point.
+ */
+ public static final String VIEWER_ID = "org.eclipse.rse.internal.synchronize.filesystem.syncViewer"; //$NON-NLS-1$
+
+ /**
+ * Custom menu groups included in the viewer definition in the plugin.xml.
+ */
+ public static final String CONTEXT_MENU_PUT_GROUP_1 = "put"; //$NON-NLS-1$
+ public static final String CONTEXT_MENU_GET_GROUP_1 = "get"; //$NON-NLS-1$
+ public static final String CONTEXT_MENU_OVERWRITE_GROUP_1 = "overwrite"; //$NON-NLS-1$
+
+ /**
+ * A custom label decorator that will show the remote mapped path for each
+ * file.
+ */
+ public class FileSystemParticipantLabelDecorator extends LabelProvider implements ILabelDecorator {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse
+ * .swt.graphics.Image, java.lang.Object)
+ */
+ public Image decorateImage(Image image, Object element) {
+ return image;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.
+ * String, java.lang.Object)
+ */
+ public String decorateText(String text, Object element) {
+ try {
+ if (element instanceof ISynchronizeModelElement) {
+ IResource resource = ((ISynchronizeModelElement) element).getResource();
+ if (resource != null && resource.getType() == IResource.FILE) {
+ SyncInfo info = FileSystemSubscriber.getInstance().getSyncInfo(resource);
+ IResourceVariant variant = info.getRemote();
+ if (variant != null) {
+ return text + " (" + variant.getContentIdentifier() + ")";
+ }
+ }
+ }
+ } catch (TeamException e) {
+ FileSystemPlugin.log(e);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Action group that contributes the get an put menus to the context menu in
+ * the synchronize view
+ */
+ public class FileSystemParticipantActionGroup extends ModelSynchronizeParticipantActionGroup {
+ private ModelPutAction putAction;
+ private ModelGetAction getAction;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.team.ui.synchronize.SynchronizePageActionGroup#initialize
+ * (org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
+ */
+ @Override
+ public void initialize(ISynchronizePageConfiguration configuration) {
+ super.initialize(configuration);
+ putAction = new ModelPutAction("", configuration);
+ getAction = new ModelGetAction("", configuration);
+ }
+
+
+
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ //menu.remove(CONTEXT_MENU_GET_GROUP_1);
+ //menu.remove(CONTEXT_MENU_PUT_GROUP_1);
+
+ try {
+ //super.fillContextMenu(menu);
+ TreeSelection selection = (TreeSelection)getConfiguration().getSite().getSelectionProvider().getSelection();
+ boolean hasOutgoingChange = false;
+ boolean hasIncomingChange = false;
+ boolean hasSingleResource = selection.size() == 1?true:false;
+
+ List