1 package org.ozoneDB.adminGui.feature; 9 10 import javax.swing.*; 11 12 15 public class Feature { 16 17 private String name = ""; 18 private String detailText = ""; 19 private boolean enabled = true; 20 private ImageIcon image; 21 private Class panelClass; 22 private FeaturePanel panel; 23 private FeatureButton featureButton; 24 25 private final boolean defaultFeature; 26 27 public Feature(String name, String imageName, Class panelClass) { 28 this(name, imageName, panelClass, false); 29 } 30 31 public Feature(String name, String imageName, Class 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 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 getDetailText() { 71 return detailText; 72 } 73 74 public void setDetailText(String 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 e) { 90 e.printStackTrace(); 91 } 92 } 93 94 public boolean equals(Object o) { 95 if (o instanceof Feature) { 96 return this.name.equals(((Feature) o).name); 97 } 98 return false; 99 } 100 101 } | Popular Tags |