Search in sources :

Example 6 with ObjectStatus

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);
    }
}
Also used : ObjectStatus(org.netxms.client.constants.ObjectStatus) AbstractObject(org.netxms.client.objects.AbstractObject) Interface(org.netxms.client.objects.Interface)

Example 7 with ObjectStatus

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;
}
Also used : NumericTextFieldValidator(org.netxms.ui.eclipse.tools.NumericTextFieldValidator) NXCSession(org.netxms.client.NXCSession) ObjectStatus(org.netxms.client.constants.ObjectStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

ObjectStatus (org.netxms.client.constants.ObjectStatus)7 AbstractObject (org.netxms.client.objects.AbstractObject)3 Point (org.eclipse.swt.graphics.Point)2 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)2 Resources (android.content.res.Resources)1 Drawable (android.graphics.drawable.Drawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ConnectionEndpointLocator (org.eclipse.draw2d.ConnectionEndpointLocator)1 IFigure (org.eclipse.draw2d.IFigure)1 Label (org.eclipse.draw2d.Label)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 PolylineDecoration (org.eclipse.draw2d.PolylineDecoration)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 GeoLocation (org.netxms.base.GeoLocation)1 InetAddressEx (org.netxms.base.InetAddressEx)1