public void activateOptions()

in src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java [225:321]


    public void activateOptions() {
        //we don't want to call super.activateOptions, but we do want active to be set to true
        active = true;
        //on receiver restart, only prompt for credentials if we don't already have them
        if (promptForUserInfo && !getFileURL().contains("@")) {
    	  /*
    	  if promptforuserinfo is true, wait for a reference to the container
    	  (via the VisualReceiver callback).

    	  We need to display a login dialog on top of the container, so we must then
    	  wait until the container has been added to a frame
    	  */

            //get a reference to the container
            new Thread(() -> {
                synchronized (waitForContainerLock) {
                    while (container == null) {
                        try {
                            waitForContainerLock.wait(1000);
                            logger.debug("waiting for setContainer call");
                        } catch (InterruptedException ie) {
                        }
                    }
                }

                Frame containerFrame1;
                if (container instanceof Frame) {
                    containerFrame1 = (Frame) container;
                } else {
                    synchronized (waitForContainerLock) {
//loop until the container has a frame
                        while ((containerFrame1 = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, container)) == null) {
                            try {
                                waitForContainerLock.wait(1000);
                                logger.debug("waiting for container's frame to be available");
                            } catch (InterruptedException ie) {
                            }
                        }
                    }
                }
                final Frame containerFrame = containerFrame1;
                //create the dialog
                SwingUtilities.invokeLater(() -> {
                    Frame owner = null;
                    if (container != null) {
                        owner = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, containerFrame);
                    }
                    final UserNamePasswordDialog f = new UserNamePasswordDialog(owner);
                    f.pack();
                    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                    f.setLocation(d.width / 2, d.height / 2);
                    f.setVisible(true);
                    if (null == f.getUserName() || null == f.getPassword()) {
                        logger.info("Username and password not both provided, not using credentials");
                    } else {
                        String oldURL = getFileURL();
                        int index = oldURL.indexOf("://");
                        String firstPart = oldURL.substring(0, index);
                        String lastPart = oldURL.substring(index + "://".length());
                        setFileURL(firstPart + "://" + f.getUserName() + ":" + new String(f.getPassword()) + "@" + lastPart);

                        setHost(oldURL.substring(0, index + "://".length()));
                        setPath(oldURL.substring(index + "://".length()));
                    }
                    vfsReader = new VFSReader();
                    new Thread(vfsReader).start();
                });
            }).start();
        } else {
            //starts with protocol:/  but not protocol://
            String oldURL = getFileURL();
            if (oldURL != null && oldURL.contains(":/") && !oldURL.contains("://")) {
                int index = oldURL.indexOf(":/");
                String lastPart = oldURL.substring(index + ":/".length());
                int passEndIndex = lastPart.indexOf("@");
                if (passEndIndex > -1) { //we have a username/password
                    setHost(oldURL.substring(0, index + ":/".length()));
                    setPath(lastPart.substring(passEndIndex + 1));
                }
                vfsReader = new VFSReader();
                new Thread(vfsReader).start();
            } else if (oldURL != null && oldURL.contains("://")) {
                //starts with protocol://
                int index = oldURL.indexOf("://");
                String lastPart = oldURL.substring(index + "://".length());
                int passEndIndex = lastPart.indexOf("@");
                if (passEndIndex > -1) { //we have a username/password
                    setHost(oldURL.substring(0, index + "://".length()));
                    setPath(lastPart.substring(passEndIndex + 1));
                }
                vfsReader = new VFSReader();
                new Thread(vfsReader).start();
            } else {
                logger.info("null URL - unable to parse file");
            }
        }
    }