KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > adminGui > feature > Feature


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: $
8
package org.ozoneDB.adminGui.feature;
9
10 import javax.swing.*;
11
12 /**
13  * @author Per Nyfelt
14  */

15 public class Feature {
16
17     private String JavaDoc name = "";
18     private String JavaDoc detailText = "";
19     private boolean enabled = true;
20     private ImageIcon image;
21     private Class JavaDoc panelClass;
22     private FeaturePanel panel;
23     private FeatureButton featureButton;
24
25     private final boolean defaultFeature;
26
27     public Feature(String JavaDoc name, String JavaDoc imageName, Class JavaDoc panelClass) {
28         this(name, imageName, panelClass, false);
29     }
30
31     public Feature(String JavaDoc name, String JavaDoc imageName, Class JavaDoc panelClass, boolean defaultFeature) {
32         this.name = name;
33         if (imageName != null) {
34             this.image = new ImageIcon(this.getClass().getResource(imageName));
35         }
36         this.panelClass = panelClass;
37         this.defaultFeature = defaultFeature;
38     }
39
40     public String JavaDoc getName() {
41         return name;
42     }
43
44     public void setEnabled(boolean enabled) {
45         this.enabled = enabled;
46         if (featureButton != null) {
47             featureButton.setEnabled(enabled);
48         }
49     }
50
51     public boolean isEnabled() {
52         return this.enabled;
53     }
54
55     public boolean isDefaultFeature() {
56         return defaultFeature;
57     }
58
59     public ImageIcon getImage() {
60         return image;
61     }
62
63     public FeaturePanel getPanel() {
64         if (panel == null) {
65             createPanel();
66         }
67         return panel;
68     }
69
70     public String JavaDoc getDetailText() {
71         return detailText;
72     }
73
74     public void setDetailText(String JavaDoc detailText) {
75         this.detailText = detailText;
76     }
77
78     public FeatureButton getFeatureButton() {
79         return featureButton;
80     }
81
82     public void setFeatureButton(FeatureButton featureButton) {
83         this.featureButton = featureButton;
84     }
85
86     private void createPanel() {
87         try {
88             panel = (FeaturePanel) panelClass.newInstance();
89         } catch (Exception JavaDoc e) {
90             e.printStackTrace();
91         }
92     }
93
94     public boolean equals(Object JavaDoc o) {
95         if (o instanceof Feature) {
96             return this.name.equals(((Feature) o).name);
97         }
98         return false;
99     }
100
101 }
Popular Tags