Remove IRemoteProcessBuilder#getHomeDirectory
Add USER_HOME_PROPERTY to IRemoteConnection#getProperty
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RemoteBuildServiceProvider.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RemoteBuildServiceProvider.java
index d15f156..f305a4c 100644
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RemoteBuildServiceProvider.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/serviceproviders/RemoteBuildServiceProvider.java
@@ -23,53 +23,57 @@
import org.eclipse.ptp.rdt.ui.messages.Messages;
import org.eclipse.ptp.remote.core.IRemoteConnection;
import org.eclipse.ptp.remote.core.IRemoteConnectionManager;
-import org.eclipse.ptp.remote.core.IRemoteProcessBuilder;
import org.eclipse.ptp.remote.core.IRemoteServices;
import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin;
import org.eclipse.ptp.remote.core.exception.RemoteConnectionException;
import org.eclipse.ptp.services.core.ServiceProvider;
/**
- * A build service provider that uses the Remote Tools API to provide execution services.
- *
- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
- * part of a work in progress. There is no guarantee that this API will work or
- * that it will remain the same. Please do not use this API without consulting
- * with the RDT team.
+ * A build service provider that uses the Remote Tools API to provide execution
+ * services.
+ *
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same. Please do not use this API without consulting with
+ * the RDT team.
*
* @author crecoskie
*/
public class RemoteBuildServiceProvider extends ServiceProvider implements IRemoteExecutionServiceProvider {
-
+
public static final String REMOTE_BUILD_SERVICE_PROVIDER_REMOTE_TOOLS_PROVIDER_ID = "RemoteBuildServiceProvider.remoteToolsProviderID"; //$NON-NLS-1$
public static final String REMOTE_BUILD_SERVICE_PROVIDER_REMOTE_TOOLS_CONNECTION_NAME = "RemoteBuildServiceProvider.remoteToolsConnectionName"; //$NON-NLS-1$
public static final String REMOTE_BUILD_SERVICE_PROVIDER_CONFIG_LOCATION = "RemoteBuildServiceProvider.configLocation"; //$NON-NLS-1$
-
+
public static final String ID = "org.eclipse.ptp.rdt.ui.RemoteBuildServiceProvider"; //$NON-NLS-1$
public static final String SERVICE_ID = "org.eclipse.ptp.rdt.core.BuildService"; //$NON-NLS-1$
public static final String NAME = Messages.getString("RemoteBuildServiceProvider.0"); //$NON-NLS-1$
private IRemoteConnection fRemoteConnection = null;
-
-
private static String getDefaultPath(IRemoteServices remoteServices, IRemoteConnection connection) {
if (remoteServices == null || connection == null) {
return null;
}
// get the user's home directory
- IRemoteProcessBuilder processBuilder = remoteServices.getProcessBuilder(connection, ""); //$NON-NLS-1$
- IFileStore homeStore = processBuilder.getHomeDirectory();
- URI uri = homeStore.toURI();
- String pathString = FileSystemUtilityManager.getDefault().getPathFromURI(uri);
- IPath path = new Path(pathString);
- path = path.append(RSEUtils.DEFAULT_CONFIG_DIR_NAME);
- return path.toString();
-
+ String homeDir = connection.getProperty(IRemoteConnection.USER_HOME_PROPERTY);
+ if (homeDir != null) {
+ IFileStore homeStore = remoteServices.getFileManager(connection).getResource(homeDir);
+ URI uri = homeStore.toURI();
+ String pathString = FileSystemUtilityManager.getDefault().getPathFromURI(uri);
+ IPath path = new Path(pathString);
+ path = path.append(RSEUtils.DEFAULT_CONFIG_DIR_NAME);
+ return path.toString();
+ }
+ return null;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider#getConfigLocation()
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider
+ * #getConfigLocation()
*/
public String getConfigLocation() {
return getString(REMOTE_BUILD_SERVICE_PROVIDER_CONFIG_LOCATION, getDefaultPath(getRemoteServices(), getConnection()));
@@ -79,25 +83,30 @@
putString(REMOTE_BUILD_SERVICE_PROVIDER_CONFIG_LOCATION, configLocation);
}
+ @Override
public String getConfigurationString() {
if (isConfigured()) {
return getRemoteServices().getName() + ": " + getRemoteConnectionName(); //$NON-NLS-1$
}
return null;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider#getConnection()
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider
+ * #getConnection()
*/
public IRemoteConnection getConnection() {
- if(fRemoteConnection == null && getRemoteConnectionName() != null) {
+ if (fRemoteConnection == null && getRemoteConnectionName() != null) {
IRemoteServices services = getRemoteServices();
if (services != null) {
IRemoteConnectionManager manager = services.getConnectionManager();
if (manager != null) {
fRemoteConnection = manager.getConnection(getRemoteConnectionName());
-
- if(fRemoteConnection != null && !fRemoteConnection.isOpen()) {
+
+ if (fRemoteConnection != null && !fRemoteConnection.isOpen()) {
try {
fRemoteConnection.open(new NullProgressMonitor());
} catch (RemoteConnectionException e) {
@@ -110,25 +119,31 @@
}
return fRemoteConnection;
}
-
+
/**
* Get the remote connection name
*
- * @return remote connection name or null if provider has not been configured
+ * @return remote connection name or null if provider has not been
+ * configured
*/
public String getRemoteConnectionName() {
return getString(REMOTE_BUILD_SERVICE_PROVIDER_REMOTE_TOOLS_CONNECTION_NAME, null);
}
- /* (non-Javadoc)
- * @see org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider#getRemoteServices()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ptp.rdt.core.serviceproviders.IRemoteExecutionServiceProvider
+ * #getRemoteServices()
*/
public IRemoteServices getRemoteServices() {
return PTPRemoteCorePlugin.getDefault().getRemoteServices(getRemoteToolsProviderID());
}
/**
- * Gets the ID of the Remote Tools provider that this provider uses for its execution services.
+ * Gets the ID of the Remote Tools provider that this provider uses for its
+ * execution services.
*
* @return remote tools provider ID
*/
@@ -136,13 +151,13 @@
return getString(REMOTE_BUILD_SERVICE_PROVIDER_REMOTE_TOOLS_PROVIDER_ID, null);
}
-
public boolean isConfigured() {
return (getRemoteToolsProviderID() != null && getRemoteConnectionName() != null);
}
-
+
/**
- * Sets the connection that this provider should use for its execution services.
+ * Sets the connection that this provider should use for its execution
+ * services.
*
* @param connection
*/
@@ -156,15 +171,16 @@
}
/**
- * Sets the ID of the Remote Tools provider that this provider should use for its execution services.
+ * Sets the ID of the Remote Tools provider that this provider should use
+ * for its execution services.
*
* @param id
*/
public void setRemoteToolsProviderID(String id) {
putString(REMOTE_BUILD_SERVICE_PROVIDER_REMOTE_TOOLS_PROVIDER_ID, id);
}
-
-
+
+ @Override
public String toString() {
return "RemoteBuildServiceProvider(" + getRemoteConnectionName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/RemoteBuildServiceFileLocationWidget.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/RemoteBuildServiceFileLocationWidget.java
index b837a73..61f9639 100644
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/RemoteBuildServiceFileLocationWidget.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/RemoteBuildServiceFileLocationWidget.java
@@ -22,7 +22,6 @@
import org.eclipse.ptp.internal.rdt.ui.RSEUtils;
import org.eclipse.ptp.rdt.ui.messages.Messages;
import org.eclipse.ptp.remote.core.IRemoteConnection;
-import org.eclipse.ptp.remote.core.IRemoteProcessBuilder;
import org.eclipse.ptp.remote.core.IRemoteServices;
import org.eclipse.ptp.remote.ui.IRemoteUIServices;
import org.eclipse.ptp.remote.ui.PTPRemoteUIPlugin;
@@ -42,131 +41,132 @@
private IRemoteConnection fRemoteConnection = null;
private IRemoteServices fRemoteServices = null;
-
- ///private final Label label;
+
+ // /private final Label label;
private final Text text;
private final Button browseButton;
- //private final Button validateButton;
+ // private final Button validateButton;
private final Button defaultButton;
-
- private ListenerList pathListeners = new ListenerList();
-
-
- private Map<String,String> previousSelections = new HashMap<String,String>();
-
- public RemoteBuildServiceFileLocationWidget(Composite parent, int style, final IRemoteServices remoteServices, IRemoteConnection initialConnection, String defaultPath) {
+
+ private final ListenerList pathListeners = new ListenerList();
+
+ private final Map<String, String> previousSelections = new HashMap<String, String>();
+
+ public RemoteBuildServiceFileLocationWidget(Composite parent, int style, final IRemoteServices remoteServices,
+ IRemoteConnection initialConnection, String defaultPath) {
super(parent, style);
-
+
fRemoteServices = remoteServices;
fRemoteConnection = initialConnection;
-
+
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
this.setLayout(layout);
this.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
Group group = new Group(this, SWT.NONE);
group.setText(Messages.getString("RemoteBuildServiceFileLocationWidget.1")); //$NON-NLS-1$
group.setLayout(new GridLayout(2, false));
group.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
text = new Text(group, SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
- //data.widthHint = 300;
+ // data.widthHint = 300;
data.horizontalSpan = 2;
text.setLayoutData(data);
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String path = text.getText();
-
+
previousSelections.put(key(remoteServices, fRemoteConnection), path);
-
- for(Object listener : pathListeners.getListeners()) {
- ((IIndexFilePathChangeListener)listener).pathChanged(path);
+
+ for (Object listener : pathListeners.getListeners()) {
+ ((IIndexFilePathChangeListener) listener).pathChanged(path);
}
}
});
-
+
browseButton = new Button(group, SWT.NONE);
- browseButton.setText(Messages.getString("IndexFileLocationWidget.1")); //$NON-NLS-1$
+ browseButton.setText(Messages.getString("IndexFileLocationWidget.1")); //$NON-NLS-1$
browseButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
browseButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
browse();
}
});
-
+
defaultButton = new Button(group, SWT.NONE);
- defaultButton.setText(Messages.getString("IndexFileLocationWidget.2")); //$NON-NLS-1$
+ defaultButton.setText(Messages.getString("IndexFileLocationWidget.2")); //$NON-NLS-1$
defaultButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
defaultButton.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
restoreDefault();
}
});
-
- if(defaultPath != null)
+
+ if (defaultPath != null)
text.setText(defaultPath);
}
-
-
+
public IRemoteConnection getConnection() {
return fRemoteConnection;
}
-
-// public void setRemoteConnection(IRemoteServices remoteServices, IRemoteConnection connection) {
-// if(connection == null || remoteServices == null)
-// throw new IllegalArgumentException();
-//
-// fRemoteConnection = connection;
-// fRemoteServices = remoteServices;
-//
-// String path = previousSelections.get(key(remoteServices, connection));
-// if(path == null)
-// path = getDefaultPath(remoteServices, connection);
-// if(path == null)
-// path = ""; //$NON-NLS-1$
-//
-// text.setText(path); // modify event listener updates map
-// }
-
-
+ // public void setRemoteConnection(IRemoteServices remoteServices,
+ // IRemoteConnection connection) {
+ // if(connection == null || remoteServices == null)
+ // throw new IllegalArgumentException();
+ //
+ // fRemoteConnection = connection;
+ // fRemoteServices = remoteServices;
+ //
+ // String path = previousSelections.get(key(remoteServices, connection));
+ // if(path == null)
+ // path = getDefaultPath(remoteServices, connection);
+ // if(path == null)
+ // path = ""; //$NON-NLS-1$
+ //
+ // text.setText(path); // modify event listener updates map
+ // }
+
public static String getDefaultPath(IRemoteServices remoteServices, IRemoteConnection connection) {
// get the user's home directory
- IRemoteProcessBuilder processBuilder = remoteServices.getProcessBuilder(connection, ""); //$NON-NLS-1$
- IFileStore homeStore = processBuilder.getHomeDirectory();
- URI uri = homeStore.toURI();
- String pathString = FileSystemUtilityManager.getDefault().getPathFromURI(uri);
- IPath path = new Path(pathString);
- path = path.append(RSEUtils.DEFAULT_CONFIG_DIR_NAME);
- return path.toString();
-
+ String homeDir = connection.getProperty(IRemoteConnection.USER_HOME_PROPERTY);
+ if (homeDir != null) {
+ IFileStore homeStore = remoteServices.getFileManager(connection).getResource(homeDir);
+ URI uri = homeStore.toURI();
+ String pathString = FileSystemUtilityManager.getDefault().getPathFromURI(uri);
+ IPath path = new Path(pathString);
+ path = path.append(RSEUtils.DEFAULT_CONFIG_DIR_NAME);
+ return path.toString();
+ }
+ return null;
}
-
private static String key(IRemoteServices remoteServices, IRemoteConnection connection) {
return remoteServices.getName() + ":" + connection.getName(); //$NON-NLS-1$
}
-
+
public String getConfigLocationPath() {
return text.getText();
}
-
-
+
public void addPathListener(IIndexFilePathChangeListener listener) {
pathListeners.add(listener);
}
-
+
public void removePathListener(IIndexFilePathChangeListener listener) {
pathListeners.remove(listener);
}
-
+
private void browse() {
IRemoteUIServices uiServices = PTPRemoteUIPlugin.getDefault().getRemoteUIServices(fRemoteServices);
- String remotePath = uiServices.getUIFileManager().browseDirectory(this.getShell(), Messages.getString("RemoteBuildServiceFileLocationWidget.0"), text.getText(),0); //$NON-NLS-1$
- if(remotePath != null)
+ String remotePath = uiServices.getUIFileManager().browseDirectory(this.getShell(),
+ Messages.getString("RemoteBuildServiceFileLocationWidget.0"), text.getText(), 0); //$NON-NLS-1$
+ if (remotePath != null)
text.setText(remotePath);
}
@@ -174,12 +174,12 @@
String defaultPath = getDefaultPath(fRemoteServices, fRemoteConnection);
text.setText(defaultPath);
}
-
+
public void update(IRemoteServices services, IRemoteConnection connection) {
fRemoteServices = services;
fRemoteConnection = connection;
String defaultPath = getDefaultPath(fRemoteServices, fRemoteConnection);
text.setText(defaultPath);
- }
+ }
}