Commit aba29ae0 authored by claes's avatar claes

More copy/paste and ldh callbacks

parent bb2c820c
......@@ -96,6 +96,16 @@ wblparse <error when parsing wb_load file> /error
nomethod <no such method> /error
volvolatilemax <max number of volatile volumes exceeded> /error
copyplcobject <plcobjects cannot be copied in navigator> /error
pasteself <unable to paste buffer into itself> /error
pasteincon <paste inconsistency> /error
memincon <buffer inconsistency> /error
access <no such access for this configuration> /error
attrconv <attribute conversion error> /error
......
......@@ -37,3 +37,4 @@ nochildren <Object has no children> /error
cmdmode <Session is in command mode> /error
dbopen <Database is already open> /error
co_convert <Error from co_convert> /error
seltomany <Too many objects is selected> /error
......@@ -406,10 +406,19 @@ palette PlcEditorPalette
class Text
class Title
}
menu Trace
menu String
{
class AAnalyse
class DAnalyse
class AtoStr
class CStoSv
class CStoSp
class DtoStr
class GetSp
class GetSv
class ItoStr
class StoSp
class StoSv
class Strcat
class SubStr
}
menu NMps NMps
{
......@@ -459,19 +468,14 @@ palette PlcEditorPalette
class TLogOpen
class TLogModify
}
menu String
menu Simulate
{
class AtoStr
class CStoSv
class CStoSp
class DtoStr
class GetSp
class GetSv
class ItoStr
class StoSp
class StoSv
class Strcat
class SubStr
class CStoAi
class ResDi
class SetDi
class StoAi
class StoDi
class StoPi
}
}
palette PlcEditorConPalette
......
......@@ -3,7 +3,7 @@
#include "wb_vrep.h"
#include "wb_cdef.h"
#include "wb_cdrep.h"
#include "wb_orepdbs.h"
#include "wb_orep.h"
void wb_adrep::unref()
{
......@@ -17,7 +17,7 @@ wb_adrep *wb_adrep::ref()
return this;
}
wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
wb_adrep::wb_adrep( wb_orep& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
m_subClass(pwr_eClass__)
{
m_orep->ref();
......@@ -28,7 +28,7 @@ wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
{
pwr_sParam attr;
m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
if ( EVEN(sts)) throw wb_error(sts);
strcpy( m_pgmname, attr.Info.PgmName);
......@@ -47,7 +47,7 @@ wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
{
pwr_sIntern attr;
m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
if ( EVEN(sts)) throw wb_error(sts);
strcpy( m_pgmname, attr.Info.PgmName);
......@@ -66,7 +66,7 @@ wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
{
pwr_sObjXRef attr;
m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
if ( EVEN(sts)) throw wb_error(sts);
strcpy( m_pgmname, attr.Info.PgmName);
......@@ -84,7 +84,7 @@ wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
{
pwr_sAttrXRef attr;
m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
if ( EVEN(sts)) throw wb_error(sts);
strcpy( m_pgmname, attr.Info.PgmName);
......@@ -102,7 +102,7 @@ wb_adrep::wb_adrep( wb_orepdbs& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
{
pwr_sBuffer attr;
m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
if ( EVEN(sts)) throw wb_error(sts);
strcpy( m_pgmname, attr.Info.PgmName);
......@@ -134,7 +134,7 @@ wb_adrep *wb_adrep::next( pwr_tStatus *sts)
if ( EVEN(*sts))
return 0;
wb_adrep *adrep = new wb_adrep( (wb_orepdbs& ) *orep);
wb_adrep *adrep = new wb_adrep( (wb_orep& ) *orep);
return adrep;
}
......@@ -144,7 +144,7 @@ wb_adrep *wb_adrep::prev( pwr_tStatus *sts)
if ( EVEN(*sts))
return 0;
wb_adrep *adrep = new wb_adrep( (wb_orepdbs& ) *orep);
wb_adrep *adrep = new wb_adrep( (wb_orep& ) *orep);
return adrep;
}
......@@ -210,7 +210,7 @@ pwr_tCid wb_adrep::cid()
wb_vrep *wb_adrep::vrep() const
{
if (EVEN(m_sts)) throw wb_error(m_sts);
return m_orep->m_vrep;
return m_orep->vrep();
}
const char *wb_adrep::name() const
......@@ -250,5 +250,5 @@ void *wb_adrep::body( void *p)
throw wb_error(LDH__NYI);
}
return m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, p);
return m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, p);
}
......@@ -8,7 +8,7 @@
class wb_bdrep;
class wb_cdrep;
class wb_orepdbs;
class wb_orep;
class wb_vrep;
class wb_bdrep;
class wb_name;
......@@ -16,7 +16,7 @@ class wb_name;
class wb_adrep
{
int m_nRef;
wb_orepdbs *m_orep;
wb_orep *m_orep;
pwr_tStatus m_sts;
size_t m_size;
......@@ -33,7 +33,7 @@ class wb_adrep
friend class wb_cdrep;
public:
wb_adrep(wb_orepdbs& );
wb_adrep(wb_orep& );
~wb_adrep();
void unref();
......
......@@ -294,6 +294,12 @@ pwr_sAttrRef *wb_attribute::aref(pwr_sAttrRef *arp) const
return arp;
}
pwr_tOid wb_attribute::aoid() const
{
check();
return m_orep->oid();
}
size_t wb_attribute::size() const
{
check();
......
#include "wb_bdrep.h"
#include "wb_adrep.h"
#include "wb_orepdbs.h"
#include "wb_orep.h"
void wb_bdrep::unref()
{
......@@ -15,7 +15,7 @@ wb_bdrep *wb_bdrep::ref()
return this;
}
wb_bdrep::wb_bdrep(wb_orepdbs& o) : m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS)
wb_bdrep::wb_bdrep(wb_orep& o) : m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS)
{
m_orep->ref();
}
......@@ -23,7 +23,7 @@ wb_bdrep::wb_bdrep(wb_orepdbs& o) : m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS)
wb_bdrep::wb_bdrep( wb_adrep *adrep) : m_nRef(0)
{
pwr_tStatus sts;
m_orep = (wb_orepdbs *) adrep->m_orep->parent( &sts);
m_orep = adrep->m_orep->parent( &sts);
if ( EVEN(sts)) throw wb_error(sts);
m_sts = LDH__SUCCESS;
}
......@@ -35,7 +35,7 @@ wb_bdrep::~wb_bdrep()
wb_adrep *wb_bdrep::adrep( pwr_tStatus *sts)
{
wb_orepdbs *orep = (wb_orepdbs *)m_orep->m_vrep->first( sts, m_orep);
wb_orep *orep = m_orep->vrep()->first( sts, m_orep);
if ( EVEN(*sts)) return 0;
return new wb_adrep(*orep);
......@@ -44,7 +44,7 @@ wb_adrep *wb_bdrep::adrep( pwr_tStatus *sts)
wb_adrep *wb_bdrep::adrep( pwr_tStatus *sts, const char *aname)
{
wb_name n(aname);
wb_orepdbs *orep = (wb_orepdbs *)m_orep->m_vrep->child( sts, m_orep, n);
wb_orep *orep = m_orep->vrep()->child( sts, m_orep, n);
if ( EVEN(*sts))
return 0;
wb_adrep *adrep = new wb_adrep( *orep);
......@@ -61,7 +61,7 @@ size_t wb_bdrep::size()
pwr_tStatus sts;
pwr_sObjBodyDef body;
m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
if ( EVEN(sts)) throw wb_error(sts);
return body.Size;
......@@ -71,9 +71,9 @@ int wb_bdrep::nAttribute()
{
pwr_tStatus sts;
int attr_count = 0;
wb_orepdbs *old;
wb_orep *old;
wb_orepdbs *orep = (wb_orepdbs *)m_orep->m_vrep->first( &sts, m_orep);
wb_orep *orep = m_orep->vrep()->first( &sts, m_orep);
while ( ODD(sts)) {
switch ( orep->cid()) {
case pwr_eClass_Param:
......@@ -89,7 +89,7 @@ int wb_bdrep::nAttribute()
;
}
old = orep;
orep = (wb_orepdbs *)orep->after( &sts);
orep = orep->after( &sts);
old->ref();
old->unref();
}
......
......@@ -6,17 +6,17 @@
#include "wb_name.h"
class wb_adrep;
class wb_orepdbs;
class wb_orep;
class wb_bdrep
{
int m_nRef;
wb_orepdbs *m_orep;
wb_orep *m_orep;
pwr_tStatus m_sts;
public:
wb_bdrep();
wb_bdrep(wb_orepdbs& o); // own orep
wb_bdrep(wb_orep& o); // own orep
wb_bdrep( wb_adrep *adrep);
~wb_bdrep();
......
This diff is collapsed.
......@@ -11,12 +11,12 @@ class wb_bdrep;
class wb_mvrep;
class wb_orep;
class wb_orepdbs;
class wb_merep;
class wb_cdrep
{
int m_nRef;
wb_orepdbs *m_orep;
wb_orep *m_orep;
pwr_tStatus m_sts;
public:
......@@ -55,8 +55,17 @@ public:
wb_orep *menuAfter( pwr_tStatus *sts, wb_orep *orep, void **o);
wb_orep *menuFirst( pwr_tStatus *sts, wb_orep *orep, void **o);
pwr_tTime ohTime();
void convertSubClass( pwr_tCid cid, wb_merep *merep,
void *body_source, void *body_target);
void convertObject( wb_merep *merep, void *rbody, void *dbody,
size_t *cnv_rbody_size, size_t *cnv_dbody_size,
void **cnv_rbody, void **cnv_dbody);
pwr_tStatus sts() { return m_sts;}
};
#endif
......@@ -24,7 +24,7 @@ extern "C" {
pwr_dImport pwr_BindClasses(System);
pwr_dImport pwr_BindClasses(Base);
wb_erep::wb_erep() : m_dir_cnt(0), m_volatile_idx(0)
wb_erep::wb_erep() : m_dir_cnt(0), m_volatile_idx(0), m_buffer_max(10)
{
m_merep = new wb_merep(0);
}
......@@ -82,16 +82,18 @@ wb_vrep *wb_erep::volume(pwr_tStatus *sts, pwr_tVid vid)
return it->second;
}
it = m_vrepbuffer.find(vid);
if ( it != m_vrepbuffer.end()) {
for ( buffer_iterator itb = m_vrepbuffer.begin(); itb != m_vrepbuffer.end(); itb++) {
if ( (*itb)->vid() == vid) {
*sts = LDH__SUCCESS;
return it->second;
return *itb;
}
}
*sts = LDH__NOSUCHVOL;
return 0;
}
wb_vrep *wb_erep::volume(pwr_tStatus *sts, const char *name)
{
vrep_iterator it;
......@@ -130,13 +132,25 @@ wb_vrep *wb_erep::externVolume(pwr_tStatus *sts, pwr_tVid vid)
wb_vrep *wb_erep::bufferVolume(pwr_tStatus *sts)
{
vrep_iterator it = m_vrepbuffer.begin();
buffer_iterator it = m_vrepbuffer.begin();
if ( it == m_vrepbuffer.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
}
*sts = LDH__SUCCESS;
return it->second;
return *it;
}
wb_vrep *wb_erep::bufferVolume(pwr_tStatus *sts, char *name)
{
for ( buffer_iterator it = m_vrepbuffer.begin(); it != m_vrepbuffer.end(); it++) {
if ( cdh_NoCaseStrcmp( name, (*it)->name()) == 0) {
*sts = LDH__SUCCESS;
return *it;
}
}
*sts = LDH__NOSUCHVOL;
return 0;
}
wb_vrep *wb_erep::nextVolume(pwr_tStatus *sts, pwr_tVid vid)
......@@ -178,18 +192,19 @@ wb_vrep *wb_erep::nextVolume(pwr_tStatus *sts, pwr_tVid vid)
}
// Search in buffer
it = m_vrepbuffer.find(vid);
if ( it != m_vrepbuffer.end()) {
it++;
if ( it != m_vrepbuffer.end()) {
for ( buffer_iterator itb = m_vrepbuffer.begin(); itb != m_vrepbuffer.end(); itb++) {
if ( (*itb)->vid() == vid) {
itb++;
if ( itb != m_vrepbuffer.end()) {
*sts = LDH__SUCCESS;
return it->second;
return *itb;
}
else {
*sts = LDH__NOSUCHVOL;
return 0;
}
}
}
*sts = LDH__NOSUCHVOL;
return 0;
......@@ -238,11 +253,25 @@ void wb_erep::addExtern( pwr_tStatus *sts, wb_vrep *vrep)
}
}
wb_vrep *wb_erep::findBuffer( pwr_tVid vid)
{
for ( buffer_iterator itb = m_vrepbuffer.begin(); itb != m_vrepbuffer.end(); itb++) {
if ( (*itb)->vid() == vid)
return *itb;
}
return 0;
}
void wb_erep::addBuffer( pwr_tStatus *sts, wb_vrep *vrep)
{
vrep_iterator it = m_vrepbuffer.find( vrep->vid());
if ( it == m_vrepbuffer.end()) {
m_vrepbuffer[vrep->vid()] = vrep;
wb_vrep *v = findBuffer( vrep->vid());
if ( !v) {
// Remove oldest buffer
if ( (int) m_vrepbuffer.size() >= m_buffer_max) {
m_vrepbuffer.erase( m_vrepbuffer.begin());
}
m_vrepbuffer.push_back( vrep);
vrep->ref();
*sts = LDH__SUCCESS;
}
......@@ -290,14 +319,16 @@ void wb_erep::removeExtern(pwr_tStatus *sts, wb_vrep *vrep)
void wb_erep::removeBuffer(pwr_tStatus *sts, wb_vrep *vrep)
{
vrep_iterator it = m_vrepbuffer.find( vrep->vid());
if ( it == m_vrepbuffer.end()) {
*sts = LDH__NOSUCHVOL;
return;
}
it->second->unref();
for ( buffer_iterator it = m_vrepbuffer.begin(); it != m_vrepbuffer.end(); it++) {
if ( *it == vrep) {
vrep->unref();
m_vrepbuffer.erase( it);
*sts = LDH__SUCCESS;
return;
}
}
*sts = LDH__NOSUCHVOL;
return;
}
void wb_erep::load( pwr_tStatus *sts)
......@@ -667,8 +698,9 @@ int wb_erep::nextVolatileVid( pwr_tStatus *sts, char *name)
{
pwr_tVid vid = ldh_cVolatileVolMin + m_volatile_idx++;
if ( vid > ldh_cVolatileVolMax) {
*sts = LDH__VOLVOLATILEMAX;
return 0;
// Recycle identities, and hope that the old volumes are history
m_volatile_idx = 0;
vid = ldh_cVolatileVolMin + m_volatile_idx++;
}
if ( name)
// Suggest a name
......
......@@ -3,6 +3,7 @@
#include <map>
#include <string>
#include <vector>
#include "wb_pwrs.h"
using namespace std;
......@@ -19,18 +20,20 @@ class wb_erep
{
typedef map<pwr_tVid, wb_vrep*>::iterator vrep_iterator;
typedef map< string, wb_tMethod>::iterator methods_iterator;
typedef vector<wb_vrep*>::iterator buffer_iterator;
unsigned int m_nRef;
wb_merep *m_merep;
map<pwr_tVid, wb_vrep*> m_vrepdb;
map<pwr_tVid, wb_vrep*> m_vrepdbs;
map<pwr_tVid, wb_vrep*> m_vrepextern;
map<pwr_tVid, wb_vrep*> m_vrepbuffer;
vector<wb_vrep*> m_vrepbuffer;
map< string, wb_tMethod> m_methods;
char m_dir_list[10][200];
int m_dir_cnt;
int m_volatile_idx;
int m_buffer_max;
public:
wb_erep();
......@@ -46,6 +49,8 @@ public:
wb_vrep *nextVolume(pwr_tStatus *sts, pwr_tVid vid);
wb_vrep *externVolume(pwr_tStatus *sts, pwr_tVid vid);
wb_vrep *bufferVolume(pwr_tStatus *sts);
wb_vrep *bufferVolume(pwr_tStatus *sts, char *name);
wb_vrep *findBuffer( pwr_tVid vid);
void addDb( pwr_tStatus *sts, wb_vrep *vrep);
void addDbs( pwr_tStatus *sts, wb_vrep *vrep);
void addExtern( pwr_tStatus *sts, wb_vrep *vrep);
......
......@@ -241,6 +241,8 @@ pwr_tStatus
ldh_ChangeObjectName(ldh_tSession session, pwr_tOid oid, char *name)
{
wb_session *sp = (wb_session *)session;
try {
wb_name n(name);
wb_object o = sp->object(oid);
......@@ -248,6 +250,10 @@ ldh_ChangeObjectName(ldh_tSession session, pwr_tOid oid, char *name)
if (!sp->isLocal(o)) return LDH__OTHERVOLUME;
return sp->renameObject(o, n);
}
catch ( wb_error& e) {
return e.sts();
}
}
......@@ -565,8 +571,8 @@ pwr_tStatus
ldh_GetObjectBody(ldh_tSession session, pwr_tOid oid, char *bname, void **buff, int *size)
{
wb_session *sp = (wb_session *)session;
wb_object o = sp->object(oid);
wb_attribute a = sp->attribute(o, bname);
wb_attribute a = sp->attribute( oid, bname);
if ( !a) return a.sts();
*buff = malloc(a.size());
if (*buff == NULL) return LDH__INSVIRMEM;
......@@ -1101,27 +1107,21 @@ ldh_VolumeIdToName(ldh_tWorkbench workbench, pwr_tVid vid, char *name, int maxsi
void
ldh_AddThisSessionCallback(ldh_tSession session, void *editorContext,
pwr_tStatus (*receiveThisSession) (
void *editorContext, ldh_sEvent *event))
ldh_tSessionCb receiveThisSession)
{
#if NOT_YET_IMPLEMENTED
wb_session *sp = (wb_session *)session;
sp->editorContext(editorContext);
sp->sendThisSession(receiveThisSession);
#endif
}
void
ldh_AddOtherSessionCallback(ldh_tSession session, void *editorContext,
pwr_tStatus (*receiveOtherSession)(
void *editorContext, ldh_sEvent *event))
ldh_tSessionCb receiveOtherSession)
{
#if NOT_YET_IMPLEMENTED
wb_session *sp = (wb_session *)session;
sp->editorContext(editorContext);
sp->sendOtherSession(receiveOtherSession);
#endif
}
......@@ -1137,6 +1137,11 @@ ldh_OpenSession(ldh_tSession *session, ldh_tVolume volume,
wb_session *sp = new wb_session(*vp);
sp->access(access);
if ( sp->evenSts()) {
pwr_tStatus sts = sp->sts();
delete sp;
return sts;
}
sp->utility(utility);
*session = (ldh_tSession)sp;
......@@ -1182,8 +1187,8 @@ pwr_tStatus
ldh_ReadObjectBody(ldh_tSession session, pwr_tObjid oid, char *bname, void *value, int size)
{
wb_session *sp = (wb_session *)session;
wb_object o = sp->object(oid);
wb_attribute a = sp->attribute(o, bname);
wb_attribute a = sp->attribute( oid, bname);
if ( !a) return a.sts();
a.value( value);
......@@ -1274,9 +1279,13 @@ ldh_SetObjectName(ldh_tSession session, pwr_tOid oid, char *name)
wb_object o = sp->object(oid);
if (!o) return o.sts();
try {
wb_name n(name);
sp->renameObject(o, n);
}
catch ( wb_error& e) {
return e.sts();
}
return sp->sts();
}
......@@ -1383,76 +1392,17 @@ ldh_CopyObjectTrees(ldh_tSession session, pwr_sAttrRef *arp, pwr_tOid doid, ldh_
left untouched. */
pwr_tStatus
ldh_Copy(ldh_tSession session, pwr_sAttrRef *arp)
ldh_Copy(ldh_tSession session, pwr_sAttrRef *arp, int keepref)
{
wb_session *sp = (wb_session*)session;
pwr_tStatus sts;
//wb_oset s = sp->objectset(arp);
//wb->copySet(s);
wb_env env = sp->env();
char name[32];
// Avoid copying objects in plcprograms
pwr_sAttrRef *ap = arp;
while ( cdh_ObjidIsNotNull( ap->Objid)) {
wb_object o = sp->object( ap->Objid);
if ( !o) return o.sts();
o = o.parent();
while ( o) {
pwr_sAttrRef *ap2 = arp;
while ( cdh_ObjidIsNotNull( ap2->Objid)) {
if ( o.cid() == pwr_cClass_plc)
return LDH__COPYPLCOBJECT;
ap2++;
}
o = o.parent();
}
ap++;
}
pwr_tVid vid = env.nextVolatileVid( name);
if ( !env) return env.sts();
wb_vrepmem *mem = new wb_vrepmem( (wb_erep *)env, vid);
mem->name( name);
((wb_erep *)env)->addBuffer( &sts, mem);
ap = arp;
wb_vrep *vrep = (wb_vrep *) *sp;
while ( cdh_ObjidIsNotNull( ap->Objid)) {
// Check selected object is not child to another selected object
bool found = false;
wb_object o = sp->object( ap->Objid);
if ( !o) return o.sts();
o = o.parent();
while ( o) {
pwr_sAttrRef *ap2 = arp;
while ( cdh_ObjidIsNotNull( ap2->Objid)) {
if ( cdh_ObjidIsEqual( ap2->Objid, o.oid())) {
found = true;
break;
}
ap2++;
}
if ( found)
break;
o = o.parent();
}
if ( found) {
ap++;
continue;
try {
sp->copyOset( arp, (keepref != 0));
}
vrep->exportTree( *mem, ap->Objid);
ap++;
catch (wb_error& e) {
return e.sts();
}
mem->importTree();
return LDH__SUCCESS;
return sp->sts();
}
/* Make a copy of object trees pointed at by AREF and
......@@ -1461,41 +1411,31 @@ ldh_Copy(ldh_tSession session, pwr_sAttrRef *arp)
deleted but can be retrieved by reverting. */
pwr_tStatus
ldh_Cut(ldh_tSession session, pwr_sAttrRef *arp)
ldh_Cut(ldh_tSession session, pwr_sAttrRef *arp, int keepref)
{
#if NOT_YET_IMPLEMENTED
wb_session *sp = (wb_session*)session;
wb_objectset s = sp->objectSet(arp);
wb->copySet(s);
sp->deleteObject(s);
#endif
return LDH__NYI;
try {
sp->cutOset( arp, (keepref != 0));
}
catch (wb_error& e) {
return e.sts();
}
return sp->sts();
}
pwr_tStatus
ldh_Paste(ldh_tSession session, pwr_tOid doid, ldh_eDest dest)
ldh_Paste(ldh_tSession session, pwr_tOid doid, ldh_eDest dest, int keepoid, char *buffer)
{
wb_session *sp = (wb_session*)session;
pwr_tStatus sts;
wb_env env = sp->env();
// Get last buffer
wb_vrepmem *mem = (wb_vrepmem *)((wb_erep *)env)->bufferVolume( &sts);
if ( EVEN(sts)) return sts;
wb_vrepmem *prev;
while ( mem) {
prev = mem;
mem = (wb_vrepmem *)mem->next();
try {
sp->pasteOset( doid, dest, (keepoid != 0), buffer);
}
mem = prev;
wb_vrep *vrep = (wb_vrep *) *sp;
mem->exportPaste( *vrep, doid);
return LDH__SUCCESS;
catch (wb_error& e) {
return e.sts();
}
return sp->sts();
}
pwr_tStatus
......
......@@ -59,6 +59,8 @@ typedef struct ldh_s_RefUsage ldh_sRefUsage;
typedef struct ldh_s_SessInfo ldh_sSessInfo;
typedef struct ldh_s_LCB ldh_sLCB;
typedef pwr_tStatus (*ldh_tSessionCb) (void *, ldh_sEvent *);
typedef union ldh_m_MenuFlags ldh_mMenuFlags;
typedef enum {
......@@ -102,6 +104,7 @@ typedef enum {
ldh_eEvent_MenuMethodCalled,
ldh_eEvent_ObjectTreeCopied,
ldh_eEvent_ObjectTreeDeleted,
ldh_eEvent_
} ldh_eEvent;
......@@ -424,7 +427,8 @@ pwr_tStatus ldh_ConnectObjectByXRef (
pwr_tStatus ldh_Copy (
ldh_tSession Session,
pwr_sAttrRef *aref
pwr_sAttrRef *aref,
int keepref
);
pwr_tStatus ldh_CopyObject (
......@@ -468,7 +472,8 @@ ldh_CreateVolume (
pwr_tStatus ldh_Cut (
ldh_tSession session,
pwr_sAttrRef *aref
pwr_sAttrRef *aref,
int keepref
);
pwr_tStatus
......@@ -774,20 +779,14 @@ void
ldh_AddThisSessionCallback (
ldh_tSession session,
void *editorContext,
pwr_tStatus (*receiveThisSession)(
void *editorContext,
ldh_sEvent *event
)
ldh_tSessionCb receiveThisSession
);
void
ldh_AddOtherSessionCallback (
ldh_tSession session,
void *editorContext,
pwr_tStatus (*receiveOtherSession)(
void *editorContext,
ldh_sEvent *event
)
ldh_tSessionCb receiveOtherSession
);
pwr_tStatus
......@@ -806,7 +805,9 @@ ldh_OpenWB (
pwr_tStatus ldh_Paste (
ldh_tSession Session,
pwr_tObjid dstoid,
ldh_eDest dest
ldh_eDest dest,
int keepoid,
char *buffer
);
pwr_tStatus
......
......@@ -9,6 +9,19 @@
#include "wb_ldh_msg.h"
wb_merep::wb_merep( const wb_merep& x, wb_vrep *vrep) :
m_mvrepdbs(x.m_mvrepdbs), m_erep(x.m_erep), m_vrep(vrep)
{
for ( mvrep_iterator it = m_mvrepdbs.begin(); it != m_mvrepdbs.end(); it++)
it->second->ref();
}
wb_merep::~wb_merep()
{
for ( mvrep_iterator it = m_mvrepdbs.begin(); it != m_mvrepdbs.end(); it++)
it->second->unref();
}
// Get first volume
wb_mvrep *wb_merep::volume( pwr_tStatus *sts)
{
......
......@@ -22,6 +22,8 @@ class wb_merep {
public:
wb_merep( wb_erep *erep, wb_vrep *vrep = 0) : m_erep(erep), m_vrep(vrep) {}
~wb_merep();
wb_merep( const wb_merep& x, wb_vrep *vrep);
wb_mvrep *volume(pwr_tStatus *sts);
wb_mvrep *volume(pwr_tStatus *sts, pwr_tVid vid);
wb_mvrep *volume(pwr_tStatus *sts, const char *name);
......
......@@ -4,6 +4,8 @@
#include "wb_cdrep.h"
#include "wb_merep.h"
#include "wb_ldh.h"
#include "wb_vrepmem.h"
#include "pwr_baseclasses.h"
static ldh_sMenuItem ldh_lMenuItem[100];
......@@ -33,7 +35,7 @@ static struct {
wb_session::wb_session(wb_volume &v) : wb_volume(v)
{
m_srep = new wb_srep(v);
m_srep = new wb_srep( v);
m_srep->ref();
}
......@@ -48,6 +50,17 @@ wb_session::~wb_session()
m_srep->unref();
}
wb_session& wb_session::operator=(const wb_session& x)
{
if ( x.m_srep)
x.m_srep->ref();
if ( m_srep)
m_srep->unref();
m_srep = x.m_srep;
m_sts = x.sts();
return *this;
}
wb_object wb_session::createObject(wb_cdef cdef, wb_destination d, wb_name name)
{
wb_orep *orep = 0;
......@@ -56,7 +69,14 @@ wb_object wb_session::createObject(wb_cdef cdef, wb_destination d, wb_name name)
throw wb_error_str("ReadOnlySession");
orep = m_vrep->createObject(&m_sts, cdef, d, name);
return wb_object(m_sts, orep);
wb_object o = wb_object(m_sts, orep);
ldh_sEvent *ep = m_srep->eventStart( o.oid(), ldh_eEvent_ObjectCreated);
m_srep->eventNewFamily( ep, o);
// sts = triggPostCreate( orep);
// sts = triggPostAdopt( father, orep);
m_srep->eventSend( ep);
return o;
}
wb_object wb_session::copyObject(wb_object o, wb_destination d, wb_name name)
......@@ -67,15 +87,12 @@ wb_object wb_session::copyObject(wb_object o, wb_destination d, wb_name name)
throw wb_error_str("ReadOnlySession");
orep = m_vrep->copyObject(&m_sts, (wb_orep*)o, d, name);
return wb_object(m_sts, orep);
}
bool wb_session::copyOset(wb_oset *o, wb_destination d)
{
if (isReadonly())
throw wb_error_str("ReadOnlySession");
ldh_sEvent *ep = m_srep->eventStart( orep->oid(), ldh_eEvent_ObjectCreated);
m_srep->eventNewFamily( ep, o);
m_srep->eventSend( ep);
return m_vrep->copyOset(&m_sts, o, d);
return wb_object(m_sts, orep);
}
bool wb_session::moveObject(wb_object o, wb_destination d)
......@@ -83,7 +100,15 @@ bool wb_session::moveObject(wb_object o, wb_destination d)
if (isReadonly())
throw wb_error_str("ReadOnlySession");
return m_vrep->moveObject(&m_sts, (wb_orep*)o, d);
ldh_sEvent *ep = m_srep->eventStart( o.oid(), ldh_eEvent_ObjectMoved);
m_srep->eventOldFamily( ep, o);
bool sts = m_vrep->moveObject(&m_sts, (wb_orep*)o, d);
m_srep->eventNewFamily( ep, o);
m_srep->eventSend( ep);
return sts;
}
......@@ -92,7 +117,11 @@ bool wb_session::renameObject(wb_object o, wb_name name)
if (isReadonly())
throw wb_error_str("ReadOnlySession");
return m_vrep->renameObject(&m_sts, (wb_orep*)o, name);
bool sts = m_vrep->renameObject(&m_sts, (wb_orep*)o, name);
ldh_sEvent *ep = m_srep->eventStart( o.oid(), ldh_eEvent_ObjectRenamed);
m_srep->eventSend( ep);
return sts;
}
bool wb_session::deleteObject(wb_object o)
......@@ -128,7 +157,10 @@ bool wb_session::writeAttribute(wb_attribute &a, void *p, size_t size)
if (isReadonly())
throw wb_error_str("ReadOnlySession");
return m_vrep->writeAttribute(&m_sts, (wb_orep*)a, a.bix(), a.offset(), a.size(), p);
bool sts = m_vrep->writeAttribute(&m_sts, (wb_orep*)a, a.bix(), a.offset(), a.size(), p);
ldh_sEvent *ep = m_srep->eventStart( a.aoid(), ldh_eEvent_AttributeModified);
m_srep->eventSend( ep);
return sts;
}
bool wb_session::writeAttribute(wb_attribute &a, void *p)
......@@ -136,7 +168,148 @@ bool wb_session::writeAttribute(wb_attribute &a, void *p)
if (isReadonly())
throw wb_error_str("ReadOnlySession");
return m_vrep->writeAttribute(&m_sts, (wb_orep*)a, a.bix(), a.offset(), a.size(), p);
bool sts = m_vrep->writeAttribute(&m_sts, (wb_orep*)a, a.bix(), a.offset(), a.size(), p);
ldh_sEvent *ep = m_srep->eventStart( a.aoid(), ldh_eEvent_AttributeModified);
m_srep->eventSend( ep);
return sts;
}
bool wb_session::copyOset( pwr_sAttrRef *arp, bool keepref)
{
char name[32];
pwr_tStatus sts;
m_sts = LDH__SUCCESS;
// Avoid copying objects in plcprograms
pwr_sAttrRef *ap = arp;
while ( cdh_ObjidIsNotNull( ap->Objid)) {
wb_object o = object( ap->Objid);
if ( !o) return o.sts();
o = o.parent();
while ( o) {
pwr_sAttrRef *ap2 = arp;
while ( cdh_ObjidIsNotNull( ap2->Objid)) {
if ( o.cid() == pwr_cClass_plc) {
m_sts = LDH__COPYPLCOBJECT;
return false;
}
ap2++;
}
o = o.parent();
}
ap++;
}
pwr_tVid vid = m_vrep->erep()->nextVolatileVid( &m_sts, name);
if ( EVEN(m_sts)) return false;
wb_vrepmem *mem = new wb_vrepmem( m_vrep->erep(), vid);
mem->name( name);
m_vrep->erep()->addBuffer( &sts, mem);
ap = arp;
while ( cdh_ObjidIsNotNull( ap->Objid)) {
// Check selected object is not child to another selected object
bool found = false;
wb_object o = object( ap->Objid);
if ( !o) return o.sts();
o = o.parent();
while ( o) {
pwr_sAttrRef *ap2 = arp;
while ( cdh_ObjidIsNotNull( ap2->Objid)) {
if ( cdh_ObjidIsEqual( ap2->Objid, o.oid())) {
found = true;
break;
}
ap2++;
}
if ( found)
break;
o = o.parent();
}
if ( found) {
ap++;
continue;
}
m_vrep->exportTree( *mem, ap->Objid);
ap++;
}
return mem->importTree( keepref);
}
bool wb_session::cutOset( pwr_sAttrRef *arp, bool keepref)
{
if (isReadonly())
throw wb_error_str("ReadOnlySession");
m_sts = LDH__SUCCESS;
copyOset( arp, keepref);
if ( EVEN(m_sts)) return false;
ldh_sEvent *ep = m_srep->eventStart( pwr_cNOid, ldh_eEvent_ObjectTreeDeleted);
pwr_sAttrRef *ap = arp;
while ( cdh_ObjidIsNotNull( ap->Objid)) {
wb_object o = object( ap->Objid);
if ( !o) {
ap++;
continue;
}
deleteFamily( o);
ldh_sEvent *e = m_srep->eventStart( pwr_cNOid, ldh_eEvent_ObjectDeleted);
m_srep->eventOldFamily( e, o);
ap++;
}
m_srep->eventSend( ep);
return true;
}
bool wb_session::pasteOset( pwr_tOid doid, ldh_eDest dest,
bool keepoid, char *buffer)
{
if (isReadonly())
throw wb_error_str("ReadOnlySession");
m_sts = LDH__SUCCESS;
wb_vrepmem *mem;
// Get last buffer
if ( !buffer) {
mem = (wb_vrepmem *) m_vrep->erep()->bufferVolume( &m_sts);
if ( EVEN(m_sts)) return false;
wb_vrepmem *prev;
while ( mem) {
prev = mem;
mem = (wb_vrepmem *)mem->next();
}
mem = prev;
}
else {
// Get specified buffer
mem = (wb_vrepmem *) m_vrep->erep()->bufferVolume( &m_sts, buffer);
if ( EVEN(m_sts)) return false;
}
if ( mem == m_vrep) {
m_sts = LDH__PASTESELF;
return false;
}
mem->exportPaste( *m_vrep, doid, dest, keepoid);
if ( dest == ldh_eDest_After || dest == ldh_eDest_Before)
doid = pwr_cNOid;
ldh_sEvent *ep = m_srep->eventStart( doid, ldh_eEvent_ObjectTreeCopied);
m_srep->eventSend( ep);
return true;
}
pwr_tStatus wb_session::getMenu( ldh_sMenuCall *ip)
......@@ -180,10 +353,12 @@ pwr_tStatus wb_session::getMenu( ldh_sMenuCall *ip)
void *o_menu_body;
wb_orep *o_menu = cdrep->menuFirst( &sts, o, &o_menu_body);
if ( ODD(sts)) {
while ( ODD(sts)) {
o_menu->ref();
getAllMenuItems( ip, &Item, cdrep, o_menu, o_menu_body, 0, &nItems, 0);
o_menu->unref();
wb_orep *prev = o_menu;
o_menu = cdrep->menuAfter( &sts, o_menu, &o_menu_body);
prev->unref();
}
delete cdrep;
o->unref();
......@@ -214,10 +389,12 @@ pwr_tStatus wb_session::getMenu( ldh_sMenuCall *ip)
Object = o->oid();
o_menu = cdrep->menuFirst( &sts, o, &o_menu_body);
if ( ODD(sts)) {
while ( ODD(sts)) {
o_menu->ref();
getAllMenuItems( ip, &Item, cdrep, o_menu, o_menu_body, 0, &nItems, 0);
o_menu->unref();
wb_orep *prev = o_menu;
o_menu = cdrep->menuAfter( &sts, o_menu, &o_menu_body);
prev->unref();
}
delete cdrep;
o->unref();
......@@ -240,10 +417,12 @@ pwr_tStatus wb_session::getMenu( ldh_sMenuCall *ip)
Object = o->oid();
o_menu = cdrep->menuFirst( &sts, o, &o_menu_body);
if ( ODD(sts)) {
while ( ODD(sts)) {
o_menu->ref();
getAllMenuItems( ip, &Item, cdrep, o_menu, o_menu_body, 0, &nItems, 0);
o_menu->unref();
wb_orep *prev = o_menu;
o_menu = cdrep->menuAfter( &sts, o_menu, &o_menu_body);
prev->unref();
}
delete cdrep;
o->unref();
......@@ -274,10 +453,12 @@ pwr_tStatus wb_session::getMenu( ldh_sMenuCall *ip)
Object = o->oid();
o_menu = cdrep->menuFirst( &sts, o, &o_menu_body);
if ( ODD(sts)) {
while ( ODD(sts)) {
o_menu->ref();
getAllMenuItems( ip, &Item, cdrep, o_menu, o_menu_body, 0, &nItems, 0);
o_menu->unref();
wb_orep *prev = o_menu;
o_menu = cdrep->menuAfter( &sts, o_menu, &o_menu_body);
prev->unref();
}
delete cdrep;
o->unref();
......@@ -355,18 +536,12 @@ void wb_session::getAllMenuItems( ldh_sMenuCall *ip, ldh_sMenuItem **Item, wb_cd
void *child_body;
wb_orep *child = cdrep->menuFirst( &sts, o, &child_body);
if ( ODD(sts)) {
while ( ODD(sts)) {
child->ref();
getAllMenuItems(ip, Item, cdrep, child, child_body, Level, nItems, 0);
child->unref();
}
void *next_body;
wb_orep *next = cdrep->menuAfter( &sts, o, &next_body);
if ( ODD(sts)) {
next->ref();
getAllMenuItems(ip, Item, cdrep, next, next_body, Level, nItems, 0);
next->unref();
wb_orep *prev = child;
child = cdrep->menuAfter( &sts, child, &child_body);
prev->unref();
}
}
}
......@@ -387,3 +562,10 @@ pwr_tStatus wb_session::callMenuMethod( ldh_sMenuCall *mcp, int Index)
return sts;
}
......@@ -8,6 +8,7 @@ Copyright (C) 2002 by Stiftelsen Proview.
#ifndef wb_session_h
#define wb_session_h
#include "pwr.h"
//#include "wb_vrep.h"
#include "wb_object.h"
......@@ -42,6 +43,7 @@ public:
wb_session(wb_volume &v);
wb_session(wb_session &s);
~wb_session();
wb_session& operator=(const wb_session& x);
// Calls redirected to srep.
......@@ -61,7 +63,6 @@ public:
wb_object createObject(wb_cdef cdef, wb_destination d, wb_name name);
wb_object copyObject(wb_object o, wb_destination d, wb_name name);
bool copyOset(wb_oset *oset, wb_destination d);
bool moveObject(wb_object o, wb_destination d);
bool renameObject(wb_object o, wb_name name);
......@@ -72,12 +73,22 @@ public:
bool writeAttribute(wb_attribute &a, void *p);
bool writeBody() {return false;} // Fix
bool copyOset( pwr_sAttrRef *arp, bool keepref);
bool cutOset( pwr_sAttrRef *arp, bool keepref);
bool pasteOset( pwr_tOid doid, ldh_eDest dest,
bool keepoid, char *buffer);
void getAllMenuItems( ldh_sMenuCall *ip, ldh_sMenuItem **Item, wb_cdrep *cdrep,
wb_orep *o, void *o_body, pwr_tUInt32 Level,
int *nItems, int AddSeparator);
pwr_tStatus getMenu( ldh_sMenuCall *ip);
pwr_tStatus callMenuMethod( ldh_sMenuCall *mcp, int Index);
void editorContext( void *ctx) { m_srep->editorContext( ctx);}
void sendThisSession( ldh_tSessionCb thisSessionCb) { m_srep->sendThisSession( thisSessionCb);}
void sendOtherSession( ldh_tSessionCb otherSessionCb) { m_srep->sendOtherSession( otherSessionCb);}
};
......
......@@ -2,12 +2,15 @@
#include "wb_vrep.h"
#include "wb_error.h"
#include "wb_ldh_msg.h"
#include "wb_object.h"
wb_srep::wb_srep(wb_vrep *vrep) : m_access(ldh_eAccess_ReadOnly), m_utility(ldh_eUtility__),
m_editorContext(0), m_sendThisSession(0), m_sendOtherSession(0),
m_nUpdate(0), m_refcount(0)
m_nUpdate(0), m_refcount(0),
m_editorContext(0), m_thisSessionCb(0), m_otherSessionCb(0),
m_events(0)
{
m_vrep = vrep->ref();
m_vrep->addSrep( this);
}
wb_srep::wb_srep(wb_srep *srep) // Fix ????? access utility ...
......@@ -23,8 +26,10 @@ wb_srep::~wb_srep()
m_vrep->abort(&sts);
}
if (m_vrep != 0)
if (m_vrep != 0) {
m_vrep->unref();
m_vrep->removeSrep( this);
}
}
wb_srep::operator wb_vrep*() const
......@@ -53,7 +58,12 @@ ldh_eAccess wb_srep::access(pwr_tStatus *sts) const
bool wb_srep::access(pwr_tStatus *sts, ldh_eAccess access) // Fix
{
if ( ldh_eAccess__ < access && access < ldh_eAccess_) {
if ( !m_vrep->accessSupported( access)) {
*sts = LDH__ACCESS;
return false;
}
m_access = access;
*sts = LDH__SUCCESS;
return true;
......@@ -112,3 +122,163 @@ bool wb_srep::abort(pwr_tStatus *sts) // Fix was inline...
}
ldh_sEvent *wb_srep::newEvent()
{
ldh_sEvent *e = (ldh_sEvent *) calloc( 1, sizeof( ldh_sEvent));
// Add event last in eventlist
if ( m_events) {
ldh_sEvent *ep = m_events;
while ( ep->nep)
ep = ep->nep;
ep->nep = e;
}
else
m_events = e;
return e;
}
void wb_srep::deleteEvents()
{
ldh_sEvent *nep;
ldh_sEvent *ep = m_events;
while ( ep) {
nep = ep->nep;
free( ep);
ep = nep;
}
m_events = 0;
}
void wb_srep::eventNewFamily( ldh_sEvent *ep, wb_object o)
{
if ( !m_thisSessionCb)
return;
if ( !ep)
return;
wb_object parent = o.parent();
if ( parent)
ep->NewParent = parent.oid();
wb_object before = o.before();
if ( before)
ep->NewLsibling = before.oid();
wb_object after = o.after();
if ( after)
ep->NewRsibling = after.oid();
}
void wb_srep::eventOldFamily( ldh_sEvent *ep, wb_object o)
{
if ( !m_thisSessionCb)
return;
if (ep == NULL)
return;
wb_object parent = o.parent();
if ( parent)
ep->OldParent = parent.oid();
wb_object before = o.before();
if ( before)
ep->OldLsibling = before.oid();
wb_object after = o.after();
if ( after)
ep->OldRsibling = after.oid();
}
void wb_srep::eventSend( ldh_sEvent *ep)
{
if (!ep)
return;
if ( ep != m_events)
// Send later
return;
if ( m_thisSessionCb)
(m_thisSessionCb)( m_editorContext, ep);
deleteEvents();
}
pwr_tStatus wb_srep::sendThisSession( void *editorContext, ldh_sEvent *event)
{
if ( m_thisSessionCb)
return (m_thisSessionCb)( editorContext, event);
return LDH__SUCCESS;
}
pwr_tStatus wb_srep::sendOtherSession( void *editorContext, ldh_sEvent *event)
{
if ( m_otherSessionCb)
return (m_otherSessionCb)( editorContext, event);
return LDH__SUCCESS;
}
void wb_srep::eventSendAllSessions( ldh_eEvent event)
{
pwr_tStatus sts;
ldh_sEvent *ep;
ep = newEvent();
ep->Event = event;
wb_srep *srep = m_vrep->srep( &sts);
while ( ODD(sts)) {
if ( srep == this)
srep->sendThisSession( m_editorContext, ep);
else
srep->sendOtherSession( m_editorContext, ep);
srep = m_vrep->nextSrep( &sts, srep);
}
deleteEvents();
}
void wb_srep::eventSendSession( ldh_eEvent event)
{
ldh_sEvent *ep;
ep = newEvent();
ep->Event = event;
if ( m_thisSessionCb)
(m_thisSessionCb)( m_editorContext, ep);
deleteEvents();
}
ldh_sEvent *wb_srep::eventStart( pwr_tOid oid, ldh_eEvent event)
{
ldh_sEvent *ep;
if ( !m_thisSessionCb)
return 0;
ep = newEvent();
ep->Event = event;
ep->Object = oid;
return ep;
}
......@@ -6,7 +6,9 @@
#include "wb_ldh.h"
#include "wb_ldhi.h"
class wb_vrep;
class wb_object;
class wb_srep
{
......@@ -14,17 +16,17 @@ protected:
ldh_eAccess m_access;
ldh_eUtility m_utility;
//ldh_sEvent *fep;
//ldh_sEvent *lep;
void *m_editorContext;
ldhi_tSesEventCB m_sendThisSession;
ldhi_tSesEventCB m_sendOtherSession;
unsigned int m_nUpdate;
unsigned int m_refcount;
wb_vrep *m_vrep;
void *m_editorContext;
ldh_tSessionCb m_thisSessionCb;
ldh_tSessionCb m_otherSessionCb;
ldh_sEvent *m_events;
public:
wb_srep(wb_vrep*);
......@@ -48,9 +50,20 @@ public:
bool commit(pwr_tStatus *sts);
bool abort(pwr_tStatus* sts);
void editorContext( void *ctx) { m_editorContext = ctx;}
void sendThisSession( ldh_tSessionCb thisSessionCb) { m_thisSessionCb = thisSessionCb;}
void sendOtherSession( ldh_tSessionCb otherSessionCb) { m_otherSessionCb = otherSessionCb;}
ldh_sEvent *newEvent();
void deleteEvents();
void eventNewFamily( ldh_sEvent *ep, wb_object o);
void eventOldFamily( ldh_sEvent *ep, wb_object o);
void eventSend( ldh_sEvent *ep);
pwr_tStatus sendThisSession( void *editorContext, ldh_sEvent *event);
pwr_tStatus sendOtherSession( void *editorContext, ldh_sEvent *event);
void eventSendAllSessions( ldh_eEvent event);
void eventSendSession( ldh_eEvent event);
ldh_sEvent *eventStart( pwr_tOid Object, ldh_eEvent event);
};
#endif
......
......@@ -18,8 +18,9 @@ bool wb_treeimport::importTranslationTableInsert( pwr_tOix from, pwr_tOix to)
void wb_treeimport::importTranslationTableClear()
{
while( ! m_translation_table.empty())
m_translation_table.erase( m_translation_table.begin());
// while( ! m_translation_table.empty())
// m_translation_table.erase( m_translation_table.begin());
m_translation_table.clear();
}
pwr_tOix wb_treeimport::importTranslate( pwr_tOix oix)
......@@ -57,8 +58,9 @@ bool wb_treeimport::importUpdateSubClass( wb_adrep *subattr, char *body, wb_vrep
pwr_tOix oix;
pwr_tCid cid = subattr->subClass();
wb_cdrep *cdrep = vrep->merep()->cdrep( &sts, cid);
if ( EVEN(sts)) throw wb_error(sts);
wb_bdrep *bdrep = cdrep->bdrep( &sts, pwr_eBix_rt);
if ( EVEN(sts)) return false;
if ( EVEN(sts)) throw wb_error(sts);
int subattr_elements = subattr->isArray() ? subattr->nElement() : 1;
......@@ -118,6 +120,7 @@ bool wb_treeimport::importUpdateObject( wb_orep *o, wb_vrep *vrep)
pwr_tOix oix;
pwr_tStatus sts;
wb_cdrep *cdrep = vrep->merep()->cdrep( &sts, o->cid());
if ( EVEN(sts)) throw wb_error(sts);
pwr_mClassDef flags = cdrep->flags();
for ( int i = 0; i < 2; i++) {
......@@ -129,6 +132,8 @@ bool wb_treeimport::importUpdateObject( wb_orep *o, wb_vrep *vrep)
char *body = (char *)malloc( bdrep->size());
vrep->readBody( &sts, o, bix, body);
if ( EVEN(sts)) throw wb_error(sts);
bool modified = false;
wb_adrep *adrep = bdrep->adrep( &sts);
......@@ -171,8 +176,10 @@ bool wb_treeimport::importUpdateObject( wb_orep *o, wb_vrep *vrep)
adrep = adrep->next( &sts);
delete prev;
}
if ( modified)
if ( modified) {
vrep->writeBody( &sts, o, bix, body);
if ( EVEN(sts)) throw wb_error(sts);
}
free( body);
delete bdrep;
}
......
......@@ -3,12 +3,15 @@
#include <map>
#include "pwr.h"
#include "wb_ldh.h"
class wb_treeexport;
class wb_adrep;
class wb_vrep;
class wb_orep;
class wb_merep;
class wb_treeimport
{
map<pwr_tOix, pwr_tOix> m_translation_table;
......@@ -23,12 +26,13 @@ class wb_treeimport
public:
virtual ~wb_treeimport() {}
virtual bool importTree() = 0;
virtual bool importTreeObject(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
virtual bool importTree( bool keepref) = 0;
virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody) = 0;
virtual bool importPaste() = 0;
virtual bool importPasteObject(pwr_tOid destination, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode, bool keepoid,
pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody) = 0;
bool importTranslationTableInsert( pwr_tOix from, pwr_tOix to);
......@@ -42,3 +46,6 @@ public:
......@@ -91,7 +91,6 @@ public:
pwr_tStatus triggPostCreate( wb_orep *orep);
pwr_tStatus triggPostMove( wb_orep *orep);
pwr_tStatus triggPostUnadopt( wb_orep *father, wb_orep *orep);
};
#endif
......
#include "wb_vrep.h"
void wb_vrep::addSrep( wb_srep *srep)
{
m_srep.push_back( srep);
}
void wb_vrep::removeSrep( wb_srep *srep)
{
for ( srep_iterator it = m_srep.begin(); it != m_srep.end(); it++) {
if ( *it == srep) {
m_srep.erase( it);
return;
}
}
}
//
// Get first srep
//
wb_srep *wb_vrep::srep( pwr_tStatus *sts)
{
srep_iterator it = m_srep.begin();
if ( it == m_srep.end()) {
*sts = LDH__NOSUCHSESS;
return 0;
}
*sts = LDH__SUCCESS;
return *it;
}
wb_srep *wb_vrep::nextSrep( pwr_tStatus *sts, wb_srep* srep)
{
for ( srep_iterator it = m_srep.begin(); it != m_srep.end(); it++) {
if ( *it == srep) {
if ( ++it == m_srep.end()) {
*sts = LDH__NOSUCHSESS;
return 0;
}
*sts = LDH__SUCCESS;
return *it;
}
}
*sts = LDH__NOSUCHSESS;
return 0;
}
......@@ -13,6 +13,7 @@
#include "wb_treeexport.h"
#include "wb_treeimport.h"
#include <map>
#include <vector>
class wb_erep;
class wb_merep;
......@@ -24,9 +25,13 @@ class wb_dbs;
class wb_vrep : public wb_export, public wb_treeexport, public wb_treeimport
{
protected:
typedef vector<wb_srep*>::iterator srep_iterator;
char m_name[80];
pwr_tVid m_vid;
pwr_tCid m_cid;
vector<wb_srep*> m_srep;
public:
virtual ~wb_vrep() {};
......@@ -124,6 +129,12 @@ public:
virtual void objectName(const wb_orep *o, char *str) = 0;
virtual bool isCommonMeta() const { return false;}
virtual bool isMeta() const { return false;}
virtual bool accessSupported( ldh_eAccess access) = 0;
void addSrep( wb_srep *srep);
void removeSrep( wb_srep *srep);
wb_srep *srep( pwr_tStatus *sts);
wb_srep *nextSrep( pwr_tStatus *sts, wb_srep* srep);
};
#endif
......@@ -21,7 +21,7 @@ wb_vrep *wb_vrepdb::ref()
wb_vrepdb::wb_vrepdb(wb_erep *erep, const char *fileName) :
m_erep(erep), m_ohead()
m_erep(erep), m_nRef(0), m_ohead()
{
strcpy(m_fileName, fileName);
......
......@@ -9,13 +9,9 @@
class wb_vrepdb : public wb_vrep
{
protected:
map<int, wb_srep*> m_srep;
//wb_session m_wsession;
wb_erep *m_erep;
wb_merep *m_merep;
unsigned int m_nSession;
unsigned int m_nRef;
char m_fileName[512];
......@@ -125,13 +121,14 @@ public:
virtual bool exportMeta(wb_import &e);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid) { return false;}
virtual bool importTree() { return false;}
virtual bool importTreeObject(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
virtual bool importTree(bool keepref) { return false;}
virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
virtual bool importPaste() { return false;}
virtual bool importPasteObject(pwr_tOid destination, pwr_tOid oid,
virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode,
bool keepoid, pwr_tOid oid,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
......@@ -145,6 +142,7 @@ public:
wb_orepdb *new_wb_orepdb(size_t size);
void delete_wb_orepdb(void *p);
virtual bool accessSupported( ldh_eAccess access) { return true;}
};
......
......@@ -17,7 +17,7 @@ wb_vrep *wb_vrepdbs::ref()
return this;
}
wb_vrepdbs::wb_vrepdbs(wb_erep *erep, const char *fileName) : m_erep(erep)
wb_vrepdbs::wb_vrepdbs(wb_erep *erep, const char *fileName) : m_erep(erep), m_nRef(0)
{
strcpy(m_fileName, fileName);
m_isDbsenvLoaded = false;
......@@ -489,7 +489,7 @@ bool wb_vrepdbs::exportTree(wb_treeimport &i, pwr_tOid oid)
dbs_sObject *op = dbs_OidToObject( &sts, dbsenv(), oid);
if (op == 0)
return false;
throw wb_error(LDH__NOSUCHOBJ);
exportTreeObject( i, op, true);
return true;
......@@ -516,7 +516,7 @@ bool wb_vrepdbs::exportTreeObject(wb_treeimport &i, dbs_sObject *op, bool isRoot
if ( op->dbody.size)
dbody = dbs_Body(&sts, dbsenv(), op, pwr_eBix_dev);
i.importTreeObject( op->oid, op->cid, parentoid, beforeoid, op->name,
i.importTreeObject( m_merep, op->oid, op->cid, parentoid, beforeoid, op->name,
op->rbody.size, op->dbody.size, rbody, dbody);
if ( first)
......
......@@ -6,16 +6,13 @@
#include "wb_cdef.h"
class wb_merep;
class wb_orepdbs;
class wb_vrepdbs : public wb_vrep
{
public:
map<int, wb_srep*> m_srep;
//wb_session m_wsession;
wb_erep *m_erep;
wb_merep *m_merep;
unsigned int m_nSession;
unsigned int m_nRef;
char m_fileName[200];
......@@ -134,17 +131,19 @@ public:
virtual bool exportMeta(wb_import &e);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid);
bool wb_vrepdbs::exportTreeObject(wb_treeimport &i, dbs_sObject *op, bool isRoot);
virtual bool importTree() { return false;}
virtual bool importTreeObject(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
virtual bool importTree(bool keepref) { return false;}
virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
virtual bool importPaste() { return false;}
virtual bool importPasteObject(pwr_tOid destination, pwr_tOid oid,
virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode,
bool keepoid, pwr_tOid oid,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
virtual bool accessSupported( ldh_eAccess access) { return access == ldh_eAccess_ReadOnly; }
};
......
This diff is collapsed.
......@@ -45,7 +45,7 @@ class mem_object
pwr_tOid fthoid = (fth && !isRoot) ? fth->m_oid : pwr_cNOid;
pwr_tOid bwsoid = (bws && !isRoot) ? bws->m_oid : pwr_cNOid;
i.importTreeObject( m_oid, m_cid, fthoid, bwsoid, name(),
i.importTreeObject( 0, m_oid, m_cid, fthoid, bwsoid, name(),
rbody_size, dbody_size, rbody, dbody);
if ( fch)
......@@ -56,35 +56,25 @@ class mem_object
return true;
}
bool exportPaste( wb_treeimport &i, pwr_tOid destination, bool isRoot) {
bool exportPaste( wb_treeimport &i, pwr_tOid destination, bool isRoot, ldh_eDest destcode,
bool keepoid) {
pwr_tOid fthoid = (fth && !isRoot) ? fth->m_oid : pwr_cNOid;
pwr_tOid bwsoid = (bws && !isRoot) ? bws->m_oid : pwr_cNOid;
i.importPasteObject( destination, m_oid, m_cid, fthoid, bwsoid, name(),
rbody_size, dbody_size, rbody, dbody);
i.importPasteObject( destination, destcode, keepoid, m_oid, m_cid, fthoid, bwsoid,
name(), rbody_size, dbody_size, rbody, dbody);
if ( fch)
fch->exportPaste( i, destination, false);
fch->exportPaste( i, destination, false, destcode, keepoid);
if ( fws)
fws->exportPaste( i, destination, false);
fws->exportPaste( i, destination, false, destcode, keepoid);
return true;
}
mem_object *find( wb_name *oname, int level);
void deleteChildren() {
mem_object *o;
mem_object *ch = fch;
while ( ch) {
o = ch;
ch = ch->fws;
o->deleteChildren();
delete o;
}
}
size_t rbody_size;
size_t dbody_size;
void *rbody;
......@@ -106,13 +96,8 @@ class wb_orepmem;
class wb_vrepmem : public wb_vrep
{
map<int, wb_srep*> m_srep;
//wb_session m_wsession;
wb_erep *m_erep;
wb_merep *m_merep;
unsigned int m_nSession;
unsigned int m_nRef;
mem_object *root_object;
int m_nextOix;
......@@ -124,7 +109,7 @@ class wb_vrepmem : public wb_vrep
public:
wb_vrepmem( wb_erep *erep) :
m_erep(erep), m_merep(erep->merep()), root_object(0), m_nextOix(0) {}
m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0), m_nextOix(0) {}
wb_vrepmem( wb_erep *erep, pwr_tVid vid);
~wb_vrepmem();
......@@ -150,6 +135,7 @@ public:
mem_object *find( const char *name);
int nameToOid( const char *name, pwr_tOid *oid);
bool registerObject( pwr_tOix oix, mem_object *node);
bool unregisterObject( pwr_tOix oix);
void registerVolume( const char *name, pwr_tCid cid, pwr_tVid vid, mem_object *node);
void info();
......@@ -186,16 +172,16 @@ public:
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name);
wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name) {return 0;}
wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name);
bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d) {return false;}
bool moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d) {return false;}
bool moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d);
bool deleteObject(pwr_tStatus *sts, wb_orep *orep);
bool deleteFamily(pwr_tStatus *sts, wb_orep *orep);
bool deleteOset(pwr_tStatus *sts, wb_oset *oset) {return false;}
bool renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name) { return false;}
bool renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name);
bool commit(pwr_tStatus *sts) {return true;}
......@@ -240,21 +226,34 @@ public:
virtual bool exportDbody(wb_import &i);
virtual bool exportMeta(wb_import &i);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid);
bool exportPaste(wb_treeimport &i, pwr_tOid destination);
virtual bool importTreeObject(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
bool exportPaste(wb_treeimport &i, pwr_tOid destination, ldh_eDest destcode, bool keepoid);
virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody);
virtual bool importTree();
virtual bool importPasteObject(pwr_tOid destination, pwr_tOid oid,
virtual bool importTree( bool keepref);
virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode,
bool keepoid, pwr_tOid oid,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody);
virtual bool importPaste();
bool updateObject( wb_orep *o);
bool updateSubClass( wb_adrep *subattr, char *body);
bool updateObject( wb_orep *o, bool keepref);
bool updateSubClass( wb_adrep *subattr, char *body, bool keepref);
virtual bool accessSupported( ldh_eAccess access) { return true;}
private:
bool nameCheck( mem_object *memo);
void deleteChildren( mem_object *memo);
};
#endif
......@@ -30,6 +30,9 @@ wb_vrepwbl::~wb_vrepwbl()
delete file[i]->lexer;
delete file[i];
}
if ( m_merep != m_erep->merep())
delete m_merep;
}
wb_orep *wb_vrepwbl::object(pwr_tStatus *sts, pwr_tOid oid)
......@@ -184,7 +187,7 @@ bool wb_vrepwbl::exportTree(wb_treeimport &i, pwr_tOid oid)
{
ref_wblnode n = findObject( oid.oix);
if ( !n)
return false;
throw wb_error(LDH__NOSUCHOBJ);
n->exportTree( i, true);
return true;
......@@ -250,6 +253,16 @@ int wb_vrepwbl::load( const char *fname)
cout << "** Errors when loading volume: " << error_cnt << " errors found" << endl;
else
cout << "-- Volume " << volume_name << " loaded" << endl;
// If classvolume, insert itself into its merep
if ( cid() == pwr_eClass_ClassVolume ) {
m_merep = new wb_merep( *m_erep->merep(), this);
wb_mvrep *mvrep = m_merep->volume( &sts, vid());
if ( ODD(sts))
m_merep->removeDbs( &sts, mvrep);
m_merep->addDbs( &sts, (wb_mvrep *)this);
m_nRef--;
}
return rsts;
}
......@@ -1288,6 +1301,18 @@ wb_orep *wb_vrepwbl::first(pwr_tStatus *sts, const wb_orep *o)
wb_orep *wb_vrepwbl::child(pwr_tStatus *sts, const wb_orep *o, wb_name &name)
{
wb_orep *child = first( sts, o);
while( ODD(*sts)) {
if ( name.segmentIsEqual( child->name())) {
*sts = LDH__SUCCESS;
return child;
}
child->ref();
wb_orep *prev = child;
child = after( sts, child);
prev->unref();
}
*sts = LDH__NOSUCHOBJ;
return 0;
}
......
......@@ -18,13 +18,8 @@ class wb_orepwbl;
class wb_vrepwbl : public wb_vrep
{
map<int, wb_srep*> m_srep;
//wb_session m_wsession;
wb_erep *m_erep;
wb_merep *m_merep;
unsigned int m_nSession;
unsigned int m_nRef;
map<string, ref_wblnode> m_type_list;
......@@ -41,10 +36,10 @@ class wb_vrepwbl : public wb_vrep
public:
wb_vrepwbl( wb_erep *erep) :
m_erep(erep), m_merep(erep->merep()), root_object(0), error_cnt(0), file_cnt(0), next_oix(0), volume_node(0) {}
m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0), error_cnt(0), file_cnt(0), next_oix(0), volume_node(0) {}
wb_vrepwbl( wb_erep *erep, pwr_tVid vid) :
wb_vrep(vid), m_erep(erep), m_merep(erep->merep()), root_object(0),error_cnt(0), file_cnt(0), next_oix(0), volume_node(0) {}
wb_vrep(vid), m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0),error_cnt(0), file_cnt(0), next_oix(0), volume_node(0) {}
~wb_vrepwbl();
pwr_tVid vid() const { return m_vid;}
......@@ -189,17 +184,19 @@ public:
virtual bool exportDbody(wb_import &i);
virtual bool exportMeta(wb_import &i);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid);
virtual bool importTree() { return false;}
virtual bool importTreeObject(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
virtual bool importTree(bool keepref) { return false;}
virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
virtual bool importPaste() { return false;}
virtual bool importPasteObject(pwr_tOid destination, pwr_tOid oid,
virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode,
bool keepoid, pwr_tOid oid,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
virtual bool accessSupported( ldh_eAccess access) { return access == ldh_eAccess_ReadOnly;}
};
#endif
......@@ -1548,7 +1548,7 @@ bool wb_wblnode::exportTree( wb_treeimport &i, bool isRoot)
pwr_tOid fthoid = (o->fth && !isRoot) ? o->fth->o->m_oid : pwr_cNOid;
pwr_tOid bwsoid = (o->bws && !isRoot) ? o->bws->o->m_oid : pwr_cNOid;
i.importTreeObject( o->m_oid, o->m_cid, fthoid, bwsoid, name(),
i.importTreeObject( m_vrep->merep(), o->m_oid, o->m_cid, fthoid, bwsoid, name(),
o->rbody_size, o->dbody_size, o->rbody, o->dbody);
if ( o->fch)
......
......@@ -1124,15 +1124,17 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
switch ( event->event)
{
case flow_eEvent_Key_Up:
case flow_eEvent_Key_ShiftUp:
{
brow_tNode *node_list;
int node_count;
brow_tObject object;
brow_tObject object, current;
int sts;
brow_GetSelectedNodes( wnav->brow->ctx, &node_list, &node_count);
if ( !node_count)
{
current = 0;
if ( wnav->last_selected && wnav->object_exist( wnav->last_selected))
object = wnav->last_selected;
else
......@@ -1143,9 +1145,22 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
}
else
{
sts = brow_GetPrevious( wnav->brow->ctx, node_list[0], &object);
if ( EVEN(sts))
{
if ( node_count == 1)
current = node_list[0];
else {
bool found = false;
for ( int i = 0; i < node_count; i++) {
if ( node_list[i] == wnav->last_selected)
found = true;
}
if ( found)
current = wnav->last_selected;
else
current = node_list[0];
}
sts = brow_GetPrevious( wnav->brow->ctx, current, &object);
if ( EVEN(sts)) {
current = 0;
sts = brow_GetLast( wnav->brow->ctx, &object);
if ( EVEN(sts))
{
......@@ -1155,9 +1170,30 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
}
}
}
if ( event->event == flow_eEvent_Key_ShiftUp) {
bool found = false;
for ( int i = 0; i < node_count; i++) {
if ( node_list[i] == object)
found = true;
}
if ( found) {
// Previous object is already selected, unselect current
if ( current) {
brow_SetInverse( current, 0);
brow_SelectRemove( wnav->brow->ctx, current);
}
}
else {
brow_SetInverse( object, 1);
brow_SelectInsert( wnav->brow->ctx, object);
}
}
else {
brow_SelectClear( wnav->brow->ctx);
brow_SetInverse( object, 1);
brow_SelectInsert( wnav->brow->ctx, object);
}
if ( !brow_IsVisible( wnav->brow->ctx, object))
brow_CenterObject( wnav->brow->ctx, object, 0.25);
if ( node_count)
......@@ -1166,15 +1202,17 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
break;
}
case flow_eEvent_Key_Down:
case flow_eEvent_Key_ShiftDown:
{
brow_tNode *node_list;
int node_count;
brow_tObject object;
brow_tObject object, current;
int sts;
brow_GetSelectedNodes( wnav->brow->ctx, &node_list, &node_count);
if ( !node_count)
{
current = 0;
if ( wnav->last_selected && wnav->object_exist( wnav->last_selected))
object = wnav->last_selected;
else
......@@ -1185,9 +1223,22 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
}
else
{
sts = brow_GetNext( wnav->brow->ctx, node_list[0], &object);
if ( EVEN(sts))
{
if ( node_count == 1)
current = node_list[0];
else {
bool found = false;
for ( int i = 0; i < node_count; i++) {
if ( node_list[i] == wnav->last_selected)
found = true;
}
if ( found)
current = wnav->last_selected;
else
current = node_list[0];
}
sts = brow_GetNext( wnav->brow->ctx, current, &object);
if ( EVEN(sts)) {
current = 0;
sts = brow_GetFirst( wnav->brow->ctx, &object);
if ( EVEN(sts))
{
......@@ -1197,9 +1248,29 @@ static int wnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
}
}
}
if ( event->event == flow_eEvent_Key_ShiftDown) {
bool found = false;
for ( int i = 0; i < node_count; i++) {
if ( node_list[i] == object)
found = true;
}
if ( found) {
// Previous object is already selected, unselect current
if ( current) {
brow_SetInverse( current, 0);
brow_SelectRemove( wnav->brow->ctx, current);
}
}
else {
brow_SetInverse( object, 1);
brow_SelectInsert( wnav->brow->ctx, object);
}
}
else {
brow_SelectClear( wnav->brow->ctx);
brow_SetInverse( object, 1);
brow_SelectInsert( wnav->brow->ctx, object);
}
if ( !brow_IsVisible( wnav->brow->ctx, object))
brow_CenterObject( wnav->brow->ctx, object, 0.75);
if ( node_count)
......@@ -2862,6 +2933,11 @@ void WNav::ldh_event( ldh_sEvent *event)
ldh_refresh( pwr_cNObjid);
break;
case ldh_eEvent_ObjectTreeCopied:
if ( find( event->Object, (void **) &item))
ldh_refresh( event->Object);
break;
case ldh_eEvent_SessionReverted:
ldh_refresh( pwr_cNObjid);
break;
......@@ -2923,6 +2999,10 @@ void WNav::enable_events( WNavBrow *brow)
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_Key_Down, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_Key_ShiftUp, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_Key_ShiftDown, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_Key_PF1, flow_eEventType_CallBack,
wnav_brow_cb);
brow_EnableEvent( brow->ctx, flow_eEvent_Key_PF2, flow_eEventType_CallBack,
......
......@@ -110,6 +110,10 @@ static int wnav_sort_func( void *client_data,
void *client_flag);
static int wnav_copy_func( void *client_data,
void *client_flag);
static int wnav_cut_func( void *client_data,
void *client_flag);
static int wnav_paste_func( void *client_data,
void *client_flag);
static int wnav_move_func( void *client_data,
void *client_flag);
static int wnav_open_func( void *client_data,
......@@ -206,7 +210,17 @@ dcli_tCmdTable wnav_command_table[] = {
&wnav_copy_func,
{ "dcli_arg1", "/FIRST", "/LAST", "/AFTER", "/BEFORE",
"/HIERARCHY", "/SOURCE", "/DESTINATION", "/NAME",
"/NODE", "/BUSNUMBER", "/NOCONFIRM", "/VERBOSE", ""}
"/NODE", "/BUSNUMBER", "/NOCONFIRM", "/VERBOSE", "/KEEPREFERENCES", ""}
},
{
"CUT",
&wnav_cut_func,
{ "/KEEPREFERENCES", ""}
},
{
"PASTE",
&wnav_paste_func,
{ "dcli_arg1", "/INTO", "/BUFFER", "/KEEPOID", ""}
},
{
"MOVE",
......@@ -2890,8 +2904,35 @@ static int wnav_copy_func( void *client_data,
int arg1_sts;
arg1_sts = dcli_get_qualifier( "dcli_arg1", arg1_str);
if ( EVEN(arg1_sts)) {
pwr_sAttrRef *sel_list;
int *sel_is_attr;
int sel_cnt;
int keepref;
pwr_tStatus sts;
if ( strncmp( arg1_str, "OBJECT", strlen( arg1_str)) == 0)
if ( wnav->window_type == wnav_eWindowType_No)
return WNAV__CMDMODE;
sts = wnav->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts)) {
wnav->message('E', "Nothing is selected in the current window");
return sts;
}
keepref = ODD( dcli_get_qualifier( "/KEEPREFERENCES", NULL));
sts = ldh_Copy( wnav->ldhses, sel_list, keepref);
if ( sel_cnt > 0) {
free( sel_list);
free( sel_is_attr);
}
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
}
else if ( strncmp( arg1_str, "OBJECT", strlen( arg1_str)) == 0)
{
char sourcestr[80];
char destinationstr[80];
......@@ -3094,6 +3135,92 @@ static int wnav_copy_func( void *client_data,
return WNAV__SUCCESS;
}
static int wnav_cut_func( void *client_data,
void *client_flag)
{
WNav *wnav = (WNav *)client_data;
pwr_sAttrRef *sel_list;
int *sel_is_attr;
int sel_cnt;
int keepref;
pwr_tStatus sts;
if ( wnav->window_type == wnav_eWindowType_No)
return WNAV__CMDMODE;
sts = wnav->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts)) {
wnav->message('E', "Nothing is selected in the current window");
return sts;
}
keepref = ODD( dcli_get_qualifier( "/KEEPREFERENCES", NULL));
sts = ldh_Cut( wnav->ldhses, sel_list, keepref);
if ( sel_cnt > 0) {
free( sel_list);
free( sel_is_attr);
}
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
return WNAV__SUCCESS;
}
static int wnav_paste_func( void *client_data,
void *client_flag)
{
WNav *wnav = (WNav *)client_data;
char buffer_str[80];
char *buffer_ptr;
pwr_sAttrRef *sel_list;
int *sel_is_attr;
int sel_cnt;
pwr_tStatus sts;
ldh_eDest dest;
if ( ODD( dcli_get_qualifier( "/BUFFER", buffer_str)))
buffer_ptr = buffer_str;
else if ( ODD( dcli_get_qualifier( "dcli_arg1", buffer_str)))
buffer_ptr = buffer_str;
else
buffer_ptr = 0;
if ( wnav->window_type == wnav_eWindowType_No)
return WNAV__CMDMODE;
sts = wnav->get_select( &sel_list, &sel_is_attr, &sel_cnt);
if ( EVEN(sts)) {
wnav->message('E', "Nothing is selected in the current window");
return sts;
}
else if ( sel_cnt > 1) {
wnav->message('E', "More than one object is selected in the current window");
return WNAV__SELTOMANY;
}
int keepoid = ODD( dcli_get_qualifier( "/KEEPOID", NULL));
if ( ODD( dcli_get_qualifier( "/INTO", NULL)))
dest = ldh_eDest_IntoFirst;
else
dest = ldh_eDest_After;
sts = ldh_Paste( wnav->ldhses, sel_list->Objid, dest, keepoid, buffer_ptr);
if ( sel_cnt > 0) {
free( sel_list);
free( sel_is_attr);
}
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
}
return WNAV__SUCCESS;
}
static int wnav_move_func( void *client_data,
void *client_flag)
{
......@@ -3179,6 +3306,9 @@ static int wnav_open_func( void *client_data,
if ( strncmp( arg1_str, "BUFFERS", strlen( arg1_str)) == 0)
{
if ( wnav->window_type == wnav_eWindowType_No)
return WNAV__CMDMODE;
if ( wnav->open_vsel_cb)
(wnav->open_vsel_cb)( wnav->parent_ctx, wb_eType_Buffer, NULL, wow_eFileSelType_All);
}
......@@ -3505,7 +3635,7 @@ static int wnav_new_func( void *client_data,
arg1_sts = dcli_get_qualifier( "dcli_arg1", arg1_str);
if ( strncmp( arg1_str, "VOLUME", strlen( arg1_str)) == 0)
if ( strncmp( arg1_str, "BUFFER", strlen( arg1_str)) == 0)
{
char name_str[80];
char *name_ptr = 0;
......@@ -3513,7 +3643,7 @@ static int wnav_new_func( void *client_data,
sts = wnav_wccm_get_wbctx_cb( wnav, &wnav->wbctx);
if ( EVEN(sts)) return sts;
// Command is "NEW VOLUME"
// Command is "NEW BUFFER"
if ( ODD( dcli_get_qualifier( "dcli_arg2", name_str)))
{
if ( name_str[0] == '/')
......@@ -3536,7 +3666,7 @@ static int wnav_new_func( void *client_data,
}
wb_vrepmem *mem = new wb_vrepmem(erep, vid);
mem->name( name_str);
erep->addDbs( &sts, mem);
erep->addBuffer( &sts, mem);
return sts;
}
......
This diff is collapsed.
......@@ -194,6 +194,7 @@ class Wtt {
Widget menu_cut_w;
Widget menu_copy_w;
Widget menu_paste_w;
Widget menu_pasteinto_w;
Widget menu_rename_w;
Widget menu_utilities_w;
Widget menu_openplc_w;
......@@ -202,6 +203,7 @@ class Wtt {
Widget menu_createboot_w;
Widget menu_distribute_w;
Widget menu_change_value_w;
Widget menu_edit_w;
uted_ctx utedctx;
void *distrwctx;
WNav *input_wnav;
......
......@@ -29,12 +29,14 @@ procedure
wtt_activate_cut(integer);
wtt_activate_copy(integer);
wtt_activate_paste(integer);
wtt_activate_pasteinto(integer);
wtt_activate_rename(integer);
wtt_activate_configure(integer);
wtt_activate_utilities(integer);
wtt_activate_openobject(integer);
wtt_activate_openvolobject(integer);
wtt_activate_openvolume(integer);
wtt_activate_openbuffer(integer);
wtt_activate_openfile_dbs(integer);
wtt_activate_openfile_wbl(integer);
wtt_activate_spreadsheet(integer);
......@@ -208,6 +210,19 @@ object file_entry : XmCascadeButton
};
};
XmPushButton
{
arguments
{
XmNlabelString = compound_string("Open Buffer...");
XmNmnemonic = keysym('b');
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure wtt_activate_openbuffer(wtt_ctx);
};
};
XmPushButton
{
arguments
{
......@@ -319,9 +334,11 @@ object edit_entry : XmCascadeButton
XmNaccelerator = "Ctrl<Key>E";
XmNacceleratorText = compound_string('Ctrl+E');
XmNfontList = menu_font;
XmNuserData = 15;
};
callbacks
{
MrmNcreateCallback = procedure wtt_create_menubutton(wtt_ctx);
XmNactivateCallback = procedure wtt_activate_configure(wtt_ctx);
};
};
......@@ -553,6 +570,23 @@ object edit_entry : XmCascadeButton
};
};
XmPushButton
{
arguments
{
XmNlabelString = compound_string("Paste Into");
XmNmnemonic = keysym('P');
XmNaccelerator = "Shift Ctrl<Key>V";
XmNacceleratorText = compound_string('Ctrl+Shift+V');
XmNfontList = menu_font;
XmNuserData = 14;
};
callbacks
{
XmNactivateCallback = procedure wtt_activate_pasteinto(wtt_ctx);
MrmNcreateCallback = procedure wtt_create_menubutton(wtt_ctx);
};
};
XmPushButton
{
arguments
{
......
......@@ -195,6 +195,8 @@ typedef enum {
flow_eEvent_Key_PF4,
flow_eEvent_Key_ShiftRight,
flow_eEvent_Key_ShiftLeft,
flow_eEvent_Key_ShiftUp,
flow_eEvent_Key_ShiftDown,
flow_eEvent_MB1Down,
flow_eEvent_MB1Up,
flow_eEvent_MB2Down,
......
......@@ -573,9 +573,15 @@ int draw_event_handler( FlowCtx *ctx, XEvent event)
// printf( "-- Return key event\n");
break;
case XK_Up:
if ( event.xkey.state & ShiftMask)
sts = ctx->event_handler( flow_eEvent_Key_ShiftUp, 0, 0, 0, 0);
else
sts = ctx->event_handler( flow_eEvent_Key_Up, 0, 0, 0, 0);
break;
case XK_Down:
if ( event.xkey.state & ShiftMask)
sts = ctx->event_handler( flow_eEvent_Key_ShiftDown, 0, 0, 0, 0);
else
sts = ctx->event_handler( flow_eEvent_Key_Down, 0, 0, 0, 0);
break;
case XK_Right:
......
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