diff options
9 files changed, 357 insertions, 19 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java index fd30e7288..9d5b81572 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProviderPlugin.java @@ -32,29 +32,29 @@ import org.eclipse.team.internal.ccvs.core.util.Util; public class CVSProviderPlugin extends Plugin { - private static CVSProviderPlugin instance; - - private static ICVSSynchronizer synchronizer; - - /** - * Int used for the communications timeout on server connections (in seconds) - */ - public static final int DEFAULT_TIMEOUT = 60; - private int communicationsTimeout = DEFAULT_TIMEOUT; - - /** - * Boolean which determines if empty directories received - * from the server should be pruned - */ + // external command to run for ext connection method + public static final String DEFAULT_CVS_RSH = "ssh"; //$NON-NLS-1$ + // remote command to run for ext connection method + public static final String DEFAULT_CVS_SERVER = "cvs"; //$NON-NLS-1$ + // determines if empty directories received from the server should be pruned. public static final boolean DEFAULT_PRUNE = true; - private boolean pruneEmptyDirectories = DEFAULT_PRUNE; + // communication timeout with the server + public static final int DEFAULT_TIMEOUT = 60; - private QuietOption quietness; - + // cvs plugin extension points and ids public static final String ID = "org.eclipse.team.cvs.core"; //$NON-NLS-1$ public static final String PT_AUTHENTICATOR = "authenticator"; //$NON-NLS-1$ public static final String PT_CONNECTIONMETHODS = "connectionmethods"; //$NON-NLS-1$ + private QuietOption quietness; + private int communicationsTimeout = DEFAULT_TIMEOUT; + private boolean pruneEmptyDirectories = DEFAULT_PRUNE; + private String cvsRshCommand = DEFAULT_CVS_RSH; + private String cvsServer = DEFAULT_CVS_SERVER; + + private static CVSProviderPlugin instance; + private static ICVSSynchronizer synchronizer; + /** * The identifier for the CVS nature * (value <code>"org.eclipse.team.cvs.core.nature"</code>). @@ -219,5 +219,37 @@ public class CVSProviderPlugin extends Plugin { }; ResourcesPlugin.getWorkspace().addResourceChangeListener(projectChangeListener, IResourceChangeEvent.POST_AUTO_BUILD); } + + /** + * Gets the cvsRshCommand. + * @return Returns a String + */ + public String getCvsRshCommand() { + return cvsRshCommand; + } + + /** + * Sets the cvsRshCommand. + * @param cvsRshCommand The cvsRshCommand to set + */ + public void setCvsRshCommand(String cvsRshCommand) { + this.cvsRshCommand = cvsRshCommand; + } + + /** + * Gets the cvsServer. + * @return Returns a String + */ + public String getCvsServer() { + return cvsServer; + } + + /** + * Sets the cvsServer. + * @param cvsServer The cvsServer to set + */ + public void setCvsServer(String cvsServer) { + this.cvsServer = cvsServer; + } } diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java new file mode 100644 index 000000000..36caf9fc7 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnection.java @@ -0,0 +1,117 @@ +package org.eclipse.team.internal.ccvs.core.connection; + +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.ccvs.core.CVSProviderPlugin; +import org.eclipse.team.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.ccvs.core.IServerConnection; +import org.eclipse.team.internal.ccvs.core.Policy; + +/** + * Implements a connection method which invokes an external tool to + * establish the connection to the cvs server. Authentication and starting + * of the cvs server are the responsibility of the external connection + * tool. + */ +public class ExtConnection implements IServerConnection { + + // command to start remote cvs in server mode + private static final String INVOKE_SVR_CMD = "server"; //$NON-NLS-1$ + + // The default port for rsh + private static final int DEFAULT_PORT = 9999; + + // cvs format for the repository (e.g. :extssh:user@host:/home/cvs/repo) + private ICVSRepositoryLocation location; + + // incoming from remote host + InputStream inputStream; + + // outgoing to remote host + OutputStream outputStream; + + // Process spawn to run the command + Process process; + + protected ExtConnection(ICVSRepositoryLocation location, String password) { + this.location = location; + // passwork not needed, authentication performed by external tool + } + + /** + * Closes the connection. + */ + public void close() throws IOException { + inputStream.close(); + outputStream.close(); + process.destroy(); + } + + /** + * Returns the <code>InputStream</code> used to read data from the + * server. + */ + public InputStream getInputStream() { + return inputStream; + } + + /** + * Returns the <code>OutputStream</code> used to send data to the + * server. + */ + public OutputStream getOutputStream() { + return outputStream; + } + + /** + * Opens the connection and invokes cvs in server mode. + * + * @see Connection.open() + */ + public void open(IProgressMonitor monitor) throws IOException { + String hostname = location.getHost(); + String username = location.getUsername(); + + String CVS_RSH = CVSProviderPlugin.getPlugin().getCvsRshCommand(); + String CVS_SERVER = CVSProviderPlugin.getPlugin().getCvsServer(); + String[] command = new String[] {CVS_RSH, "-l", username, hostname, CVS_SERVER, INVOKE_SVR_CMD}; //$NON-NLS-1$ + + int port = location.getPort(); + if (port == location.USE_DEFAULT_PORT) + port = DEFAULT_PORT; + try { + // The command line doesn't support the use of a port + if (port != DEFAULT_PORT) + throw new IOException(Policy.bind("EXTServerConnection.invalidPort")); //$NON-NLS-1$ + + if(CVS_RSH == null || CVS_SERVER == null) { + throw new IOException(Policy.bind("EXTServerConnection.varsNotSet")); //$NON-NLS-1$ + } + + process = Runtime.getRuntime().exec(command); + + inputStream = process.getInputStream(); + outputStream = process.getOutputStream(); + } catch (IOException ex) { + try { + close(); + } finally { + throw new IOException(Policy.bind("EXTServerConnection.ioError", CVS_RSH)); //$NON-NLS-1$ + } + } catch (RuntimeException e) { + try { + close(); + } finally { + throw new IOException(Policy.bind("EXTServerConnection.ioError", CVS_RSH)); //$NON-NLS-1$ + } + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java new file mode 100644 index 000000000..90b59aca1 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ExtConnectionMethod.java @@ -0,0 +1,26 @@ +package org.eclipse.team.internal.ccvs.core.connection; + +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ + +import org.eclipse.team.ccvs.core.ICVSRepositoryLocation; +import org.eclipse.team.ccvs.core.IConnectionMethod; +import org.eclipse.team.ccvs.core.IServerConnection; + +public class ExtConnectionMethod implements IConnectionMethod { + /** + * @see IConnectionMethod#getName + */ + public String getName() { + return "ext"; //$NON-NLS-1$ + } + + /** + * @see IConnectionMethod#createConnection + */ + public IServerConnection createConnection(ICVSRepositoryLocation repositoryRoot, String password) { + return new ExtConnection(repositoryRoot, password); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties index 811a10e09..aea7aa4a5 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties @@ -108,7 +108,7 @@ Command.status=status Command.tag=tag Command.update=update Command.valid-requests=valid-requests -Command.unsupportedResponse=Unsupported response {0} received from cvs server +Command.unsupportedResponse=Unsupported response received from cvs server: {0} Command.argumentNotManaged=Argument {0} is not managed Command.loadingSyncInfo=Loading CVS synchronization information Command.loadingSyncInfo=Saving CVS synchronization information @@ -162,4 +162,8 @@ SyncFileUtil_Error_reloading_sync_information_58=Error reloading sync informatio SyncFileUtil_Error_writing_to_.cvsignore_61=Error writing to .cvsignore SyncFileUtil_Cannot_close_.cvsignore_62=Cannot close .cvsignore -FileModificationValidator.isReadOnly=File is Read Only.
\ No newline at end of file +FileModificationValidator.isReadOnly=File is Read Only. + +EXTServerConnection.invalidPort=A port cannot be specified for the ext connection method. +EXTServerConnection.varsNotSet=Cannot run external ext program because CVS_RSH and CVS_SERVER variables are not initialized. +EXTServerConnection.ioError=Error starting external connection program: {0}. Ensure that the path is correct and that you can connect manually using this program.
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties index ee3f19ac0..fd12dcf69 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.properties +++ b/bundles/org.eclipse.team.cvs.ui/plugin.properties @@ -8,6 +8,7 @@ SharingWizard.name=CVS PreferencePage.name=CVS DecoratorPreferencePage.name=Decorators +ExtMethodPreferencePage.name=Ext Connection Method DecoratorStandard.name=CVS diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml.off b/bundles/org.eclipse.team.cvs.ui/plugin.xml.off index 488690d9d..85a7ee269 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.xml.off +++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml.off @@ -355,6 +355,15 @@ category="org.eclipse.team.cvs.ui.CVSPreferences">
</page>
</extension>
+
+ <extension
+ point = "org.eclipse.ui.preferencePages">
+ <page id="org.eclipse.team.cvs.ui.ExtMethodPreferencePage"
+ class="org.eclipse.team.internal.ccvs.ui.ExtMethodPreferencePage"
+ name="%ExtMethodPreferencePage.name"
+ category="org.eclipse.team.cvs.ui.CVSPreferences">
+ </page>
+ </extension>
<!-- **************** DECORATOR ******************* -->
<extension point="org.eclipse.ui.decorators">
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java index e8de3ce3f..112c14f79 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java @@ -167,6 +167,8 @@ public class CVSUIPlugin extends AbstractUIPlugin { store.setDefault(ICVSUIConstants.PREF_TIMEOUT, CVSProviderPlugin.DEFAULT_TIMEOUT); store.setDefault(ICVSUIConstants.PREF_SHOW_MODULES, false); store.setDefault(ICVSUIConstants.PREF_HISTORY_TRACKS_SELECTION, false); + store.setDefault(ICVSUIConstants.PREF_CVS_RSH, CVSProviderPlugin.DEFAULT_CVS_RSH); + store.setDefault(ICVSUIConstants.PREF_CVS_SERVER, CVSProviderPlugin.DEFAULT_CVS_SERVER); store.setDefault(ICVSUIConstants.PREF_FILETEXT_DECORATION, CVSDecoratorConfiguration.DEFAULT_FILETEXTFORMAT); store.setDefault(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION, CVSDecoratorConfiguration.DEFAULT_FOLDERTEXTFORMAT); @@ -185,6 +187,8 @@ public class CVSUIPlugin extends AbstractUIPlugin { // Forward the values to the CVS plugin CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(store.getBoolean(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES)); CVSProviderPlugin.getPlugin().setTimeout(store.getInt(ICVSUIConstants.PREF_TIMEOUT)); + CVSProviderPlugin.getPlugin().setCvsRshCommand(store.getString(ICVSUIConstants.PREF_CVS_RSH)); + CVSProviderPlugin.getPlugin().setCvsServer(store.getString(ICVSUIConstants.PREF_CVS_SERVER)); CVSProviderPlugin.getPlugin().setQuietness(CVSPreferencesPage.getQuietnessOptionFor(store.getInt(ICVSUIConstants.PREF_QUIETNESS))); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java new file mode 100644 index 000000000..ec71ca748 --- /dev/null +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java @@ -0,0 +1,143 @@ +package org.eclipse.team.internal.ccvs.ui; + +/* + * (c) Copyright IBM Corp. 2000, 2002. + * All Rights Reserved. + */ + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.eclipse.team.ccvs.core.CVSProviderPlugin; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class ExtMethodPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + Text cvsRsh; + Text cvsServer; + + /* + * @see PreferencePage#createContents(Composite) + */ + protected Control createContents(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + GridLayout layout= new GridLayout(); + layout.numColumns = 3; + composite.setLayout(layout); + composite.setLayoutData(new GridData()); + + Label intro = new Label(composite, SWT.LEFT); + intro.setText("These variables define the external connection program to use with the 'ext' connection method.\nThese values should be the same as the 'ext' CVS command-line environment variable settings."); + GridData data = new GridData(); + data.horizontalSpan = 3; + data.horizontalAlignment = GridData.FILL; + intro.setLayoutData(data); + + new Label(composite, SWT.NULL); new Label(composite, SWT.NULL); new Label(composite, SWT.NULL); // spacer + + new Label(composite, SWT.LEFT).setText("CVS_RSH:"); + cvsRsh = new Text(composite, SWT.BORDER); + cvsRsh.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + final Button b = new Button(composite, SWT.NONE); + b.setText("Browse..."); + b.setLayoutData(new GridData()); + b.addListener(SWT.MouseDown, new Listener() { + public void handleEvent (Event event) { + FileDialog d = new FileDialog(getShell()); + d.setText("Select a program or script"); + String file = d.open(); + if(file!=null) { + setCvsRshText(file); + } + } + }); + + + Label l = new Label(composite, SWT.LEFT | SWT.BOLD); + l.setText("Note:"); + l.setFont(JFaceResources.getBannerFont()); + + l = new Label(composite, SWT.LEFT); + l.setText("The RSH command must fit the following calling pattern:\n<CVS_RSH> -l <USERNAME> <HOST> <CVS_SERVER>\nThis program will be called to connect to the remote CVS server."); + data = new GridData(); + data.horizontalSpan = 2; + data.horizontalAlignment = GridData.FILL; + l.setLayoutData(data); + + new Label(composite, SWT.NULL); new Label(composite, SWT.NULL); new Label(composite, SWT.NULL); // spacer + + new Label(composite, SWT.LEFT).setText("CVS_SERVER:"); + cvsServer = new Text(composite, SWT.BORDER); + data = new GridData(); + data.horizontalSpan = 2; + data.horizontalAlignment = GridData.FILL; + cvsServer.setLayoutData(data); + + l = new Label(composite, SWT.LEFT | SWT.BOLD); + l.setText("Note:"); + l.setFont(JFaceResources.getBannerFont()); + + l = new Label(composite, SWT.LEFT); + l.setText("This is the name of the remote CVS server program.\nChange this setting only if the remote CVS server name\nis different than the default."); + data = new GridData(); + data.horizontalSpan = 2; + data.horizontalAlignment = GridData.FILL; + l.setLayoutData(data); + + + initializeDefaults(); + + return composite; + } + + protected void initializeDefaults() { + IPreferenceStore store = getPreferenceStore(); + cvsRsh.setText(store.getString(ICVSUIConstants.PREF_CVS_RSH)); + cvsServer.setText(store.getString(ICVSUIConstants.PREF_CVS_SERVER)); + } + + /* + * Set CVS_RSH program + */ + protected void setCvsRshText(String s) { + cvsRsh.setText(s); + } + + /* + * @see IWorkbenchPreferencePage#init(IWorkbench) + */ + public void init(IWorkbench workbench) { + } + + /* + * @see IPreferencePage#performOk() + */ + public boolean performOk() { + IPreferenceStore store = getPreferenceStore(); + store.setValue(ICVSUIConstants.PREF_CVS_RSH, cvsRsh.getText()); + store.setValue(ICVSUIConstants.PREF_CVS_SERVER, cvsServer.getText()); + CVSProviderPlugin.getPlugin().setCvsRshCommand(cvsRsh.getText()); + CVSProviderPlugin.getPlugin().setCvsServer(cvsServer.getText()); + return super.performOk(); + } + /* + * @see PreferencePage#doGetPreferenceStore() + */ + protected IPreferenceStore doGetPreferenceStore() { + return CVSUIPlugin.getPlugin().getPreferenceStore(); + } + +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java index f28ef47a1..0c15f00de 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java @@ -38,6 +38,8 @@ public interface ICVSUIConstants { public final String PREF_QUIETNESS = "pref_quietness"; public final String PREF_SHOW_MODULES = "pref_show_modules"; public final String PREF_HISTORY_TRACKS_SELECTION = "pref_history_tracks_selection"; + public final String PREF_CVS_RSH = "pref_cvs_rsh"; + public final String PREF_CVS_SERVER = "pref_cvs_server"; // decorator preferences public final String PREF_FILETEXT_DECORATION = "pref_filetext_decoration"; |