All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.harvard.hul.ois.jhove.viewer.ModuleInfoWindow Maven / Gradle / Ivy

/**********************************************************************
 * JhoveView - JSTOR/Harvard Object Validation Environment
 * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
 **********************************************************************/

package edu.harvard.hul.ois.jhove.viewer;

import java.awt.Font;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import edu.harvard.hul.ois.jhove.*;

/**
 *   This window is for presenting information about the selected
 *   module.  If no module is selected, a brief message is
 *   put into the window.
 */
public class ModuleInfoWindow extends InfoWindow{

    private JTextArea texta;
    private int _level;
    private Module _module;

    /**
     *  Constructor.
     *
     *  @param app    The associated App object.
     *  @param base   The associated JhoveBase object.
     *  @param module The Module whose information is to be presented.
     */
    public ModuleInfoWindow (App app, JhoveBase base, Module module) 
    {
        super ("Module Info", app, base);
        _module = module;
        setSaveActionListener ( 
            new ActionListener() {
                public void actionPerformed (ActionEvent e) {
                    saveInfo ();
                }
            });
        
        texta = new JTextArea ();
	texta.setColumns (72);
	JScrollPane scrollpane = new JScrollPane (texta);
	texta.setFont (new Font ("sansserif", Font.PLAIN, 10));
	texta.setLineWrap (true);
	texta.setWrapStyleWord (true);
	// Getting Swing to accept what you want for dimensions
	// apparently requires setting as many dimension restrictions
	// as possible, and hoping it will pay attention to some 
	// of them.
	scrollpane.setMinimumSize (new Dimension (240, 240));
	scrollpane.setMaximumSize (new Dimension (600, 500));
	scrollpane.setPreferredSize (new Dimension (600, 500));
	getContentPane ().add (scrollpane, "Center");

        // Add a small panel at the bottom, since on some OS's there
        // may be stuff near the bottom of a window which will conflict
        // with the scroll bar.
        JPanel panel = new JPanel ();
        panel.setMinimumSize (new Dimension (8, 8));
        getContentPane ().add (panel, "South");

        showModule (module);
        pack ();

    }

    /** Formats and presents the module information in 
     *  the window. */
    public void showModule (Module module)
    {
        _module = module;
        if (module == null) {
            texta.setText ("(No module selected)");
        }
        else {
            _level = 0;
            texta.setText ("");
            String margin = getIndent (++_level);
            texta.append (margin + "Module: " + module.getName () + eol);
            texta.append (margin + "Release: " + module.getRelease () + eol);
            texta.append (margin + "Date: " + _dateFmt.format (module.getDate ()) + eol);
    	    String [] ss = module.getFormat ();
            if (ss.length > 0) {
                texta.append (margin + "Format: " + ss[0]);
                for (int i = 1; i < ss.length; i++) {
                    texta.append (", " + ss[i]);
                }
                texta.append (eol);
            }
    
            String s = module.getCoverage ();
            if (s != null) {
                texta.append (margin + "Coverage: " + s + eol);
            }
            ss = module.getMimeType ();
            if (ss.length > 0) {
                texta.append (margin + "MIMEtype: " + ss[0]);
                for (int i=1; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy