use of org.netxms.client.constants.ObjectStatus in project netxms by netxms.
the class ObjectDecorator method decorate.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
*/
@Override
public void decorate(Object element, IDecoration decoration) {
ObjectStatus status = ((AbstractObject) element).getStatus();
decoration.addOverlay(statusImages[status.getValue()], IDecoration.BOTTOM_RIGHT);
if (((AbstractObject) element).isInMaintenanceMode()) {
decoration.addOverlay(maintModeImage, IDecoration.TOP_RIGHT);
decoration.addSuffix(Messages.get().ObjectDecorator_MaintenanceSuffix);
decoration.setForegroundColor(maintColor);
}
if (element instanceof Interface) {
if ((((Interface) element).getOperState() == Interface.OPER_STATE_DOWN) && (((Interface) element).getAdminState() == Interface.ADMIN_STATE_UP) && (((Interface) element).getExpectedState() == Interface.EXPECTED_STATE_IGNORE))
decoration.addOverlay(statusImages[ObjectStatus.CRITICAL.getValue()], IDecoration.TOP_LEFT);
}
}
use of org.netxms.client.constants.ObjectStatus in project netxms by netxms.
the class StatusCalculation method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
if (!WidgetHelper.validateTextInput(textRelativeStatus, Messages.get().StatusCalculation_Validate_RelativeStatus, new NumericTextFieldValidator(-4, 4), this) || !WidgetHelper.validateTextInput(textSingleThreshold, Messages.get().StatusCalculation_Validate_SingleThreshold, new NumericTextFieldValidator(0, 100), this) || !WidgetHelper.validateTextInput(textThresholds[0], String.format(Messages.get().StatusCalculation_Validate_Threshold, StatusDisplayInfo.getStatusText(Severity.WARNING)), new NumericTextFieldValidator(0, 100), this) || !WidgetHelper.validateTextInput(textThresholds[1], String.format(Messages.get().StatusCalculation_Validate_Threshold, StatusDisplayInfo.getStatusText(Severity.MINOR)), new NumericTextFieldValidator(0, 100), this) || !WidgetHelper.validateTextInput(textThresholds[2], String.format(Messages.get().StatusCalculation_Validate_Threshold, StatusDisplayInfo.getStatusText(Severity.MAJOR)), new NumericTextFieldValidator(0, 100), this) || !WidgetHelper.validateTextInput(textThresholds[3], String.format(Messages.get().StatusCalculation_Validate_Threshold, StatusDisplayInfo.getStatusText(Severity.CRITICAL)), new NumericTextFieldValidator(0, 100), this))
return false;
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setStatusCalculationMethod(calculationMethod);
md.setStatusPropagationMethod(propagationMethod);
md.setFixedPropagatedStatus(ObjectStatus.getByValue(comboFixedStatus.getSelectionIndex()));
md.setStatusShift(Integer.parseInt(textRelativeStatus.getText()));
ObjectStatus[] transformations = new ObjectStatus[4];
for (int i = 0; i < 4; i++) transformations[i] = ObjectStatus.getByValue(comboTranslatedStatus[i].getSelectionIndex());
md.setStatusTransformation(transformations);
md.setStatusSingleThreshold(Integer.parseInt(textSingleThreshold.getText()));
int[] thresholds = new int[4];
for (int i = 0; i < 4; i++) thresholds[i] = Integer.parseInt(textThresholds[i].getText());
md.setStatusThresholds(thresholds);
if (!hasChanges(md))
// Nothing to apply
return true;
currentState = md;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(String.format(Messages.get().StatusCalculation_JobName, object.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return Messages.get().StatusCalculation_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
StatusCalculation.this.setValid(true);
}
});
}
}
}.start();
return true;
}
Aggregations