View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.gui.plugin;
21  
22  import javax.swing.tree.DefaultMutableTreeNode;
23  
24  import org.xnap.pkg.PackageInfo;
25  import org.xnap.plugin.PluginInfo;
26  import org.xnap.plugin.PluginManager;
27  
28  public class PluginNode extends DefaultMutableTreeNode {
29  
30      //--- Contant(s) ---
31      
32  	public static final int STATE_KEEP = 0;
33  	public static final int STATE_INSTALL = 1;
34  	public static final int STATE_REMOVE = 2;
35  
36      //--- Data field(s) ---
37  	
38  	privatePackageInfo packageInfo/package-summary.html">> PackageInfo packageInfo;
39  	private PluginInfo pluginInfo;
40  	private String action;
41  	private boolean marked;
42  	
43      //--- Constructor(s) ---
44  	
45      publicPluginNode(PackageInfo packageInfo)/package-summary.html">ong> PluginNode(PackageInfo packageInfo)
46      {
47  		setPackageInfo(packageInfo);
48  	}
49  
50  	//--- Method(s) ---
51  
52  	/***
53  	 * The selected action.
54  	 */
55  	public String getAction()
56  	{
57  		return action;
58  	}
59  
60  	/***
61  	 * Returns the plugin info that corresponds to the package.
62  	 */
63  	public PluginInfo getPluginInfo()
64  	{
65  		return pluginInfo;
66  	}
67  
68  	/***
69  	 * Returns the package that is to be changed.
70  	 */
71  	public PackageInfo getPackageInfo()
72  	{
73  		returng> packageInfo;
74  	}
75  
76  	public boolean isActionChanged()
77  	{
78  		return (action != null) && !action.equals(packageInfo.getAction());
79  	}
80  
81  	public boolean isMarked()
82  	{
83  		return marked;
84  	}
85  
86  	public boolean isUpdateAvailable()
87  	{
88  		return (pluginInfo != null) 
89  			? packageInfo.compareToVersion(pluginInfo) > 0
90  			: false;
91  	}
92  
93  	public void setAction(String action)
94  	{
95  		this.action = action;
96  	}
97  
98  	public void setMarked(boolean marked)
99  	{
100 		this.marked = marked;
101 	}
102 
103 	publicPackageInfo packageInfo)/package-summary.html">> void setPackageInfo(PackageInfo packageInfo)
104 	{
105 		this.packageInfo = packageInfo;
106 		setAction(packageInfo.getAction());
107 		setPluginInfo
108 			(PluginManager.getInstance().getInfoByName(packageInfo.getName()));
109 	}
110 
111 	public void setPluginInfo(PluginInfo pluginInfo)
112 	{
113 		this.pluginInfo = pluginInfo;
114 	}
115 
116 }