ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chr...@apache.org
Subject cvs commit: jakarta-ant-antidote/src/java/org/apache/tools/ant/gui About.java
Date Tue, 03 Dec 2002 08:23:54 GMT
chrisw      2002/12/03 00:23:54

  Modified:    src/java/org/apache/tools/ant/gui/resources
                        antidote.properties
               src/java/org/apache/tools/ant/gui About.java
  Log:
  [antidote] Nicer About Dialog "to get my feet wet"
  
  Revision  Changes    Path
  1.4       +16 -13    jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/resources/antidote.properties
  
  Index: antidote.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/resources/antidote.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- antidote.properties	21 Jun 2001 16:04:57 -0000	1.3
  +++ antidote.properties	3 Dec 2002 08:23:54 -0000	1.4
  @@ -134,17 +134,20 @@
   #----------------------------------------------------------------------------
   
   org.apache.tools.ant.gui.About.title=About
  -org.apache.tools.ant.gui.About.ok=OK
  +org.apache.tools.ant.gui.About.version=Version
   org.apache.tools.ant.gui.About.message=\
  -	<html><h1>Antidote</h1> \
  -	<p>Copyright &copy; 2000 The Apache Software Foundation. <br>\
  -    All rights reserved.</p><br> \
  -    <p>Visit http://jakarta.apache.org/ant for more information.</p><br>
\
  -    <table> \
  -	<tr><td align="right"><b>Version</b>:</td><td>{0}</td></tr>
\
  -	<tr><td align="right"><b>Date</b>:</td><td>{1}</td></tr>
\
  -    </table> \
  -	<hr> \
  -    <p>Icons Copyright &copy; 1998 Dean S. Jones (deansjones@hotmail.com)<br>
\
  -    http://jfa.javalobby.org/projects/icons</p> \
  -	</html>
  +	<html><font face=Arial size=1 color=#000000>Copyright &copy; 2002 The
Apache Software Foundation. All rights reserved.<br>For more informations visit <b>jakarta.apache.org/ant</b></font></html>
  +
  +org.apache.tools.ant.gui.About.date=Date
  +
  +org.apache.tools.ant.gui.About.operatingSystem=Operating System
  +
  +org.apache.tools.ant.gui.About.freeMemory=Free Memory
  +
  +org.apache.tools.ant.gui.About.totalMemory=Total Memory
  +
  +org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.icon_open=project_open.gif
  +
  +org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.icon_open=target_open.gif
  +
  +org.apache.tools.ant.gui.acs.ACSTaskElementBeanInfo.icon_open=task_open.gif
  
  
  
  1.2       +168 -78   jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/About.java
  
  Index: About.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/About.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- About.java	8 Apr 2001 23:42:09 -0000	1.1
  +++ About.java	3 Dec 2002 08:23:54 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999, 2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -52,91 +52,181 @@
    * <http://www.apache.org/>.
    */
   package org.apache.tools.ant.gui;
  -import org.apache.tools.ant.gui.util.WindowUtils;
   
  +import org.apache.tools.ant.gui.util.WindowUtils;
   import org.apache.tools.ant.gui.core.AppContext;
  -import javax.swing.*;
  +
   import java.io.IOException;
  -import java.util.*;
  +import java.util.Properties;
  +
  +import java.awt.Frame;
   import java.awt.BorderLayout;
   import java.awt.Dimension;
  -import java.awt.event.ActionListener;
  -import java.awt.event.ActionEvent;
  +import java.awt.GridBagLayout;
  +import java.awt.GridBagConstraints;
  +import java.awt.Insets;
  +
  +import javax.swing.ImageIcon;
  +import javax.swing.JFrame;
  +import javax.swing.JDialog;
  +import javax.swing.JPanel;
  +import javax.swing.JTable;
  +import javax.swing.JLabel;
  +import javax.swing.JTabbedPane;
  +import javax.swing.JScrollPane;
  +import javax.swing.JOptionPane;
  +import javax.swing.BorderFactory;
  +import javax.swing.table.DefaultTableModel;
  +import javax.swing.table.TableColumn;
  +
   
   /**
    * Dialog displaying information on the application.
  - * 
  - * @version $Revision$ 
  - * @author Simeon Fitch 
  + *
  + * @version $Revision$
  + * @author Simeon Fitch, Christoph Wilhelms
    */
   public class About extends JDialog {
  -
  -	/** 
  -	 * Standard ctor.
  -	 * 
  -	 * @param context Application context.
  -	 */
  -	public About(AppContext context) {
  -		super(context.getParentFrame(), true);
  -		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  -
  -		String version = null;
  -		String date = null;
  -
  -		Properties props = new Properties();
  -
  -		try {
  -			props.load(getClass().getResourceAsStream("version.txt"));
  -		}
  -		catch(IOException ex) {
  -			// XXX log me.
  -			ex.printStackTrace();
  -			return;
  -		}
  -
  -		version = props.getProperty("VERSION", "??");
  -		date = props.getProperty("DATE", "??");
  -
  -		String message = context.getResources().getMessage(
  -			getClass(), "message", 
  -			new Object[] { version, date });
  -
  -		String title = context.getResources().getString(
  -			getClass(), "title");
  -		setTitle(title);
  -
  -        JTextPane contents = new JTextPane();
  -        contents.setContentType("text/html");
  -        contents.setText(message);
  -        contents.setEditable(false);
  -        // XXX Still not sure why this is necessary. JTextPane doesn't 
  -        // seem to report a "true" preferred size.
  -        contents.setPreferredSize(
  -            new Dimension(contents.getPreferredSize().width, 450));
  -		getContentPane().add(BorderLayout.CENTER, contents);
  -
  -		// Add the OK button.
  -		JButton ok = new JButton(
  -			context.getResources().getString(getClass(), "ok"));
  -		ok.addActionListener(new ActionHandler());
  -		JPanel p = new JPanel();
  -		p.add(ok);
  -		getContentPane().add(BorderLayout.SOUTH, p);
  -
  -        getRootPane().setDefaultButton(ok);
  -
  -
  -		// Just go ahead and show it...
  -		pack();
  -		WindowUtils.centerWindow(context.getParentFrame(), this);
  -		setVisible(true);
  -	}
  -
  -	/** Handles press of the OK button. */
  -	private class ActionHandler implements ActionListener {
  -		public void actionPerformed(ActionEvent e) {
  -			WindowUtils.sendCloseEvent(About.this);
  -		}
  -	}
  -
  +    
  +    private transient AppContext _context = null;
  +    
  +    /**
  +     * Standard ctor.
  +     *
  +     * @param context Application context.
  +     */
  +    public About(AppContext context) {
  +        super(context.getParentFrame(), true);
  +        _context = context;
  +        init();
  +    }
  +
  +    /** 
  +     * Alternative ctor for use without AppContext.
  +     */
  +    public About(JFrame parent) {
  +        super((Frame)((parent == null)?null:(parent instanceof Frame)?parent:JOptionPane.getFrameForComponent(parent)));
  +        init();
  +    }
  +    
  +    private void init() {
  +        
  +        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  +        
  +        setModal(true);
  +        String title = (_context!=null?_context.getResources().getString(getClass(), "title"):"");
  +        setTitle(title);
  +        JPanel mainPanel = new JPanel(new BorderLayout());
  +        setContentPane(mainPanel);
  +
  +        JTabbedPane mainTabbedPane = new JTabbedPane();
  +
  +        mainTabbedPane.add("About", getImagePanel());
  +        mainTabbedPane.add("Info", getClientInfoPanel());
  +
  +        mainPanel.add(mainTabbedPane, BorderLayout.CENTER);
  +        
  +        // Just go ahead and show it...
  +        pack();
  +        if (_context != null)
  +            WindowUtils.centerWindow(_context.getParentFrame(), this);
  +        setResizable(false);
  +        setVisible(true);
  +    }
  +    
  +    private JPanel getImagePanel() {
  +        JPanel imagePanel = new JPanel(new BorderLayout());
  +        JLabel imageLabel = new JLabel(new ImageIcon(getClass().getResource("/org/apache/tools/ant/gui/resources/About.gif")));
  +        imagePanel.add(imageLabel, BorderLayout.CENTER);
  +        
  +        JLabel messageLabel = (_context!=null?new JLabel(_context.getResources().getMessage(getClass(),
"message",new Object[] {})):null);
  +        
  +        if (messageLabel != null) {
  +            messageLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 3, 4));
  +            imagePanel.add(messageLabel, BorderLayout.SOUTH);
  +        }
  +        
  +        return imagePanel;
  +    }
  +    
  +    private JPanel getClientInfoPanel() {
  +        JPanel infoPanel = new JPanel(new GridBagLayout());
  +        
  +        String version = null;
  +        String date = null;
  +        
  +        Properties props = new Properties();
  +        
  +        try {
  +            props.load(getClass().getResourceAsStream("version.txt"));
  +        }
  +        catch(IOException ex) {
  +            // XXX log me.
  +            ex.printStackTrace();
  +        }
  +        
  +        version = props.getProperty("VERSION", "??");
  +        date = props.getProperty("DATE", "??");
  +
  +        JLabel iaLogoLabel = new JLabel();
  +        iaLogoLabel.setIcon(new ImageIcon(getClass().getResource("/org/apache/tools/ant/gui/resources/ant_small.gif")));
  +        infoPanel.add(iaLogoLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
GridBagConstraints.NONE, new Insets(5, 6, 0, 0), 0, 0));
  +        
  +        JLabel titleLabel = new JLabel("ANTidote");
  +        infoPanel.add(titleLabel, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(5, 6, 0, 0), 0, 0));
  +        
  +        JTable clientTable = new JTable();
  +        clientTable.setAutoCreateColumnsFromModel(false);
  +        clientTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
  +        
  +        TableColumn col = new TableColumn(0);
  +        col.setHeaderValue("Property");
  +        col.setPreferredWidth(100);
  +        clientTable.getColumnModel().addColumn(col);
  +        
  +        col = new TableColumn(1);
  +        col.setHeaderValue("Value");
  +        col.setPreferredWidth(250);
  +        clientTable.getColumnModel().addColumn(col);
  +        
  +        String [] dummy = {"",""};
  +        String[][] data = new String[9][2];
  +        data[0][0] = (_context!=null?_context.getResources().getString(getClass(), "version"):"Version");
  +        data[0][1] = version;
  +        data[1][0] = (_context!=null?_context.getResources().getString(getClass(), "date"):"Date");
  +        data[1][1] = date;
  +        data[2][0] = (_context!=null?_context.getResources().getString(getClass(), "operatingSystem"):"Operating
System");
  +        data[2][1] = System.getProperty("os.name")+" version "+System.getProperty("os.version")+"
running on "+System.getProperty("os.arch");
  +        data[3][0] = "Java";
  +        data[3][1] = System.getProperty("java.version");
  +        data[4][0] = "VM";
  +        data[4][1] = System.getProperty("java.vm.name")+" "+System.getProperty("java.vm.version");
  +        data[5][0] = "Java Home";
  +        data[5][1] = System.getProperty("java.home");
  +        data[6][0] = "System Locale";
  +        data[6][1] = System.getProperty("user.language")+"_"+System.getProperty("user.region");
  +        data[7][0] = (_context!=null?_context.getResources().getString(getClass(), "freeMemory"):"Free
Memory");
  +        data[7][1] = (Runtime.getRuntime().freeMemory()/1024)+" kByte";
  +        data[8][0] = (_context!=null?_context.getResources().getString(getClass(), "totalMemory"):"Total
Memory");
  +        data[8][1] = (Runtime.getRuntime().totalMemory()/1024)+" kByte";
  +        
  +        clientTable.setModel(new DefaultTableModel(data, dummy) {
  +            public boolean isCellEditable(int r, int c) {
  +                return false;
  +            }
  +        });
  +        
  +        clientTable.setRowSelectionAllowed(false);
  +        
  +        JScrollPane tableScrollPane = new JScrollPane(clientTable);
  +        tableScrollPane.setPreferredSize(new Dimension(250, 100));
  +        infoPanel.add(tableScrollPane, new GridBagConstraints(1, 4, 2, 1, 0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(1, 6, 2, 6), 0, 0));
  +        
  +        JLabel deanLabel = new JLabel("<html><font face=Arial size=1 color=#000000>Icons:
Copyright &copy; 1998 Dean S. Jones (deansjones@hotmail.com)<br>http://sourceforge.net/projects/icon-collection/</font></html>");
  +        infoPanel.add(deanLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(1, 6, 2, 6), 0, 0));
  +        
  +        infoPanel.setBorder(BorderFactory.createEmptyBorder(7,7,5,7));
  +        
  +        return infoPanel;
  +    }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message