Kaydet (Commit) 9c4f3ce7 authored tarafından Gürer Özen's avatar Gürer Özen

model dosyası ile ilgili ufak bi tag değişikliği,

model editörü
üst cce72bbc
......@@ -605,11 +605,10 @@ Her bir ileti
yetki denetiminden geçmeden işleticiye geçmesine izin verilmemelidir.
\layout Standard
Yetki denetimi çağrıyı yapanın kimlik bilgileri ile, model üzerindeki her
noktada yapılır.
Yetki denetimi grup, sınıf ve metotlar üzerinde tanımlanabilmelidir.
Böylece bir kullanıcıya ayar değiştirme yetkisi vermeden bilgi sorma metotların
ı çağırma yetkisi verilebilmesi ya da bütün bir grubun yönetiminin basitçe
tek bir kullanıcıya verilmesi sağlanabilir.
ı çağırma yetkisi verilebilmesi ya da bütün bir grubun yönetiminin tek bir
kullanıcıya verilmesi kolayca tanımlanabilir.
\layout Standard
Görevleri sağlayan nesneler paralel olarak veya çağrı bir nesneye yönelikse
......
......@@ -55,7 +55,7 @@ Model Tan
tag) iermektedir.
\layout Section*
<model>
<comarModel>
\layout Standard
Model tanmlamasn kapsayan ana etikettir.
......
<?xml version='1.0'?>
<comar>
<model name='PARDUS'>
<comarModel name='PARDUS'>
<group name='System'>
<class name='Power'>
......@@ -50,5 +49,4 @@
</class>
</group>
</model>
</comar>
</comarModel>
......@@ -119,7 +119,7 @@ build_path(iks *g, iks *o, iks *m)
int
model_init(void)
{
iks *doc, *model;
iks *model;
iks *grp, *obj, *met;
int count = 0;
size_t size = 0;
......@@ -128,14 +128,13 @@ model_init(void)
int e;
// parse model file
e = iks_load(cfg_model_file, &doc);
e = iks_load(cfg_model_file, &model);
if (e) {
log_error("Cannot process model file '%s'\n", cfg_model_file);
return -1;
}
model = iks_find(doc, "model");
if (iks_strcmp(iks_name(doc), "comar") != 0 || model == NULL) {
if (iks_strcmp(iks_name(model), "comarModel") != 0) {
log_error("Not a COMAR model file '%s'\n", cfg_model_file);
return -1;
}
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. Please read the COPYING file.
#
from qt import *
class NodeEdit(QWidget):
def __init__(self, *args):
QWidget.__init__(self, *args)
vb = QVBoxLayout(self)
lab = QLabel("Name:", self)
vb.addWidget(lab)
self.name = QLineEdit(self)
vb.addWidget(self.name)
self.connect(self.name, SIGNAL("textChanged(const QString &)"), self._name_cb)
lab = QLabel("Description:", self)
vb.addWidget(lab)
self.desc = QTextEdit(self)
vb.addWidget(self.desc)
self.connect(self.desc, SIGNAL("textChanged()"), self._desc_cb)
self.node = None
def _name_cb(self, text):
if self.node:
self.node.nodeName = unicode(self.name.text())
def _desc_cb(self):
if self.node:
self.node.nodeDesc = unicode(self.desc.text())
def use_node(self, node):
self.node = None
self.name.setText(node.nodeName)
self.desc.setText(node.nodeDesc)
self.node = node
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. Please read the COPYING file.
#
from qt import *
import xml.dom.minidom as mdom
import codecs
import edit
def getByName(parent, childName):
return [x for x in parent.childNodes if x.nodeType == x.ELEMENT_NODE if x.tagName == childName]
def get_cdata(node, tag):
try:
c = getByName(node, tag)[0].firstChild.data
except:
c = ""
return c
class Node(QListViewItem):
MODEL = 0
CLASS = 1
GROUP = 2
METHOD = 3
def __init__(self, parent, type, name, data=None):
QListViewItem.__init__(self, parent, name)
self.nodeParent = parent
self.nodeType = type
self.nodeName = name
if data is not None:
tmp = get_cdata(data, "description")
if tmp == "":
self.nodeDesc = ""
else:
tmp = tmp.strip(' \n')
tmp = tmp.split('\n')
L1 = len([x for x in tmp[0] if x == '\t'])
s = ""
for t in tmp:
L2 = len([x for x in t if x == '\t'])
if L1 <= L2:
s += t[L1:].rstrip('\t\n') + '\n'
else:
s += t
self.nodeDesc = s.rstrip('\t\n') + '\n'
else:
self.nodeDesc = ""
self.setOpen(True)
def text(self, column):
return self.nodeName
class Model(QHBox):
def __init__(self, *args):
QHBox.__init__(self, *args)
vb = QVBox(self)
self.list = QListView(vb)
list = self.list
list.setRootIsDecorated(True)
list.addColumn("System Model")
list.setSorting(-1)
self.connect(list, SIGNAL("selectionChanged()"), self._change)
hb = QHButtonGroup(vb)
self.bt_group = QPushButton("Group", hb)
self.connect(self.bt_group, SIGNAL("clicked()"), self._add_group)
self.bt_class = QPushButton("Class", hb)
self.connect(self.bt_class, SIGNAL("clicked()"), self._add_class)
self.bt_method = QPushButton("Method", hb)
self.connect(self.bt_method, SIGNAL("clicked()"), self._add_method)
self.clear()
self.editor = edit.NodeEdit(self)
def _change(self):
item = self.list.selectedItem()
if item is not None:
self.editor.use_node(item)
def _add_group(self):
Node(self.list_top, Node.GROUP, "(new_group)")
def _add_class(self):
item = self.list.selectedItem()
if item == None:
return
if item.parent() != self.list_top:
return
Node(item, Node.CLASS, "(new_class)")
def _add_method(self):
item = self.list.selectedItem()
if item == None:
return
if (item.parent() is None) or (item.parent().parent() != self.list_top):
return
Node(item, Node.METHOD, "(new_method)")
def clear(self):
self.list.clear()
self.list_top = Node(self.list, Node.MODEL, "Model")
def load(self, model_file):
self.clear()
doc = mdom.parse(model_file)
if doc.documentElement.tagName != "comarModel":
raise Exception("not a comar file")
for group in doc.getElementsByTagName("group"):
groupItem = Node(self.list_top, Node.GROUP, group.getAttribute("name"), group)
for class_ in group.getElementsByTagName("class"):
classItem = Node(groupItem, Node.CLASS, class_.getAttribute("name"), class_)
for method in class_.getElementsByTagName("method"):
Node(classItem, Node.METHOD, method.getAttribute("name"), method)
doc.unlink()
def save(self, model_file):
impl = mdom.getDOMImplementation()
doc = impl.createDocument(None, "comarModel", None)
g = self.list_top.firstChild()
while g:
ge = doc.createElement("group")
ge.setAttribute("name", g.nodeName)
doc.documentElement.appendChild(ge)
c = g.firstChild()
while c:
ce = doc.createElement("class")
ce.setAttribute("name", c.nodeName)
ge.appendChild(ce)
m = c.firstChild()
while m:
me = doc.createElement("method")
me.setAttribute("name", m.nodeName)
if m.nodeDesc:
n1 = doc.createTextNode(m.nodeDesc)
n2 = doc.createElement("description")
me.appendChild(n2)
n2.appendChild(n1)
ce.appendChild(me)
m = m.nextSibling()
c = c.nextSibling()
g = g.nextSibling()
f = codecs.open(model_file, 'w', "utf-8")
f.write(doc.toprettyxml())
f.close()
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-3.5.dtd">
<!-- Project file for project smed -->
<!-- Saved: 2005-08-13, 15:42:35 -->
<!-- Copyright (C) 2005 , -->
<Project version="3.5">
<Description></Description>
<Author></Author>
<EmaIl></EmaIl>
<Sources>
<Source>
<Name>smed.py</Name>
</Source>
<Source>
<Name>model.py</Name>
</Source>
<Source>
<Name>edit.py</Name>
</Source>
</Sources>
<Forms>
</Forms>
<Translations>
</Translations>
<Interfaces>
</Interfaces>
<Others>
</Others>
<MainScript>
<Name>smed.py</Name>
</MainScript>
<Vcs>
<VcsType>Subversion</VcsType>
<VcsOptions>{'status': [''], 'log': [''], 'global': [''], 'update': [''], 'remove': [''], 'add': [''], 'tag': [''], 'export': [''], 'diff': [''], 'commit': [''], 'checkout': [''], 'history': ['']}</VcsOptions>
<VcsOtherData>{'standardLayout': 1}</VcsOtherData>
</Vcs>
</Project>
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. Please read the COPYING file.
#
import sys
from qt import *
import model
class MainWindow(QMainWindow):
def __init__(self, *args):
QMainWindow.__init__(self, *args)
self.setCaption(u"ÇOMAR System Model Editor")
self.setMinimumSize(540,320)
mb = self.menuBar()
file_ = QPopupMenu(self)
mb.insertItem("&File", file_)
file_.insertItem("&Open", self._cb_open, self.CTRL + self.Key_O)
file_.insertItem("&Save", self._cb_save, self.CTRL + self.Key_S)
file_.insertItem("Save &as...", self._cb_save_as, self.CTRL + self.SHIFT + self.Key_S)
file_.insertSeparator()
file_.insertItem("&Quit", main_quit, self.CTRL + self.Key_Q)
self.model = model.Model(self)
self.setCentralWidget(self.model)
self.fileName = None
def _cb_open(self):
name = QFileDialog.getOpenFileName(".", "Model Files (*.xml)", self, "lala", "Choose model file to open")
if not name:
return
name = unicode(name)
w.model.load(name)
self.fileName = name
def _cb_save_as(self):
name = QFileDialog.getSaveFileName(".", "Model Files (*.xml)", self, "lala", "Choose model file to save")
if not name:
return
name = unicode(name)
w.model.save(name)
self.fileName = name
def _cb_save(self):
if self.fileName:
w.model.save(self.fileName)
else:
self._cb_save_as()
def main_quit():
sys.exit(0)
if __name__ == "__main__":
app = QApplication(sys.argv)
app.connect(app, SIGNAL("lastWindowClosed()"), main_quit)
w = MainWindow()
w.show()
w.model.clear()
app.exec_loop()
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