public Boolean addEventListener(String name, ContextEventListener contextEventListener,
                                        Boolean sendRemoteCommand)
        {
            try
            {
                init();

                var ed = getEventData(name);

                if (ed == null)
                {
                    throw new ContextException(Cres.get().getString("conEventNotFound") + name);
                }

                if (sendRemoteCommand)
                {
                    addRemoteListener(ed.getDefinition().getName(), contextEventListener);
                }

                return(base.addEventListener(name, contextEventListener));
            }
            catch (Exception ex)
            {
                var msg = String.Format(Cres.get().getString("conErrAddingListener"), name, this.getPath());
                throw new InvalidOperationException(msg + ": " + ex.Message, ex);
            }
        }
Esempio n. 2
0
        public object checkAndConvertValue(Context context, ContextManager contextManager, CallerController <CallerData> caller, object value, bool validate)
        {
            if (!this.isNullable() && value == null)
            {
                throw new ValidationException("Nulls are not permitted in " + this);
                //throw new ValidationException(MessageFormat.format(Cres.get().getString("dtNullsNotPermitted"), this.toString()));
            }

            value = this.convertValue(value);

            if (value != null && !this.isExtendableSelectionValues() && this.hasSelectionValue(value))
            {
                if (validate)
                {
                    throw new ValidationException(Cres.get().getString("dtValueNotInSelVals") + value + " (" + value.GetType().Name + ")");
                }
                else
                {
                    value = this.getDefaultValue();
                }
            }

            if (validate)
            {
                foreach (var fv in this.validators)
                {
                    value = fv.validate(context, contextManager, caller, value);
                }
            }

            return(value);
        }
Esempio n. 3
0
        static EventUtils()
        {
            IntFieldFormat ff = (IntFieldFormat)FieldFormat.create("<" + FIELD_SEVERITY_STATS_LEVEL + "><I><D=" +
                                                                   Cres.get().getString(FIELD_SEVERITY_STATS_LEVEL) + ">");

            ff.setSelectionValues(EventLevel.getSelectionValues());
            SEVERITY_STATS_FORMAT.addField(ff);

            SEVERITY_STATS_FORMAT.addField(
                FieldFormat.create("<" + FIELD_SEVERITY_STATS_NUMBER + "><I><D=" + Cres.get().getString("efEventCount") + ">"));
            SEVERITY_STATS_FORMAT.addField(FieldFormat.create("<" + FIELD_SEVERITY_STATS_COLOR + "><C><F=H>"));
        }
Esempio n. 4
0
        public FieldFormat setEditor(string editorString)
        {
            if (immutable)
            {
                throw new ArgumentException("Immutable");
            }

            if (editorString != null && !this.getSuitableEditors().Contains(editorString))
            {
                Logger.getLogger(Log.DATATABLE).warn(Cres.get().getString("dtEditorNotSuitable") + editorString + " (" + this.ToString() + ")");
            }

            this.editor = editorString;

            return(this);
        }
Esempio n. 5
0
        static EventLevel()
        {
            LEVELS.Add(NOTICE, Cres.get().getString("conElNotice"));
            LEVELS.Add(INFO, Cres.get().getString("conElInfo"));
            LEVELS.Add(WARNING, Cres.get().getString("conElWarning"));
            LEVELS.Add(ERROR, Cres.get().getString("conElError"));
            LEVELS.Add(FATAL, Cres.get().getString("conElFatal"));
            LEVELS.Add(NONE, Cres.get().getString("conElNotDefined"));

            SELECTION_VALUES.Add(new NullableObject(0), Cres.get().getString("none"));

            for (int i = 1; i <= NUM_LEVELS; i++)
            {
                SELECTION_VALUES.Add(new NullableObject(i), getName(i));
            }
        }
Esempio n. 6
0
        public override object validate(Context context, ContextManager contextManager, CallerController <CallerData> caller, object value)
        {
            Regex reg;

            try
            {
                reg = new Regex(regex);
            }
            catch (ArgumentException ex)
            {
                throw new ValidationException(ex.Message, ex);
            }

            if (value != null && !reg.IsMatch(value.ToString()))
            {
                throw new ValidationException(this.message ?? string.Format(Cres.get().getString("dtValueDoesNotMatchPattern"), value, this.regex));
            }

            return(value);
        }
Esempio n. 7
0
        static TimeHelper()
        {
            SELECTION_VALUES.Add(MILLISECOND, Cres.get().getString("tuMillisecond"));
            SELECTION_VALUES.Add(SECOND, Cres.get().getString("tuSecond"));
            SELECTION_VALUES.Add(MINUTE, Cres.get().getString("tuMinute"));
            SELECTION_VALUES.Add(HOUR, Cres.get().getString("tuHour"));
            SELECTION_VALUES.Add(DAY, Cres.get().getString("tuDay"));
            SELECTION_VALUES.Add(WEEK, Cres.get().getString("tuWeek"));
            SELECTION_VALUES.Add(MONTH, Cres.get().getString("tuMonth"));
            SELECTION_VALUES.Add(QUARTER, Cres.get().getString("tuQuarter"));
            SELECTION_VALUES.Add(YEAR, Cres.get().getString("tuYear"));

            UNITS.Add(MILLISECOND_UNIT);
            UNITS.Add(SECOND_UNIT);
            UNITS.Add(MINUTE_UNIT);
            UNITS.Add(HOUR_UNIT);
            UNITS.Add(DAY_UNIT);
            UNITS.Add(WEEK_UNIT);
            UNITS.Add(MONTH_UNIT);
            UNITS.Add(QUARTER_UNIT);
            UNITS.Add(YEAR_UNIT);
        }
Esempio n. 8
0
        static FieldFormat()
        {
            TYPES.Add(INTEGER_FIELD, typeof(IntFieldFormat));
            TYPES.Add(STRING_FIELD, typeof(StringFieldFormat));
            TYPES.Add(BOOLEAN_FIELD, typeof(BooleanFieldFormat));
            TYPES.Add(LONG_FIELD, typeof(LongFieldFormat));
            TYPES.Add(FLOAT_FIELD, typeof(FloatFieldFormat));
            TYPES.Add(DOUBLE_FIELD, typeof(DoubleFieldFormat));
            TYPES.Add(DATE_FIELD, typeof(DateFieldFormat));
            TYPES.Add(DATATABLE_FIELD, typeof(DataTableFieldFormat));
            TYPES.Add(COLOR_FIELD, typeof(ColorFieldFormat));
            TYPES.Add(DATA_FIELD, typeof(DataFieldFormat));

            CLASS_TO_TYPE.Add(typeof(Int32), INTEGER_FIELD);
            CLASS_TO_TYPE.Add(typeof(string), STRING_FIELD);
            CLASS_TO_TYPE.Add(typeof(Boolean), BOOLEAN_FIELD);
            CLASS_TO_TYPE.Add(typeof(Int64), LONG_FIELD);
            CLASS_TO_TYPE.Add(typeof(float), FLOAT_FIELD);
            CLASS_TO_TYPE.Add(typeof(double), DOUBLE_FIELD);
            CLASS_TO_TYPE.Add(typeof(DateTime), DATE_FIELD);
            CLASS_TO_TYPE.Add(typeof(DataTable), DATATABLE_FIELD);
            CLASS_TO_TYPE.Add(typeof(Object), OBJECT_FIELD);
            CLASS_TO_TYPE.Add(typeof(Color), COLOR_FIELD);
            CLASS_TO_TYPE.Add(typeof(Data), DATA_FIELD);

            TYPE_SELECTION_VALUES.Add(INTEGER_FIELD.ToString(), Cres.get().getString("dtInteger"));
            TYPE_SELECTION_VALUES.Add(STRING_FIELD.ToString(), Cres.get().getString("dtString"));
            TYPE_SELECTION_VALUES.Add(BOOLEAN_FIELD.ToString(), Cres.get().getString("dtBoolean"));
            TYPE_SELECTION_VALUES.Add(LONG_FIELD.ToString(), Cres.get().getString("dtLong"));
            TYPE_SELECTION_VALUES.Add(FLOAT_FIELD.ToString(), Cres.get().getString("dtFloat"));
            TYPE_SELECTION_VALUES.Add(DOUBLE_FIELD.ToString(), Cres.get().getString("dtDouble"));
            TYPE_SELECTION_VALUES.Add(DATE_FIELD.ToString(), Cres.get().getString("date"));
            TYPE_SELECTION_VALUES.Add(DATATABLE_FIELD.ToString(), Cres.get().getString("dtDataTable"));
            TYPE_SELECTION_VALUES.Add(OBJECT_FIELD.ToString(), Cres.get().getString("dtObject"));
            TYPE_SELECTION_VALUES.Add(COLOR_FIELD.ToString(), Cres.get().getString("color"));
            TYPE_SELECTION_VALUES.Add(DATA_FIELD.ToString(), Cres.get().getString("dtDataBlock"));
        }