Commit a7dacded authored by Claes Sjofors's avatar Claes Sjofors

Ge conditional Confirm action for ToggleDig added

parent 5f27cea5
......@@ -463,6 +463,8 @@ public class Dyn {
public static final int eSave_Command_command = 5500;
public static final int eSave_CommandDC_command = 5600;
public static final int eSave_Confirm_text = 5700;
public static final int eSave_Confirm_on_set = 5701;
public static final int eSave_Confirm_on_reset = 5702;
public static final int eSave_IncrAnalog_attribute = 5800;
public static final int eSave_IncrAnalog_increment = 5801;
public static final int eSave_IncrAnalog_min_value = 5802;
......@@ -8195,6 +8197,8 @@ public class Dyn {
public class DynConfirm extends DynElem {
String text;
int on_set;
int on_reset;
public DynConfirm( Dyn dyn) {
super(dyn, 0, 0, Dyn.mActionType1_Confirm, 0, Dyn.eDynPrio_Confirm);
......@@ -8218,6 +8222,40 @@ public class Dyn {
break;
case Glow.eEvent_MB1Click:
case Glow.eEvent_ValueChanged:
int skip = 0;
if ( ((on_set != 0 && on_reset == 0) || (on_reset != 0 && on_set == 0)) &&
(dyn.total_action_type1 & Dyn.mActionType1_ToggleDig) != 0) {
for ( int j = 0; j < dyn.elements.size(); j++) {
if ( dyn.elements.get(j).action_type1 == Dyn.mActionType1_ToggleDig) {
DynParsedAttrName pname = dyn.parseAttrName( ((DynToggleDig)dyn.elements.get(j)).attribute);
if ( pname.name.startsWith("&"))
pname.name = dyn.graph.get_reference_name( pname.name);
switch ( pname.database) {
case GraphIfc.eDatabase_Gdh:
CdhrBoolean ret = dyn.graph.getGdh().getObjectInfoBoolean( pname.name);
if (ret.oddSts()) {
if ( (on_set != 0 && ret.value) || (on_reset != 0 && !ret.value))
skip = 1;
}
else
System.out.println("Confirm: " + ret.getSts());
break;
case GraphIfc.eDatabase_Ccm:
// TODO
break;
default: ;
}
break;
}
}
}
if ( skip != 0) {
dyn.confirmedAction( e.event, o);
return 1;
}
dyn.graph.openConfirmDialog( dyn, text, object);
break;
}
......@@ -8242,6 +8280,12 @@ public class Dyn {
if ( token.hasMoreTokens())
text = line.substring(5);
break;
case Dyn.eSave_Confirm_on_set:
on_set = Integer.valueOf(token.nextToken());
break;
case Dyn.eSave_Confirm_on_reset:
on_reset = Integer.valueOf(token.nextToken());
break;
case Dyn.eSave_End:
end_found = true;
break;
......
......@@ -238,9 +238,7 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
MouseAdapter adapter = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("GrowFrame click " + e.getModifiers() + " " + MouseEvent.BUTTON1_MASK);
if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
System.out.println("GrowFrame click MB1" + e.getModifiers() + " " + MouseEvent.BUTTON1_MASK);
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
......@@ -248,7 +246,6 @@ public class GrowFrame extends JFrame implements GraphApplIfc, ActionListener {
graph.ctx.eventHandler( event);
}
else if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
System.out.println("GrowFrame click MB3" + e.getModifiers() + " " + MouseEvent.BUTTON3_MASK);
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
......
......@@ -3733,6 +3733,10 @@ specified text, Ok and Cancel buttons, is displayed before any other action elem
<b>Attribute <t><t>Desciption
Confirm.Text <t><t>Text displayed in the confirm window.
Confirm.OnSet <t><t>Used with action ToggleDig when only set of value to 1 should be confirmed.
<t><t>Set of value to 0 is executed without confirm.
Confirm.OnReset <t><t>Used with action ToggleDig when only set of value to 0 should be confirmed.
<t><t>Set of value to 1 is executed without confirm.
</topic>
<topic>GeDynIncrAnalog <style>function
......
......@@ -3694,6 +3694,10 @@ resp Ja och Nej knappar visas, innan
<b>Attribut <t><t>Beskrivning
Confirm.Text <t><t>Text som visas i verifierings fönstret.
Confirm.OnSet <t><t>Används med action ToggleDig när bekräftelse enbart krävs när värdet sätts till 1.
<t><t>När värdet sätts till 0 sker det utan bekräftelse.
Confirm.OnReset <t><t>Används med action ToggleDig när bekräftelse enbart krävs när värdet sätts till 0.
<t><t>När värdet sätts till 1 sker det utan bekräftelse.
</topic>
<topic>GeDynIncrAnalog <style>function
......
......@@ -12477,6 +12477,16 @@ void GeConfirm::get_attributes( attr_sItem *attrinfo, int *item_count)
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( text);
strcpy( attrinfo[i].name, "OnSet");
attrinfo[i].value = &on_set;
attrinfo[i].type = glow_eType_Boolean;
attrinfo[i++].size = sizeof( on_set);
strcpy( attrinfo[i].name, "OnReset");
attrinfo[i].value = &on_reset;
attrinfo[i].type = glow_eType_Boolean;
attrinfo[i++].size = sizeof( on_reset);
dyn->display_access = true;
*item_count = i;
}
......@@ -12485,6 +12495,8 @@ void GeConfirm::save( ofstream& fp)
{
fp << int(ge_eSave_Confirm) << endl;
fp << int(ge_eSave_Confirm_text) << FSPACE << text << endl;
fp << int(ge_eSave_Confirm_on_set) << FSPACE << on_set << endl;
fp << int(ge_eSave_Confirm_on_reset) << FSPACE << on_reset << endl;
fp << int(ge_eSave_End) << endl;
}
......@@ -12510,6 +12522,8 @@ void GeConfirm::open( ifstream& fp)
fp.get();
fp.getline( text, sizeof(text));
break;
case ge_eSave_Confirm_on_set: fp >> on_set; break;
case ge_eSave_Confirm_on_reset: fp >> on_reset; break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeConfirm:open syntax error" << endl;
......@@ -12533,6 +12547,46 @@ int GeConfirm::action( grow_tObject object, glow_tEvent event)
case glow_eEvent_MB1Click: {
if ( dyn->total_action_type1 & ge_mActionType1_ValueInput)
return 1;
int skip = 0;
if ( ((on_set && !on_reset) || (on_reset && !on_set)) &&
dyn->total_action_type1 & ge_mActionType1_ToggleDig) {
for ( GeDynElem *elem = dyn->elements; elem; elem = elem->next) {
if ( elem->action_type1 == ge_mActionType1_ToggleDig) {
pwr_tAName parsed_name;
int inverted;
int attr_type, attr_size;
graph_eDatabase db;
pwr_tBoolean value;
pwr_tStatus sts;
db = dyn->parse_attr_name( ((GeToggleDig *)elem)->attribute, parsed_name, &inverted, &attr_type, &attr_size);
if ( parsed_name[0] == '&')
dyn->graph->get_reference_name( parsed_name, parsed_name);
switch ( db) {
case graph_eDatabase_Gdh: {
sts = gdh_GetObjectInfo( parsed_name, &value, sizeof(value));
if ( EVEN(sts)) {
printf("Confirm error: %s\n", parsed_name);
break;
}
if ( (on_set && value == 1) || (on_reset && value == 0))
skip = 1;
break;
}
default: ;
}
break;
}
}
}
if ( skip) {
dyn->confirmed_action( object, event);
return 1;
}
if ( dyn->graph->confirm_cb) {
(dyn->graph->confirm_cb)( dyn->graph->parent_ctx,
object, text);
......
......@@ -557,6 +557,8 @@
ge_eSave_Command_command = 5500,
ge_eSave_CommandDC_command = 5600,
ge_eSave_Confirm_text = 5700,
ge_eSave_Confirm_on_set = 5701,
ge_eSave_Confirm_on_reset = 5702,
ge_eSave_IncrAnalog_attribute = 5800,
ge_eSave_IncrAnalog_increment = 5801,
ge_eSave_IncrAnalog_min_value = 5802,
......@@ -2013,12 +2015,16 @@ class GeCommandDoubleClick : public GeDynElem {
class GeConfirm : public GeDynElem {
public:
char text[120];
pwr_tBoolean on_set;
pwr_tBoolean on_reset;
GeConfirm( GeDyn *e_dyn) :
GeDynElem(e_dyn, ge_mDynType1_No, ge_mDynType2_No, ge_mActionType1_Confirm, ge_mActionType2_No, ge_eDynPrio_Confirm)
GeDynElem(e_dyn, ge_mDynType1_No, ge_mDynType2_No, ge_mActionType1_Confirm, ge_mActionType2_No, ge_eDynPrio_Confirm),
on_set(0), on_reset(0)
{ strcpy( text, "");}
GeConfirm( const GeConfirm& x) :
GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio)
GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio),
on_set(x.on_set), on_reset(x.on_reset)
{ strcpy( text, x.text);}
void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment