1 24 25 package org.objectweb.cjdbc.console.gui.objects; 26 27 import java.awt.Color ; 28 29 import org.objectweb.cjdbc.console.gui.constants.GuiConstants; 30 import org.objectweb.cjdbc.console.gui.constants.GuiIcons; 31 32 38 public class DatabaseObject extends AbstractGuiObject 39 { 40 private String state; 41 private String controllerName; 42 private boolean isDistributed; 43 44 52 public DatabaseObject(String databaseName, String controllerName, 53 boolean isDistributed) 54 { 55 super(); 56 setText(databaseName); 57 setName(databaseName); 58 this.controllerName = controllerName; 59 this.isDistributed = isDistributed; 60 setBackground(Color.white); 61 if (isDistributed) 62 setIcon(GuiIcons.DATABASE_DISTRIBUTED_ICON); 63 else 64 setIcon(GuiIcons.DATABASE_SINGLE_ICON); 65 } 66 67 72 public String getIpAdress() 73 { 74 return controllerName.substring(0, controllerName.indexOf(':')); 75 } 76 77 82 public String getPort() 83 { 84 return controllerName.substring(controllerName.indexOf(':') + 1); 85 } 86 87 92 public String getState() 93 { 94 return state; 95 } 96 97 102 public void setState(String state) 103 { 104 if (state.equals(GuiConstants.CONTROLLER_STATE_UP)) 105 setIcon(GuiIcons.CONTROLLER_READY); 106 else 107 setIcon(GuiIcons.CONTROLLER_DOWN); 108 this.state = state; 109 } 110 111 116 public String getControllerName() 117 { 118 return controllerName; 119 } 120 121 126 public boolean isDistributed() 127 { 128 return isDistributed; 129 } 130 131 136 public void setDistributed(boolean isDistributed) 137 { 138 this.isDistributed = isDistributed; 139 } 140 } | Popular Tags |