Example usage for org.eclipse.jgit.awtui AwtCredentialsProvider install

List of usage examples for org.eclipse.jgit.awtui AwtCredentialsProvider install

Introduction

In this page you can find the example usage for org.eclipse.jgit.awtui AwtCredentialsProvider install.

Prototype

public static void install() 

Source Link

Document

Install this implementation as the default.

Usage

From source file:kr.re.ec.grigit.util.PgmMain.java

License:Eclipse Distribution License

/**
 * Parse the command line and execute the requested action.
 *
 * Subclasses should allocate themselves and then invoke this method:
 *
 * <pre>//from w w w .  ja  va  2  s .com
 * class ExtMain {
 *    public static void main(String[] argv) {
 *       new ExtMain().run(argv);
 *    }
 * }
 * </pre>
 *
 * @param argv
 *            arguments.
 */
protected void run(final String[] argv) {
    logger = LoggerFactory.getLogger(PgmMain.class);

    try {
        if (!installConsole()) {
            AwtAuthenticator.install();
            AwtCredentialsProvider.install();
        }
        configureHttpProxy();
        execute(argv);
    } catch (Die err) {
        if (err.isAborted())
            //System.exit(1);
            System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
        if (showStackTrace)
            err.printStackTrace();
        //System.exit(128);
    } catch (Exception err) {
        // Try to detect errno == EPIPE and exit normally if that happens
        // There may be issues with operating system versions and locale,
        // but we can probably assume that these messages will not be thrown
        // under other circumstances.
        if (err.getClass() == IOException.class) {
            // Linux, OS X
            if (err.getMessage().equals("Broken pipe")) //$NON-NLS-1$
                //   System.exit(0);
                logger.info("Broken pipe");

            // Windows
            if (err.getMessage().equals("The pipe is being closed")) //$NON-NLS-1$
                //   System.exit(0);
                logger.info("The pipe is being closed");
        }
        if (!showStackTrace && err.getCause() != null && err instanceof TransportException)
            System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getCause().getMessage()));

        if (err.getClass().getName().startsWith("org.eclipse.jgit.errors.")) { //$NON-NLS-1$
            System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
            if (showStackTrace)
                err.printStackTrace();
            //System.exit(128);
        }
        err.printStackTrace();
        //System.exit(1);
    }
    if (System.out.checkError()) {
        System.err.println(CLIText.get().unknownIoErrorStdout);
        //System.exit(1);
    }
    if (System.err.checkError()) {
        // No idea how to present an error here, most likely disk full or
        // broken pipe
        //System.exit(1);
    }
}