View Javadoc

1   package com.explosion.expf.menusandtools.HistoryManager;
2   
3   /* =============================================================================
4    *       
5    *     Copyright 2004 Stephen Cowx
6    *
7    *     Licensed under the Apache License, Version 2.0 (the "License");
8    *     you may not use this file except in compliance with the License.
9    *     You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *     Unless required by applicable law or agreed to in writing, software
14   *     distributed under the License is distributed on an "AS IS" BASIS,
15   *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *     See the License for the specific language governing permissions and
17   *     limitations under the License.
18   * 
19   * =============================================================================
20   */
21  
22  import java.io.Externalizable;
23  import java.io.ObjectInput;
24  import java.io.ObjectOutput;
25  
26  import javax.swing.JMenuItem;
27  
28  public class HistoryJMenuItem extends JMenuItem implements Externalizable
29  {
30    private int number = 0;
31    private Object item;
32    private String itemLabel;
33  
34    public HistoryJMenuItem(String itemLabel, Object item, int number)
35    {
36      this.item = item;
37      this.itemLabel = itemLabel;
38      this.number = number;
39    }
40  
41    public HistoryJMenuItem()
42    {
43    }
44  
45    public void setItem(Object item)
46    {
47      this.item = item;
48    }
49  
50    public Object getItem()
51    {
52      return this.item;
53    }
54  
55    public void setItemLabel(String itemLabel)
56    {
57      this.itemLabel = itemLabel;
58    }
59  
60    public String getItemLabel()
61    {
62      return this.itemLabel;
63    }
64  
65    public void setNumber(int number)
66    {
67      this.number = number;
68    }
69  
70    public int getNumber()
71    {
72      return this.number;
73    }
74  
75    public void readExternal(ObjectInput oi)
76    {
77      try
78      {
79        this.item = oi.readObject();
80        this.itemLabel = (String) oi.readObject();
81        this.number = ((Integer) oi.readObject()).intValue();
82      }
83      catch (Exception e)
84      {
85        com.explosion.utilities.exception.ExceptionManagerFactory.getExceptionManager().manageException(e, null);
86      }
87    }
88  
89    public void writeExternal(ObjectOutput oo)
90    {
91      try
92      {
93        oo.writeObject(item);
94        oo.writeObject(itemLabel);
95        oo.writeObject(new Integer(number));
96      }
97      catch (Exception e)
98      {
99        com.explosion.utilities.exception.ExceptionManagerFactory.getExceptionManager().manageException(e, null);
100     }
101   }
102 }