The login command.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/vcscvs/src/org/netbeans/modules/vcs/cmdline/commands/CvsLogin.java Mon Mar 05 09:06:22 2001 +0000
1.3 @@ -0,0 +1,64 @@
1.4 +/*
1.5 + * Sun Public License Notice
1.6 + *
1.7 + * The contents of this file are subject to the Sun Public License
1.8 + * Version 1.0 (the "License"). You may not use this file except in
1.9 + * compliance with the License. A copy of the License is available at
1.10 + * http://www.sun.com/
1.11 + *
1.12 + * The Original Code is NetBeans. The Initial Developer of the Original
1.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
1.14 + * Microsystems, Inc. All Rights Reserved.
1.15 + */
1.16 +
1.17 +package org.netbeans.modules.vcs.cmdline.commands;
1.18 +
1.19 +import java.util.*;
1.20 +
1.21 +import org.netbeans.modules.vcscore.VcsFileSystem;
1.22 +import org.netbeans.modules.vcscore.commands.CommandOutputListener;
1.23 +import org.netbeans.modules.vcscore.commands.CommandDataOutputListener;
1.24 +import org.netbeans.modules.vcscore.cmdline.*;
1.25 +
1.26 +import org.netbeans.modules.vcs.cmdline.CvsFileSystem;
1.27 +import org.netbeans.modules.vcs.cmdline.passwd.LoginDialog;
1.28 +
1.29 +/**
1.30 + * This class is used as a CVS login command.
1.31 + * @author Martin Entlicher
1.32 + */
1.33 +public class CvsLogin implements VcsAdditionalCommand {
1.34 +
1.35 + private VcsFileSystem fileSystem = null;
1.36 +
1.37 + public void setFileSystem(VcsFileSystem fileSystem) {
1.38 + this.fileSystem = fileSystem;
1.39 + }
1.40 +
1.41 + public boolean exec(Hashtable vars, String[] args,
1.42 + CommandOutputListener stdoutNRListener, CommandOutputListener stderrNRListener,
1.43 + CommandDataOutputListener stdoutListener, String dataRegex,
1.44 + CommandDataOutputListener stderrListener, String errorRegex) {
1.45 +
1.46 + if (fileSystem instanceof CvsFileSystem) {
1.47 + CvsFileSystem cvsFileSystem = (CvsFileSystem) fileSystem;
1.48 + LoginDialog login = LoginDialog.createDialog(cvsFileSystem);
1.49 + login.setPserverName(cvsFileSystem.getCvsServer());
1.50 + String connectStr = ":pserver:" + cvsFileSystem.getCvsUserName()
1.51 + + "@" + cvsFileSystem.getCvsServer()
1.52 + + ":" + cvsFileSystem.getCvsRoot();
1.53 + login.setConnectString(connectStr);
1.54 + login.show();
1.55 + boolean loginCancelled = !login.isOffline();
1.56 + boolean isLoggedIn = login.isLoggedIn();
1.57 + if (!isLoggedIn && !loginCancelled) {
1.58 + fileSystem.setOffLine(true); // set offline mode
1.59 + } else if (isLoggedIn) {
1.60 + fileSystem.setOffLine(false); // unset offline mode
1.61 + }
1.62 + return isLoggedIn || loginCancelled;
1.63 + }
1.64 + return false;
1.65 + }
1.66 +}
1.67 +