/*
 * Autopsy Forensic Browser
 * 
 * Copyright 2014 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sleuthkit.autopsy.ingest;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JDialog;
import org.openide.util.NbBundle;
import org.openide.windows.WindowManager;

/**
 * A dialog that displays ingest task progress snapshots.
 */
public final class IngestProgressSnapshotDialog extends JDialog {

    private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestProgressSnapshotDialog.title.text");
    private static final Dimension DIMENSIONS = new Dimension(500, 300);
    private JDialog pseudoOwner = null;

    /**
     * Constructs a non-modal instance of the dialog with its own frame.
     */
    public IngestProgressSnapshotDialog() {
        this((Window) WindowManager.getDefault().getMainWindow(), false);
    }

    /**
     * Constructs an instance of the dialog with its own frame. Could be modal.
     *
     * @param owner - the owner of this dialog. If this dialog should be modal, the owner gets set to non modal.
     * @param shouldBeModal - true if this should be modal, false otherwise.
     */
    public IngestProgressSnapshotDialog(Container owner, Boolean shouldBeModal) {
        super((Window) owner, TITLE, ModalityType.MODELESS);
        if (shouldBeModal) { // if called from a modal dialog, manipulate the parent be just under this in z order, and not modal.
            pseudoOwner = (JDialog) owner;
            addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosed(WindowEvent e) { // Put it back to how it was before we manipulated it.
                    pseudoOwner.setVisible(false);
                    pseudoOwner.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
                    pseudoOwner.toFront();
                    pseudoOwner.setVisible(true);
                }
            });
            pseudoOwner.setVisible(false);
            pseudoOwner.setModalityType(Dialog.ModalityType.MODELESS);
            pseudoOwner.toFront();
            pseudoOwner.repaint();
            pseudoOwner.setVisible(true);
        }
        setResizable(true);
        setLayout(new BorderLayout());
        Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
        setSize(DIMENSIONS);
        int w = this.getSize().width;
        int h = this.getSize().height;
        setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2);
        add(new IngestProgressSnapshotPanel(this));
        pack();
        setResizable(false);
        if (shouldBeModal) { // if called from a modal dialog, become modal, otherwise don't.
            setModal(true);
        }
        setVisible(true);
    }
}

@@ -1400,44 +1400,8 @@
     
-private JDialog pseudoOwner = null;%0A
 %0A   
@@ -2064,32 +2064,60 @@
 f (shouldBeModal
+ && owner instanceof JDialog
 ) %7B // if called
@@ -2210,32 +2210,46 @@
 al.%0A            
+final JDialog 
 pseudoOwner = (J

Use final local instead of member variable, add instanceof for JDialog.