Commit bb2c820c authored by claes's avatar claes

Copy-Paste implemented

parent 4aaaac51
......@@ -76,6 +76,7 @@ typedef struct pwr_s_SystemVolume pwr_sSystemVolume;
typedef struct pwr_s_ClassVolume pwr_sClassVolume;
typedef struct pwr_s_WorkBenchVolume pwr_sWorkBenchVolume;
typedef struct pwr_s_DirectoryVolume pwr_sDirectoryVolume;
typedef struct pwr_s_VolatileVolume pwr_sVolatileVolume;
typedef struct pwr_s_CreateVolume pwr_sCreateVolume;
typedef struct pwr_s_MountVolume pwr_sMountVolume;
typedef struct pwr_s_MountObject pwr_sMountObject;
......@@ -237,6 +238,7 @@ typedef enum {
pwr_eCix_MountVolume = 56,
pwr_eCix_MountObject = 57,
pwr_eCix_RtMenu = 58,
pwr_eCix_VolatileVolume = 59,
pwr_eCix_
} pwr_eCix;
......@@ -302,6 +304,7 @@ typedef enum {
pwr_eClass_MountVolume = pwr_ClassId(pwr_eCix_MountVolume),
pwr_eClass_MountObject = pwr_ClassId(pwr_eCix_MountObject),
pwr_eClass_RtMenu = pwr_ClassId(pwr_eCix_RtMenu),
pwr_eClass_VolatileVolume = pwr_ClassId(pwr_eCix_VolatileVolume),
pwr_eClass_
} pwr_eClass;
......@@ -1096,6 +1099,11 @@ struct pwr_s_DirectoryVolume {
pwr_tUInt32 RtBodySize;
};
struct pwr_s_VolatileVolume {
pwr_tString80 Description;
pwr_tObjectIx NextOix;
};
struct pwr_s_CreateVolume {
pwr_tString80 Description;
pwr_tVolumeId Volume;
......
......@@ -95,7 +95,7 @@ projconfig <project is not configured> /info
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
......
! pwrs_c_volatilevolume.wb_load -- Defines the class VolatileVolume.
!
! PROVIEW/R
! Copyright (C) 1996 by Comator Process AB.
!
! <Description>.
!
!
SObject pwrs:Class
Object $VolatileVolume $ClassDef pwr_eCix_VolatileVolume
Body SysBody
Attr Flags |= pwr_mClassDef_System
Attr Flags |= pwr_mClassDef_DevOnly
Attr Flags |= pwr_mClassDef_TopObject
EndBody
Object SysBody $ObjBodyDef 1
Body SysBody
Attr StructName = "VolatileVolume"
EndBody
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object NextOix $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$ObjectIx"
Attr Flags |= PWR_MASK_NOEDIT
EndBody
EndObject
EndObject
EndObject
EndSObject
......@@ -72,7 +72,7 @@ void pwr_vsel_cancel();
void pwr_login_success();
void pwr_login_cancel();
void pwr_wtt_close( void *wttctx);
void pwr_wtt_open_volume( void *wttctx, char *filename, wow_eFileSelType file_type);
void pwr_wtt_open_volume( void *wttctx, wb_eType type, char *filename, wow_eFileSelType file_type);
int pwr_time_to_exit( void *wttctx);
void
......@@ -133,7 +133,7 @@ void pwr_login_success()
appl_count++;
new WVsel( &sts, NULL, mainwindow, "PROVIEW/R Volumes",
wbctx, NULL,
&pwr_vsel_success, &pwr_vsel_cancel, &pwr_time_to_exit, 0);
&pwr_vsel_success, &pwr_vsel_cancel, &pwr_time_to_exit, 0, wb_eType_Volume);
}
else
{
......@@ -158,7 +158,7 @@ int pwr_time_to_exit( void *wttctx)
return 0;
}
void pwr_wtt_open_volume( void *wttctx, char *filename, wow_eFileSelType file_type)
void pwr_wtt_open_volume( void *wttctx, wb_eType type, char *filename, wow_eFileSelType file_type)
{
char title[80];
char systemname[80];
......@@ -175,7 +175,8 @@ void pwr_wtt_open_volume( void *wttctx, char *filename, wow_eFileSelType file_ty
strcat( title, systemname);
appl_count++;
new WVsel( &sts, NULL, mainwindow, "PROVIEW/R Volumes", wbctx, NULL,
&pwr_vsel_success, &pwr_vsel_cancel, &pwr_time_to_exit, 1);
&pwr_vsel_success, &pwr_vsel_cancel, &pwr_time_to_exit, 1,
type);
}
else {
// Open the file... TODO
......@@ -460,7 +461,7 @@ int main( int argc, char *argv[])
strcat( title, systemname);
appl_count++;
new WVsel( &sts, NULL, mainwindow, "PROVIEW/R Volumes", wbctx, volumename,
&pwr_vsel_success, &pwr_vsel_cancel, &pwr_time_to_exit, 0);
&pwr_vsel_success, &pwr_vsel_cancel, &pwr_time_to_exit, 0, wb_eType_Volume);
}
else
exit(LOGIN__NOPRIV);
......
......@@ -17,7 +17,8 @@
typedef enum {
wb_eType_Volume,
wb_eType_Project,
wb_eType_Class
wb_eType_Class,
wb_eType_Buffer
} wb_eType;
typedef enum {
......
......@@ -58,6 +58,8 @@ public:
int flags() {return m_flags;}
pwr_tOid boid();
pwr_tCid subClass() { return m_subClass;}
bool isClass() const {return (m_flags & PWR_MASK_CLASS || m_flags & PWR_MASK_BUFFER);}
bool isArray() const {return (m_flags & PWR_MASK_ARRAY);}
const char *name() const;
wb_name longName();
......
......@@ -158,7 +158,7 @@ extern "C" wtt_tCtx wtt_new(
void *wbctx,
pwr_tVolumeId volid,
void (*wtt_close_cb)(void *),
void (*wtt_open_volume_cb)(void *, char *, wow_eFileSelType),
void (*wtt_open_volume_cb)(void *, wb_eType, char *, wow_eFileSelType),
int (*wtt_time_to_exit_cb)(void *),
pwr_tStatus *sts
)
......
......@@ -30,6 +30,10 @@ extern "C" {
#include "co_wow.h"
#endif
#ifndef wb_h
#include "wb.h"
#endif
/* Pal */
typedef void *pal_tCtx;
......@@ -79,7 +83,7 @@ wtt_tCtx wtt_new(
void *wbctx,
pwr_tVolumeId volid,
void (*wtt_close_cb)(void *),
void (*wtt_open_volume_cb)(void *, char *, wow_eFileSelType),
void (*wtt_open_volume_cb)(void *, wb_eType, char *, wow_eFileSelType),
int (*wtt_time_to_exit_cb)(void *),
pwr_tStatus *sts
);
......
......@@ -55,6 +55,7 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep, int
m_elements = m_adrep->nElement();
m_type = m_adrep->type();
m_flags = m_adrep->flags();
m_bix = m_adrep->bix();
if (m_flags & PWR_MASK_ARRAY) {
if (idx >= m_elements)
......@@ -87,7 +88,7 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep, int
}
m_size = bdef.size();
m_bix = bdef.bix();
}
}
}
......@@ -104,6 +105,7 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, const char *bname) :
wb_bdrep *bd = cd->bdrep( &m_sts, bname);
if ( oddSts()) {
m_size = bd->size();
m_bix = bd->bix();
delete bd;
}
delete cd;
......@@ -343,9 +345,12 @@ pwr_tCid wb_attribute::cid() const
pwr_eBix wb_attribute::bix() const
{
throw wb_error_str("wb_attribute::bix() NYI");
check();
return pwr_eBix__; // Fix
if (m_flags & PWR_MASK_SUBCLASS)
return m_bix;
return m_adrep->bix();
}
pwr_tOid wb_attribute::boid() const
......@@ -388,7 +393,10 @@ void *wb_attribute::value( void *p) const
check();
if ( m_adrep == 0) {
return m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_rt, p);
if ( m_bix == pwr_eBix_dev)
return m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_dev, p);
else
return m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_rt, p);
}
if (m_flags & PWR_MASK_SUBCLASS)
......@@ -435,7 +443,7 @@ wb_attribute wb_attribute::after() const
return wb_attribute();
wb_adrep* adrep = m_adrep->next(&sts);
if (evenSts())
if (EVEN(sts))
return wb_attribute();
wb_attribute a(LDH__SUCCESS, m_orep, adrep);
......@@ -462,7 +470,7 @@ wb_attribute wb_attribute::before() const
return wb_attribute();
wb_adrep* adrep = m_adrep->prev(&sts);
if (evenSts())
if (EVEN(sts))
return wb_attribute();
wb_attribute a(LDH__SUCCESS, m_orep, adrep);
......
......@@ -103,10 +103,15 @@ public:
pwr_tStatus sts() const { return m_sts;}
wb_adrep *adrep() { return m_adrep;}
private:
void check() const;
void init();
};
#endif
......@@ -76,6 +76,13 @@ wb_volume wb_env::externVolume(pwr_tVid vid)
return v;
}
wb_volume wb_env::bufferVolume()
{
wb_vrep *vrep = m_erep->bufferVolume( &m_sts);
wb_volume v( vrep);
return v;
}
wb_volume wb_env::volume(const char *name)
{
wb_volume v( m_erep->volume( &m_sts, name));
......
......@@ -38,11 +38,14 @@ public:
wb_volume volume(const char *name);
wb_volume externVolume(pwr_tVid);
wb_volume bufferVolume();
wb_volume snapshot(pwr_tVid);
wb_volume createVolume(wb_cdef cdef, pwr_tVid vid, wb_name name);
int nextVolatileVid( char *name) { return m_erep->nextVolatileVid( &m_sts, name); }
};
......
......@@ -65,18 +65,31 @@ wb_vrep *wb_erep::volume( pwr_tStatus *sts)
wb_vrep *wb_erep::volume(pwr_tStatus *sts, pwr_tVid vid)
{
vrep_iterator it = m_vrepdb.find( vid);
if ( it == m_vrepdb.end()) {
it = m_vrepdbs.find(vid);
if ( it == m_vrepdbs.end()) {
it = m_vrepextern.find(vid);
if ( it == m_vrepextern.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
}
}
if ( it != m_vrepdb.end()) {
*sts = LDH__SUCCESS;
return it->second;
}
*sts = LDH__SUCCESS;
return it->second;
it = m_vrepdbs.find(vid);
if ( it != m_vrepdbs.end()) {
*sts = LDH__SUCCESS;
return it->second;
}
it = m_vrepextern.find(vid);
if ( it != m_vrepextern.end()) {
*sts = LDH__SUCCESS;
return it->second;
}
it = m_vrepbuffer.find(vid);
if ( it != m_vrepbuffer.end()) {
*sts = LDH__SUCCESS;
return it->second;
}
*sts = LDH__NOSUCHVOL;
return 0;
}
wb_vrep *wb_erep::volume(pwr_tStatus *sts, const char *name)
......@@ -115,29 +128,71 @@ wb_vrep *wb_erep::externVolume(pwr_tStatus *sts, pwr_tVid vid)
return it->second;
}
wb_vrep *wb_erep::bufferVolume(pwr_tStatus *sts)
{
vrep_iterator it = m_vrepbuffer.begin();
if ( it == m_vrepbuffer.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
}
*sts = LDH__SUCCESS;
return it->second;
}
wb_vrep *wb_erep::nextVolume(pwr_tStatus *sts, pwr_tVid vid)
{
// Search in db
vrep_iterator it = m_vrepdb.find( vid);
if ( it != m_vrepdb.end()) {
it++;
if ( it != m_vrepdb.end()) {
*sts = LDH__SUCCESS;
return it->second;
}
else {
// Next volume in dbs
it = m_vrepdbs.begin();
if ( it == m_vrepdbs.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
if ( it != m_vrepdbs.end()) {
*sts = LDH__SUCCESS;
return it->second;
}
else {
*sts = LDH__NOSUCHVOL;
return 0;
}
}
}
else {
it = m_vrepdbs.find(vid);
// Search in dbs
it = m_vrepdbs.find(vid);
if ( it != m_vrepdbs.end()) {
it++;
if ( it == m_vrepdbs.end()) {
if ( it != m_vrepdbs.end()) {
*sts = LDH__SUCCESS;
return it->second;
}
else {
*sts = LDH__NOSUCHVOL;
return 0;
}
}
*sts = LDH__SUCCESS;
return it->second;
// Search in buffer
it = m_vrepbuffer.find(vid);
if ( it != m_vrepbuffer.end()) {
it++;
if ( it != m_vrepbuffer.end()) {
*sts = LDH__SUCCESS;
return it->second;
}
else {
*sts = LDH__NOSUCHVOL;
return 0;
}
}
*sts = LDH__NOSUCHVOL;
return 0;
}
void wb_erep::addDb( pwr_tStatus *sts, wb_vrep *vrep)
......@@ -183,6 +238,20 @@ void wb_erep::addExtern( pwr_tStatus *sts, wb_vrep *vrep)
}
}
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;
vrep->ref();
*sts = LDH__SUCCESS;
}
else {
*sts = LDH__VOLIDALREXI;
return;
}
}
void wb_erep::removeDb(pwr_tStatus *sts, wb_vrep *vrep)
{
vrep_iterator it = m_vrepdb.find( vrep->vid());
......@@ -219,6 +288,18 @@ void wb_erep::removeExtern(pwr_tStatus *sts, wb_vrep *vrep)
*sts = LDH__SUCCESS;
}
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();
m_vrepbuffer.erase( it);
*sts = LDH__SUCCESS;
}
void wb_erep::load( pwr_tStatus *sts)
{
loadDirList( sts);
......@@ -582,13 +663,17 @@ void wb_erep::bindMethods()
#endif
}
int wb_erep::nextVolatileVid( pwr_tStatus *sts)
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;
}
if ( name)
// Suggest a name
sprintf( name, "Buffer%03d", vid & 255);
return vid;
}
......
......@@ -25,6 +25,7 @@ class wb_erep
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;
map< string, wb_tMethod> m_methods;
char m_dir_list[10][200];
......@@ -44,12 +45,15 @@ public:
wb_vrep *volume(pwr_tStatus *sts, const char *name);
wb_vrep *nextVolume(pwr_tStatus *sts, pwr_tVid vid);
wb_vrep *externVolume(pwr_tStatus *sts, pwr_tVid vid);
wb_vrep *bufferVolume(pwr_tStatus *sts);
void addDb( pwr_tStatus *sts, wb_vrep *vrep);
void addDbs( pwr_tStatus *sts, wb_vrep *vrep);
void addExtern( pwr_tStatus *sts, wb_vrep *vrep);
void addBuffer( pwr_tStatus *sts, wb_vrep *vrep);
void removeDb( pwr_tStatus *sts, wb_vrep *vrep);
void removeDbs( pwr_tStatus *sts, wb_vrep *vrep);
void removeExtern( pwr_tStatus *sts, wb_vrep *vrep);
void removeBuffer( pwr_tStatus *sts, wb_vrep *vrep);
void load( pwr_tStatus *sts);
wb_orep *object( pwr_tStatus *sts, pwr_tOid oid);
......@@ -59,7 +63,7 @@ public:
wb_cdrep *cdrep( pwr_tStatus *sts, const wb_orep& o);
wb_tdrep *tdrep( pwr_tStatus *sts, const wb_adrep& a);
void method( pwr_tStatus *sts, char *methodName, wb_tMethod *method);
int nextVolatileVid( pwr_tStatus *sts);
int nextVolatileVid( pwr_tStatus *sts, char *name);
private:
void loadDirList( pwr_tStatus *status);
......
......@@ -16,7 +16,6 @@ public:
virtual bool exportDbody(wb_import &e) = 0;
virtual bool exportMeta(wb_import &e) = 0;
};
#endif
......@@ -27,3 +27,5 @@ public:
};
#endif
......@@ -19,7 +19,6 @@ This module contains the API-routines to the Local Data Handler, LDH. */
#include <lib$routines.h>
#endif
#include <stdarg.h>
#include <X11/Intrinsic.h>
#include "pwr.h"
#include "wb_ldhi.h"
#include "pwr_class.h"
......@@ -37,6 +36,9 @@ This module contains the API-routines to the Local Data Handler, LDH. */
#include "wb_object.h"
#include "wb_volume.h"
#include "wb_error.h"
#include "wb_vrepmem.h"
#include "pwr_baseclasses.h"
#include <X11/Intrinsic.h>
pwr_dImport pwr_BindClasses(System);
pwr_dImport pwr_BindClasses(Base);
......@@ -118,6 +120,18 @@ ldh_GetVolumeList(ldh_tWorkbench workbench, pwr_tVid *vid)
return LDH__SUCCESS;
}
pwr_tStatus
ldh_GetBufferList(ldh_tWorkbench workbench, pwr_tVid *vid)
{
wb_env *wb = (wb_env *)workbench;
wb_volume v = wb->bufferVolume();
if (!v) return v.sts();
*vid = v.vid();
return LDH__SUCCESS;
}
pwr_tStatus
ldh_GetNextVolume(ldh_tWorkbench workbench, pwr_tVid vid, pwr_tVid *new_vid)
{
......@@ -1217,16 +1231,17 @@ ldh_SessionToWB(ldh_tSession session)
pwr_tStatus
ldh_SetObjectBody(ldh_tSession session, pwr_tOid oid, char *bname, char *value, int size)
{
wb_session *sp = (wb_session*)session;
wb_session *sp = (wb_session *)session;
wb_object o = sp->object(oid);
if (!o) return o.sts();
#if NOT_YET_IMPLEMENTED
wb_body b = o.body(bname);
if (!b) return b.sts();
return b.value(value, size);
#endif
return LDH__NYI;
wb_attribute a = sp->attribute(o, bname);
try {
sp->writeAttribute(a, value);
return sp->sts();
}
catch (wb_error& e) {
return e.sts();
}
}
pwr_tStatus
......@@ -1240,9 +1255,13 @@ ldh_SetObjectBuffer(ldh_tSession session, pwr_tOid oid, char *bname, char *aname
wb_attribute a = o.attribute(bname, aname);
if (!a) return a.sts();
sp->writeAttribute(a, value);
return sp->sts();
try {
sp->writeAttribute(a, value);
return sp->sts();
}
catch (wb_error& e) {
return e.sts();
}
}
......@@ -1366,12 +1385,74 @@ ldh_CopyObjectTrees(ldh_tSession session, pwr_sAttrRef *arp, pwr_tOid doid, ldh_
pwr_tStatus
ldh_Copy(ldh_tSession session, pwr_sAttrRef *arp)
{
//wb_session *sp = (wb_session*)session;
wb_session *sp = (wb_session*)session;
pwr_tStatus sts;
//wb_oset s = sp->objectset(arp);
//wb->copySet(s);
return LDH__NYI;
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;
}
vrep->exportTree( *mem, ap->Objid);
ap++;
}
mem->importTree();
return LDH__SUCCESS;
}
/* Make a copy of object trees pointed at by AREF and
......@@ -1395,9 +1476,26 @@ ldh_Cut(ldh_tSession session, pwr_sAttrRef *arp)
pwr_tStatus
ldh_Paste(ldh_tSession session, pwr_tOid doid, ldh_eDest dest)
{
//wb_session *sp = (wb_session*)session;
wb_session *sp = (wb_session*)session;
pwr_tStatus sts;
return LDH__NYI;
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();
}
mem = prev;
wb_vrep *vrep = (wb_vrep *) *sp;
mem->exportPaste( *vrep, doid);
return LDH__SUCCESS;
}
pwr_tStatus
......
......@@ -671,6 +671,12 @@ ldh_GetVolumeList (
pwr_tVolumeId *Volume
);
pwr_tStatus
ldh_GetBufferList (
ldh_tWorkbench Workbench,
pwr_tVolumeId *Volume
);
pwr_tStatus
ldh_GetNextVolume (
ldh_tWorkbench Workbench,
......
#ifndef wb_treeexport_h
#define wb_treeexport_h
class wb_treeimport;
class wb_treeexport
{
public:
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid) = 0;
};
#endif
#include "pwr.h"
#include "pwr_class.h"
#include "wb_treeimport.h"
#include "wb_vrep.h"
#include "wb_orep.h"
#include "wb_cdrep.h"
#include "wb_bdrep.h"
#include "wb_adrep.h"
#include "wb_merep.h"
bool wb_treeimport::importTranslationTableInsert( pwr_tOix from, pwr_tOix to)
{
pair<pwr_tOix, pwr_tOix>p(from,to);
pair<map<pwr_tOix,pwr_tOix>::iterator,bool>result = m_translation_table.insert(p);
return result.second;
}
void wb_treeimport::importTranslationTableClear()
{
while( ! m_translation_table.empty())
m_translation_table.erase( m_translation_table.begin());
}
pwr_tOix wb_treeimport::importTranslate( pwr_tOix oix)
{
iterator_translation_table it = m_translation_table.find( oix);
if ( it == m_translation_table.end())
return 0;
return it->second;
}
bool wb_treeimport::importUpdateTree( wb_vrep *vrep)
{
iterator_translation_table it;
pwr_tStatus sts;
// Update all imported objects, get objects from the translationtable
for ( it = m_translation_table.begin(); it != m_translation_table.end(); it++) {
pwr_tOid oid;
oid.oix = it->second;
oid.vid = vrep->vid();
wb_orep *o = vrep->object( &sts, oid);
if ( EVEN(sts)) throw wb_error( LDH__NOSUCHOBJ);
o->ref();
importUpdateObject( o, vrep);
o->unref();
}
return true;
}
bool wb_treeimport::importUpdateSubClass( wb_adrep *subattr, char *body, wb_vrep *vrep,
bool *modified)
{
pwr_tStatus sts;
pwr_tOix oix;
pwr_tCid cid = subattr->subClass();
wb_cdrep *cdrep = vrep->merep()->cdrep( &sts, cid);
wb_bdrep *bdrep = cdrep->bdrep( &sts, pwr_eBix_rt);
if ( EVEN(sts)) return false;
int subattr_elements = subattr->isArray() ? subattr->nElement() : 1;
for ( int i = 0; i < subattr_elements; i++) {
wb_adrep *adrep = bdrep->adrep( &sts);
while ( ODD(sts)) {
int elements = adrep->isArray() ? adrep->nElement() : 1;
if ( adrep->isClass()) {
importUpdateSubClass( adrep, body + i * subattr->size() / subattr_elements + adrep->offset(),
vrep, modified);
}
else {
switch ( adrep->type()) {
case pwr_eType_Objid: {
pwr_tOid *oidp = (pwr_tOid *)(body + i * subattr->size() / subattr_elements +
adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( oidp->vid == m_import_source_vid && (oix = importTranslate( oidp->oix))) {
oidp->vid = vrep->vid();
oidp->oix = oix;
*modified = true;
}
oidp++;
}
break;
}
case pwr_eType_AttrRef: {
pwr_sAttrRef *arp = (pwr_sAttrRef *)(body + i * subattr->size() / subattr_elements +
adrep->offset());
for ( int j = 0; j < elements; j++) {
if ( arp->Objid.vid == m_import_source_vid && (oix = importTranslate( arp->Objid.oix))) {
arp->Objid.vid = vrep->vid();
arp->Objid.oix = oix;
*modified = true;
}
arp++;
}
break;
}
default:
;
}
}
wb_adrep *prev = adrep;
adrep = adrep->next( &sts);
delete prev;
}
}
delete bdrep;
delete cdrep;
return true;
}
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());
pwr_mClassDef flags = cdrep->flags();
for ( int i = 0; i < 2; i++) {
pwr_eBix bix = i ? pwr_eBix_rt : pwr_eBix_dev;
wb_bdrep *bdrep = cdrep->bdrep( &sts, bix);
if ( EVEN(sts)) continue;
char *body = (char *)malloc( bdrep->size());
vrep->readBody( &sts, o, bix, body);
bool modified = false;
wb_adrep *adrep = bdrep->adrep( &sts);
while ( ODD(sts)) {
int elements = adrep->isArray() ? adrep->nElement() : 1;
if ( adrep->isClass()) {
importUpdateSubClass( adrep, body + adrep->offset(), vrep, &modified);
}
else {
switch ( adrep->type()) {
case pwr_eType_Objid: {
pwr_tOid *oidp = (pwr_tOid *)(body + adrep->offset());
for ( i = 0; i < elements; i++) {
if ( oidp->vid == m_import_source_vid && (oix = importTranslate( oidp->oix))) {
oidp->vid = vrep->vid();
oidp->oix = oix;
modified = true;
}
oidp++;
}
break;
}
case pwr_eType_AttrRef: {
pwr_sAttrRef *arp = (pwr_sAttrRef *)(body + adrep->offset());
for ( i = 0; i < elements; i++) {
if ( arp->Objid.vid == m_import_source_vid && (oix = importTranslate( arp->Objid.oix))) {
arp->Objid.vid = vrep->vid();
arp->Objid.oix = oix;
modified = true;
}
arp++;
}
break;
}
default:
;
}
}
wb_adrep *prev = adrep;
adrep = adrep->next( &sts);
delete prev;
}
if ( modified)
vrep->writeBody( &sts, o, bix, body);
free( body);
delete bdrep;
}
delete cdrep;
return true;
}
#ifndef wb_treeimport_h
#define wb_treeimport_h
#include <map>
#include "pwr.h"
class wb_treeexport;
class wb_adrep;
class wb_vrep;
class wb_orep;
class wb_treeimport
{
map<pwr_tOix, pwr_tOix> m_translation_table;
pwr_tVid m_import_source_vid;
typedef map<pwr_tOix, pwr_tOix>::iterator iterator_translation_table;
bool importUpdateSubClass( wb_adrep *subattr, char *body, wb_vrep *vrep,
bool *modified);
bool importUpdateObject( wb_orep *o, wb_vrep *vrep);
public:
virtual ~wb_treeimport() {}
virtual bool importTree() = 0;
virtual bool importTreeObject(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,
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);
void importTranslationTableClear();
pwr_tOix importTranslate( pwr_tOix oix);
void importSetSourceVid( pwr_tVid vid) { m_import_source_vid = vid;}
bool importUpdateTree( wb_vrep *vrep);
};
#endif
......@@ -2,6 +2,7 @@
#include "wb_merep.h"
#include "wb_bdrep.h"
#include "wb_cdrep.h"
#include "wb_vrepmem.h"
wb_volume::wb_volume() : wb_status(LDH__NOSUCHVOL), m_vrep(0)
{
......@@ -295,6 +296,12 @@ wb_attribute wb_volume::attribute(const pwr_sAttrRef* arp) const
return wb_attribute();
}
bool wb_volume::exportTree( wb_volume &import, pwr_tOid oid)
{
wb_vrepmem *vrepmem = (wb_vrepmem *)(wb_vrep *)import;
return m_vrep->exportTree( *vrepmem, oid);
}
pwr_tStatus wb_volume::syntaxCheck( int *errorcount, int *warningcount)
{
pwr_tStatus sts;
......
......@@ -78,6 +78,7 @@ public:
bool isLocal(wb_object &o) const;
bool createSnapshot(const char *fileName) { return m_vrep->createSnapshot(fileName);}
bool exportTree( wb_volume &import, pwr_tOid oid);
pwr_tStatus syntaxCheck( int *errorcount, int *warningcount);
pwr_tStatus syntaxCheckObject( wb_orep *orep, int *errorcount, int *warningcount);
......@@ -94,3 +95,13 @@ public:
};
#endif
......@@ -10,6 +10,8 @@
#include "wb_cdef.h"
#include "wb_destination.h"
#include "wb_export.h"
#include "wb_treeexport.h"
#include "wb_treeimport.h"
#include <map>
class wb_erep;
......@@ -19,7 +21,7 @@ class wb_cdef;
class wb_destination;
class wb_dbs;
class wb_vrep : public wb_export
class wb_vrep : public wb_export, public wb_treeexport, public wb_treeimport
{
protected:
char m_name[80];
......
......@@ -124,6 +124,19 @@ 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,
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,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
#if 0
int del_family(DbTxn *txn, Dbc *cp, pwr_tOid poid);
#endif
......
......@@ -3,6 +3,7 @@
#include "wb_erep.h"
#include "wb_merep.h"
#include "wb_import.h"
#include "wb_treeimport.h"
void wb_vrepdbs::unref()
{
......@@ -482,3 +483,53 @@ bool wb_vrepdbs::exportMeta(wb_import &i)
return false;
}
bool wb_vrepdbs::exportTree(wb_treeimport &i, pwr_tOid oid)
{
pwr_tStatus sts;
dbs_sObject *op = dbs_OidToObject( &sts, dbsenv(), oid);
if (op == 0)
return false;
exportTreeObject( i, op, true);
return true;
}
bool wb_vrepdbs::exportTreeObject(wb_treeimport &i, dbs_sObject *op, bool isRoot)
{
pwr_tStatus sts;
dbs_sObject *before = dbs_Before(&sts, dbsenv(), op);
dbs_sObject *parent = dbs_Parent(&sts, dbsenv(), op);
dbs_sObject *first = dbs_First(&sts, dbsenv(), op);
dbs_sObject *after = dbs_After(&sts, dbsenv(), op);
pwr_tOid parentoid = pwr_cNOid;
pwr_tOid beforeoid = pwr_cNOid;
void *rbody = 0;
void *dbody = 0;
if ( parent && !isRoot)
parentoid = parent->oid;
if ( before && !isRoot)
beforeoid = before->oid;
if ( op->rbody.size)
rbody = dbs_Body(&sts, dbsenv(), op, pwr_eBix_rt);
if ( op->dbody.size)
dbody = dbs_Body(&sts, dbsenv(), op, pwr_eBix_dev);
i.importTreeObject( op->oid, op->cid, parentoid, beforeoid, op->name,
op->rbody.size, op->dbody.size, rbody, dbody);
if ( first)
exportTreeObject( i, first, false);
if ( !isRoot && after)
exportTreeObject( i, after, false);
return true;
}
......@@ -132,6 +132,19 @@ public:
virtual bool exportRbody(wb_import &e);
virtual bool exportDbody(wb_import &e);
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,
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,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
};
......
This diff is collapsed.
......@@ -6,6 +6,7 @@
#include "wb_vrep.h"
#include "wb_erep.h"
#include "wb_attrname.h"
#include "wb_treeimport.h"
class wb_vrepmem;
......@@ -32,16 +33,57 @@ class mem_object
mem_object *get_lch() {
mem_object *c = fch;
if ( c)
while ( c->fws) ;
while ( c->fws)
c = c->fws;
return c;
}
bool exportHead(wb_import &i) { return false;}
bool exportDbody(wb_import &i) { return false;}
bool exportRbody(wb_import &i) { return false;}
bool exportTree( wb_treeimport &i, bool isRoot) {
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(),
rbody_size, dbody_size, rbody, dbody);
if ( fch)
fch->exportTree( i, false);
if ( !isRoot && fws)
fws->exportTree( i, false);
return true;
}
bool exportPaste( wb_treeimport &i, pwr_tOid destination, bool isRoot) {
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);
if ( fch)
fch->exportPaste( i, destination, false);
if ( fws)
fws->exportPaste( i, destination, false);
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;
......@@ -74,6 +116,7 @@ class wb_vrepmem : public wb_vrep
unsigned int m_nRef;
mem_object *root_object;
int m_nextOix;
pwr_tVid m_source_vid;
map<pwr_tOix, mem_object *> m_oix_list;
......@@ -102,6 +145,7 @@ public:
wb_erep *erep() {return m_erep;}
wb_merep *merep() const { return m_merep;}
int nextOix();
mem_object *findObject( pwr_tOix oix);
mem_object *find( const char *name);
int nameToOid( const char *name, pwr_tOid *oid);
......@@ -147,23 +191,23 @@ public:
bool moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d) {return false;}
bool deleteObject(pwr_tStatus *sts, wb_orep *orep) {return false;}
bool deleteFamily(pwr_tStatus *sts, wb_orep *orep) {return false;}
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 commit(pwr_tStatus *sts) {return false;}
bool abort(pwr_tStatus *sts) {return false;}
bool commit(pwr_tStatus *sts) {return true;}
bool abort(pwr_tStatus *sts) {return true;}
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p) {return false;}
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
virtual void *readAttribute(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
virtual void *readBody(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, void *p);
virtual bool writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p) {return false;};
virtual bool writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p);
wb_orep *ancestor(pwr_tStatus *sts, const wb_orep *o);
......@@ -186,7 +230,7 @@ public:
wb_srep *newSession() {return 0;}
bool isLocal(const wb_orep *o) {return false;}
bool isLocal(const wb_orep *o) {return o->oid().vid == vid();}
void objectName(const wb_orep *o, char *str);
......@@ -195,6 +239,19 @@ public:
virtual bool exportRbody(wb_import &i);
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,
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,
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);
};
#endif
......
......@@ -180,6 +180,16 @@ bool wb_vrepwbl::exportMeta(wb_import &i)
return false;
}
bool wb_vrepwbl::exportTree(wb_treeimport &i, pwr_tOid oid)
{
ref_wblnode n = findObject( oid.oix);
if ( !n)
return false;
n->exportTree( i, true);
return true;
}
int wb_vrepwbl::load( const char *fname)
{
int i;
......@@ -1224,7 +1234,8 @@ wb_orep *wb_vrepwbl::parent(pwr_tStatus *sts, const wb_orep *o)
{
wb_orepwbl *orep = 0;
if ( ((wb_orepwbl *)o)->wblNode()->o->fth) {
if ( ((wb_orepwbl *)o)->wblNode()->o->fth &&
((wb_orepwbl *)o)->wblNode()->o->fth != root_object) {
orep = new wb_orepwbl( (wb_vrepwbl *)this, ((wb_orepwbl *)o)->wblNode()->o->fth);
*sts = LDH__SUCCESS;
}
......
......@@ -150,13 +150,13 @@ public:
bool commit(pwr_tStatus *sts) {return false;}
bool abort(pwr_tStatus *sts) {return false;}
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p) {return false;}
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p) { return false;}
virtual void *readAttribute(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
virtual void *readBody(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, void *p);
virtual bool writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p) {return false;};
virtual bool writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p) { return false;}
wb_orep *ancestor(pwr_tStatus *sts, const wb_orep *o);
......@@ -179,7 +179,7 @@ public:
wb_srep *newSession() {return 0;}
bool isLocal(const wb_orep *o) {return false;}
bool isLocal(const wb_orep *o) {return o->oid().vid == vid();}
void objectName(const wb_orep *o, char *str);
......@@ -188,6 +188,18 @@ public:
virtual bool exportRbody(wb_import &i);
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,
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,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
};
#endif
......@@ -279,11 +279,12 @@ WVsel::WVsel (
int (*bc_success)( void *, pwr_tVolumeId *, int),
void (*bc_cancel)(),
int (*bc_time_to_exit)( void *),
int show_volumes
int show_volumes,
wb_eType wv_wb_type
) : parent_ctx(wv_parent_ctx), parent_wid(wv_parent_wid), wbctx(wv_wbctx),
vsel_bc_success(bc_success), vsel_bc_cancel(bc_cancel),
vsel_bc_time_to_exit( bc_time_to_exit), volume_count(0), all(0),
write_priv(0)
write_priv(0), wb_type(wv_wb_type)
{
Arg args[20];
int sts;
......@@ -337,7 +338,7 @@ WVsel::WVsel (
if ( volumename != NULL && *volumename != 0 && !show_volumes)
/* Start the navigater for this volume */
strcpy( volname, volumename);
else if ( !show_volumes)
else if ( !show_volumes && wb_type != wb_eType_Buffer)
{
/* If there is only one volume in the db, select this volume */
volume_count = 0;
......@@ -368,7 +369,7 @@ WVsel::WVsel (
// If volume name is supplied, find this volume and open the navigator.
if ( strcmp( volname, ""))
if ( strcmp( volname, "") && wb_type != wb_eType_Buffer)
/* Check syntax, if new volumes is found, show the window */
sts = check_volumelist( 1, &display_window);
......@@ -451,7 +452,8 @@ WVsel::WVsel (
MrmCloseHierarchy(s_DRMh);
sts = check_volumelist( 0, &display_window);
if ( wb_type != wb_eType_Buffer)
sts = check_volumelist( 0, &display_window);
// Set input focus to the scrolled list widget
XmProcessTraversal( widgets.volumelist, XmTRAVERSE_CURRENT);
......@@ -523,7 +525,10 @@ pwr_tStatus WVsel::load_volumelist()
XmListDeleteAllItems( widgets.volumelist);
volume_count = 0;
sts = ldh_GetVolumeList( wbctx, &volume);
if ( wb_type != wb_eType_Buffer)
sts = ldh_GetVolumeList( wbctx, &volume);
else
sts = ldh_GetBufferList( wbctx, &volume);
while ( ODD(sts) )
{
sts = ldh_GetVolumeClass( wbctx, volume, &classid);
......@@ -759,3 +764,8 @@ pwr_tStatus WVsel::check_volumelist(
......@@ -16,6 +16,10 @@
#include "wb_nav_macros.h"
#endif
#ifndef wb_h
#include "wb.h"
#endif
#define VSEL_MAX_VOLUMES 200
struct vsel_widgets
......@@ -45,7 +49,8 @@ class WVsel {
int (*bc_success)( void *, pwr_tVolumeId *, int),
void (*bc_cancel)(),
int (*bc_time_to_exit)( void *),
int show_volumes);
int show_volumes,
wb_eType wv_wb_type);
void message( char *new_label);
pwr_tStatus load_volumelist();
pwr_tStatus check_volumelist( int quiet, int *display_window);
......@@ -62,6 +67,7 @@ class WVsel {
int volume_count;
int all;
int write_priv;
wb_eType wb_type;
// Backcall functions from uil
static void vsel_activate_showall( Widget w, WVsel *vsel, XmToggleButtonCallbackStruct *data);
......
......@@ -8,6 +8,7 @@
#include "wb_wblvocabTokenTypes.hpp"
#include "wb_dbs.h"
#include "wb_name.h"
#include "wb_treeimport.h"
#define wblAlign(size) ((size + 3) & ~3)
......@@ -186,6 +187,8 @@ static wbl_sSym classes[] =
,{ "pwr_eCix_WorkBenchVolume", pwr_eCix_WorkBenchVolume }
,{ "pwr_eClass_DirectoryVolume", pwr_eClass_DirectoryVolume }
,{ "pwr_eCix_DirectoryVolume", pwr_eCix_DirectoryVolume }
,{ "pwr_eClass_VolatileVolume", pwr_eClass_VolatileVolume }
,{ "pwr_eCix_VolatileVolume", pwr_eCix_VolatileVolume }
,{ "pwr_eClass_CreateVolume", pwr_eClass_CreateVolume }
,{ "pwr_eCix_CreateVolume", pwr_eCix_CreateVolume }
,{ "pwr_eClass_MountVolume", pwr_eClass_MountVolume }
......@@ -476,7 +479,7 @@ void wb_wblnode::build( bool recursive)
case pwr_eClass_Param:
if ( attr->o->a.type == pwr_eType_AttrRef)
((pwr_sClassDef *)o->rbody)->Flags.b.AttrRef = 1;
else if ( attr->o->a.type == pwr_eType_AttrRef)
else if ( attr->o->a.type == pwr_eType_Objid)
((pwr_sClassDef *)o->rbody)->Flags.b.ObjRef = 1;
break;
default:
......@@ -1540,6 +1543,23 @@ bool wb_wblnode::exportRbody( wb_import &i)
return true;
}
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(),
o->rbody_size, o->dbody_size, o->rbody, o->dbody);
if ( o->fch)
o->fch->exportTree( i, false);
if ( !isRoot && o->fws)
o->fws->exportTree( i, false);
return true;
}
void wb_wblnode::setFile( wb_wblfile *f)
{
file = f;
......
......@@ -16,6 +16,7 @@ class wb_vrepwbl;
class wb_vrep;
class wb_dbs;
class wb_import;
class wb_treeimport;
typedef enum {
wbl_eNodeType_No,
......@@ -243,6 +244,7 @@ public:
bool exportHead(wb_import &i);
bool exportDbody(wb_import &i);
bool exportRbody(wb_import &i);
bool exportTree(wb_treeimport &i, bool isRoot);
#if 0
void iterObject(wb_dbs *);
......
......@@ -40,6 +40,14 @@ extern "C" {
#include "wb_pal.h"
#endif
#ifndef co_wow_h
#include "co_wow.h"
#endif
#ifndef wb_h
#include "wb.h"
#endif
#define wnav_cVersion "X3.3a"
#define wnav_cScriptDescKey "!** Description"
#define wnav_cScriptInvisKey "!** Invisible"
......@@ -219,6 +227,7 @@ class WNav {
int **, int *);
int (*global_unselect_objid_cb)( void *, pwr_tObjid objid);
void (*set_window_char_cb)( void *, short, short);
void (*open_vsel_cb)( void *, wb_eType, char *, wow_eFileSelType);
int ccm_func_registred;
wnav_sMenu *menu_tree;
int closing_down;
......
......@@ -3171,12 +3171,23 @@ static int wnav_move_func( void *client_data,
static int wnav_open_func( void *client_data,
void *client_flag)
{
WNav *wnav = (WNav *)client_data;
char arg1_str[80];
int arg1_sts;
arg1_sts = dcli_get_qualifier( "dcli_arg1", arg1_str);
return WNAV__SUCCESS;
if ( strncmp( arg1_str, "BUFFERS", strlen( arg1_str)) == 0)
{
if ( wnav->open_vsel_cb)
(wnav->open_vsel_cb)( wnav->parent_ctx, wb_eType_Buffer, NULL, wow_eFileSelType_All);
}
else
{
wnav->message('E', "Syntax error");
return WNAV__SYNTAX;
}
return WNAV__SUCCESS;
}
static int wnav_create_func( void *client_data,
......@@ -3497,6 +3508,7 @@ static int wnav_new_func( void *client_data,
if ( strncmp( arg1_str, "VOLUME", strlen( arg1_str)) == 0)
{
char name_str[80];
char *name_ptr = 0;
sts = wnav_wccm_get_wbctx_cb( wnav, &wnav->wbctx);
if ( EVEN(sts)) return sts;
......@@ -3512,12 +3524,12 @@ static int wnav_new_func( void *client_data,
}
else if ( EVEN( dcli_get_qualifier( "/NAME", name_str)))
{
wnav->message('E',"Enter name");
return WNAV__QUAL;
// Use defaultname from erep
name_ptr = name_str;
}
wb_erep *erep = *(wb_env *)wnav->wbctx;
pwr_tVid vid = erep->nextVolatileVid( &sts);
pwr_tVid vid = erep->nextVolatileVid( &sts, name_ptr);
if ( EVEN(sts)) {
wnav->message(' ', wnav_get_message(sts));
return sts;
......
......@@ -159,6 +159,15 @@ extern "C" void wtt_distrw_quit_cb( void *ctx)
((Wtt *)ctx)->distrwctx = NULL;
}
static void wtt_open_vsel_cb( void *ctx, wb_eType type, char *filename, wow_eFileSelType file_type)
{
Wtt *wtt = (Wtt *)ctx;
if ( wtt->open_volume_cb)
(wtt->open_volume_cb) ( wtt, type, filename, file_type);
}
static void wtt_set_window_char_cb( void *ctx, short width, short height)
{
Wtt *wtt = (Wtt *)ctx;
......@@ -317,6 +326,40 @@ void Wtt::menu_setup()
XtSetValues( menu_change_value_w, nosensitive, 1);
}
break;
case wb_eType_Buffer:
if ( editmode)
{
XtSetValues( menu_save_w, sensitive, 1);
XtSetValues( menu_revert_w, nosensitive, 1);
XtSetValues( menu_cut_w, sensitive, 1);
XtSetValues( menu_copy_w, sensitive, 1);
XtSetValues( menu_paste_w, sensitive, 1);
XtSetValues( menu_rename_w, sensitive, 1);
XtSetValues( menu_utilities_w, sensitive, 1);
XtSetValues( menu_openplc_w, nosensitive, 1);
XtSetValues( menu_compile_w, nosensitive, 1);
XtSetValues( menu_createload_w, nosensitive, 1);
XtSetValues( menu_createboot_w, nosensitive, 1);
XtSetValues( menu_distribute_w, nosensitive, 1);
XtSetValues( menu_change_value_w, sensitive, 1);
}
else
{
XtSetValues( menu_save_w, nosensitive, 1);
XtSetValues( menu_revert_w, nosensitive, 1);
XtSetValues( menu_cut_w, nosensitive, 1);
XtSetValues( menu_copy_w, nosensitive, 1);
XtSetValues( menu_paste_w, nosensitive, 1);
XtSetValues( menu_rename_w, nosensitive, 1);
XtSetValues( menu_utilities_w, sensitive, 1);
XtSetValues( menu_openplc_w, sensitive, 1);
XtSetValues( menu_compile_w, nosensitive, 1);
XtSetValues( menu_createload_w, nosensitive, 1);
XtSetValues( menu_createboot_w, nosensitive, 1);
XtSetValues( menu_distribute_w, nosensitive, 1);
XtSetValues( menu_change_value_w, nosensitive, 1);
}
break;
default:
;
}
......@@ -560,7 +603,7 @@ static void wtt_file_selected_cb( void *ctx, char *filename, wow_eFileSelType fi
Wtt *wtt = (Wtt *)ctx;
if ( wtt->open_volume_cb)
(wtt->open_volume_cb) ( wtt, filename, file_type);
(wtt->open_volume_cb) ( wtt, wb_eType_Volume, filename, file_type);
}
static void wtt_save_cb( void *ctx)
......@@ -1794,7 +1837,7 @@ static void wtt_activate_openvolume( Widget w, Wtt *wtt, XmAnyCallbackStruct *da
{
wtt->set_clock_cursor();
if ( wtt->open_volume_cb)
(wtt->open_volume_cb) ( wtt, NULL, wow_eFileSelType_All);
(wtt->open_volume_cb) ( wtt, wb_eType_Volume, NULL, wow_eFileSelType_All);
wtt->reset_cursor();
}
......@@ -3223,6 +3266,15 @@ Wtt::Wtt(
strcpy( title_w1, "Class Configuration");
strcpy( title_w2, "Node Configuration");
break;
case pwr_eClass_VolatileVolume:
wb_type = wb_eType_Buffer;
strcpy( layout_w1, "");
strcpy( layout_w2, "");
strcpy( layout_palette, "NavigatorPalette");
strcpy( title_w1, "Plant Configuration");
strcpy( title_w2, "Node Configuration");
sprintf( title, "PwR Navigator Buffer %s, %s", volname, name);
break;
default:
wb_type = wb_eType_Volume;
strcpy( layout_w1, "NavigatorW1");
......@@ -3338,6 +3390,7 @@ Wtt::Wtt(
wnav->get_global_select_cb = wtt_get_global_select_cb;
wnav->global_unselect_objid_cb = wtt_global_unselect_objid_cb;
wnav->set_window_char_cb = wtt_set_window_char_cb;
wnav->open_vsel_cb = wtt_open_vsel_cb;
focused_wnav = wnav;
wnav_mapped = 1;
......@@ -3368,6 +3421,7 @@ Wtt::Wtt(
wnavnode->get_global_select_cb = wtt_get_global_select_cb;
wnavnode->global_unselect_objid_cb = wtt_global_unselect_objid_cb;
wnavnode->set_window_char_cb = wtt_set_window_char_cb;
wnavnode->open_vsel_cb = wtt_open_vsel_cb;
i = 0;
XtSetArg(args[i], XmNheight, 300);i++;
......
......@@ -209,7 +209,7 @@ class Wtt {
pwr_tObjid input_objid;
wtt_eInputMode input_mode;
void (*close_cb)(void *ctx);
void (*open_volume_cb)(void *ctx, char *, wow_eFileSelType);
void (*open_volume_cb)(void *ctx, wb_eType, char *, wow_eFileSelType);
void (*open_project_volume_cb)(void *ctx);
int (*time_to_exit_cb)(void *ctx);
int set_focus_disabled;
......
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