@Override public void action(final Object cmp) { for (int i = 1; i < EDITKIND.length; ++i) if (radio[i].isSelected()) kind = i; gui.gprop.set(GUIProp.LASTINSERT, kind); String msg = null; ok = kind != Data.TEXT || input2.getText().length != 0; if (kind != Data.TEXT && kind != Data.COMM) { ok = XMLToken.isQName(token(input1.getText())); if (!ok && !input1.getText().isEmpty()) msg = Util.info(INVALID, EDITNAME); } info.setText(msg, Msg.ERROR); enableOK(buttons, BUTTONOK, ok); }
/** * Checks the specified template and adds a variable. * * @param tmp template string * @param type allowed type * @param declared variable declaration flags * @return resulting variable * @throws QueryException query exception */ private QNm checkVariable(final String tmp, final Type type, final boolean[] declared) throws QueryException { final Var[] args = function.args; final Matcher m = TEMPLATE.matcher(tmp); if (!m.find()) error(INV_TEMPLATE, tmp); final byte[] vn = token(m.group(1)); if (!XMLToken.isQName(vn)) error(INV_VARNAME, vn); final QNm qnm = new QNm(vn, context); int r = -1; while (++r < args.length && !args[r].name.eq(qnm)) ; if (r == args.length) error(UNKNOWN_VAR, vn); if (declared[r]) error(VAR_ASSIGNED, vn); final SeqType st = args[r].declaredType(); if (args[r].checksType() && !st.type.instanceOf(type)) error(INV_VARTYPE, vn, type); declared[r] = true; return qnm; }