public void refreshInfo(Vertex v) {
clearLabels();
rmaxwitdh = 0;
vselected = v;
sip.showServices(v);
Host h = _gm.getVertexHost(vselected);
HostStatus hs = _gm.getVertexHostStatus(vselected);
JLabel tmp = null;
Font f = null;
FontMetrics fm = null;
tmp = labelsRight.get(labelsTexts[0]);
f = tmp.getFont();
fm = tmp.getFontMetrics(f);
if (h != null) {
tmp.setText(h.getName());
tmp.setToolTipText(tmp.getText());
tmp = labelsRight.get(labelsTexts[1]);
tmp.setText(h.getDescription());
tmp.setToolTipText(tmp.getText());
tmp = labelsRight.get(labelsTexts[2]);
tmp.setText(h.getAddress());
tmp.setToolTipText(tmp.getText());
tmp = labelsRight.get(labelsTexts[3]);
tmp.setText(h.getParentsString());
}
if (hs != null) {
tmp.setToolTipText(tmp.getText());
tmp = labelsRight.get(labelsTexts[4]); // status info
tmp.setText(hs.getPluginOutput());
tmp.setToolTipText(tmp.getText());
// ^^^^^ status info
tmp = labelsRight.get(labelsTexts[5]); // current state
String currState = hs.getCurrentState().toString();
setFontColor(tmp, hs.getCurrentState(), hs.getProblemHasBeenAcknowledged());
tmp.setText(currState + hasBeenAcknowledged(hs.getProblemHasBeenAcknowledged(), hs.getCurrentState()));
tmp.setToolTipText(tmp.getText());
// Last check
tmp = labelsRight.get(labelsTexts[6]);
long time = hs.getLastCheck();
if (time != 0) {
tmp.setText(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(time));
} else {
tmp.setText("N/A");
}
tmp.setToolTipText(tmp.getText());
// time in actual state
tmp = labelsRight.get(labelsTexts[7]);
tmp.setText(timeInActualState(System.currentTimeMillis() - hs.getLastStateChange()) + (hs.getLastStateChange() == 0?"+":""));
tmp.setToolTipText(tmp.getText());
tmp = labelsRight.get(labelsTexts[8]); //previous hard state
setFontColor(tmp, hs.getLastHardState());
tmp.setText(hs.getLastHardState().toString());
tmp = labelsRight.get(labelsTexts[9]);
time = hs.getLastHardStateChange();
if (time != 0) {
tmp.setText(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(hs.getLastHardStateChange()));
} else {
tmp.setText("N/A");
}
tmp.setToolTipText(tmp.getText());
time = 0;
time = hs.getLastTimeUp();
tmp = labelsRight.get(labelsTexts[10]);
if (time != 0) {
tmp.setText(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(hs.getLastTimeUp()));
} else {
tmp.setText("N/A");
}
tmp.setToolTipText(tmp.getText());
time = 0;
time = hs.getLastTimeDown();
tmp = labelsRight.get(labelsTexts[11]);
if (time != 0) {
tmp.setText(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(hs.getLastTimeDown()));
} else {
tmp.setText("N/A");
}
tmp.setToolTipText(tmp.getText());
tmp = labelsRight.get(labelsTexts[12]);
time = 0;
time = hs.getLastTimeUnreachable();
if (time != 0) {
tmp.setText(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(hs.getLastTimeUnreachable()));
} else {
tmp.setText("N/A");
}
tmp.setToolTipText(tmp.getText());
// check host to only show services links it has
tmp = labelsInfo.get(16);
if (_gm.getHostExtInfo(h.getName()) != null &&
_gm.getHostExtInfo(h.getName()).getNotesUrl().length() == 0) {
tmp.setEnabled(false);
} else {
tmp.setEnabled(true);
}