home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-10-10 | 4.8 KB | 193 lines |
- // VersionPanel.java
- //
- // Created 09/25/96
- //
- // (C)Copyright 1996 Microsoft Corporation, All rights reserved.
- //
-
- import java.awt.*;
- import java.util.*;
- import java.io.*;
- import com.ms.util.*;
-
- public
- class VersionPanel extends Panel
- {
- static Label addText (String str, Panel p, GridBagConstraints c)
- {
- Label text = new Label(str);
-
- ((GridBagLayout)p.getLayout()).setConstraints(text,c);
- p.add(text);
-
- return text;
- }
-
- List items;
- TextArea value;
- Label filever;
- Label descr;
- Label copyright;
- Properties version;
-
- void addVersionItems (Properties version, List items)
- {
- Enumeration e;
-
- e = version.keys();
-
- while (e.hasMoreElements())
- {
- String key = (String)e.nextElement();
- String value = version.getProperty(key);
-
- if (!( key.equals("LegalCopyright")
- || key.equals("FileVersion")
- || key.equals("Description") ))
- {
- items.addItem(key);
- }
- }
- }
-
- public VersionPanel ()
- {
- version = null;
-
- GridBagLayout grid = new GridBagLayout();
- setLayout(grid);
-
- GridBagConstraints c = new GridBagConstraints();
-
- c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.HORIZONTAL;
- addText("File version:",this,c);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- filever = addText("", this, c);
-
- c.gridwidth = 1;
- addText("Description:",this,c);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- descr = addText("",this,c);
-
- c.gridwidth = 1;
- addText("Copyright:",this,c);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- copyright = addText("",this,c);
-
- c.anchor = GridBagConstraints.SOUTHWEST;
- addText("Other version information",this,c);
-
-
- c.weightx = 1;
- c.weighty = 1;
- c.anchor = GridBagConstraints.CENTER;
- c.gridheight = GridBagConstraints.REMAINDER;
- c.fill = GridBagConstraints.BOTH;
- Panel bot = new Panel();
- grid.setConstraints(bot,c);
- add(bot);
- grid = new GridBagLayout();
- bot.setLayout(grid);
-
- c.weightx = 0;
- c.weighty = 0;
- c.gridheight = 1;
- c.gridwidth = 1;
- c.anchor = GridBagConstraints.SOUTHWEST;
- c.fill = GridBagConstraints.NONE;
- addText("Item name:",bot,c);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- addText("Value:",bot,c);
-
- c.weightx = 1;
- c.weighty = 1;
- c.gridwidth = 1;
- c.gridheight = GridBagConstraints.REMAINDER;
- c.anchor = GridBagConstraints.CENTER;
- c.fill = GridBagConstraints.BOTH;
- items = new List();
- grid.setConstraints(items,c);
- bot.add(items);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- value = new TextArea();
- value.setEditable(false);
- grid.setConstraints(value,c);
- bot.add(value);
- }
-
- VersionPanel (Properties i_version)
- {
- this();
- version = i_version;
-
- changeInfo(version);
- }
-
- public boolean handleEvent (Event e)
- {
- if (e.id == Event.LIST_SELECT)
- {
- value.setText((String)version.getProperty(items.getItem(items.getSelectedIndex())));
- return true;
- }
-
- return false;
- }
-
- public void clearInfo ()
- {
- if (version == null)
- return;
-
- items.clear();
- value.setText("");
- version = null;
- filever.setText("");
- descr.setText("");
- copyright.setText("");
- }
-
- public void changeInfo (Properties newinfo)
- {
- if (newinfo == null)
- {
- clearInfo();
- version = null;
- return;
- }
-
- version = newinfo;
-
- items.clear();
- value.setText("");
-
- String prop = version.getProperty("FileVersion");
-
- if (prop == null)
- {
- filever.setText(
- version.getProperty("MajorVersion")+"."
- +version.getProperty("MinorVersion")+"."
- +version.getProperty("BuildNumber")+"."
- +version.getProperty("BuildIncrement")
- );
- }
- else
- {
- filever.setText(prop);
- }
-
- addVersionItems(version,items);
-
- descr.setText(version.getProperty("Description"));
- copyright.setText(version.getProperty("LegalCopyright"));
- }
- }
-
-