Ejemplo n.º 1
0
    def initUI(self, ):

        # property grid
        self.gridProps.setSortingEnabled(False)
        self.gridProps.setModel(self.createPropModel())
        self.gridProps.setSortingEnabled(False)
        comboPropList = [""]
        comboPropList.extend(
            sorted(
                set(
                    self.model.instanceList("Property") +
                    self.schemaModel.instanceList("Property"))))
        dataTypeList = [dataType.value for dataType in DataType]
        self.gridProps.setItemDelegate(NeoEditDelegate(self))
        self.gridProps.setItemDelegateForColumn(
            DATATYPE, CBDelegate(self, dataTypeList, setEditable=False))
        self.gridProps.setItemDelegateForColumn(
            PROPERTY, CBDelegate(self, comboPropList, setEditable=True))
        self.gridProps.setColumnWidth(PROPERTY, 200)
        self.gridProps.setColumnWidth(DATATYPE, 125)
        self.gridProps.setColumnWidth(VALUE, 300)
        self.gridProps.setSelectionBehavior(QAbstractItemView.SelectItems)
        self.gridProps.setSelectionMode(QAbstractItemView.SingleSelection)
        header = self.gridProps.horizontalHeader()
        header.setSectionResizeMode(PROPERTY, QHeaderView.Interactive)
        header.setSectionResizeMode(DATATYPE, QHeaderView.Fixed)
        header.setSectionResizeMode(VALUE, QHeaderView.Stretch)
Ejemplo n.º 2
0
    def initPage(self, ):

        # header area
        self.txtDiagramName.setText(self.objectName)  
        self.txtNeoCon.setText("{} - {}".format( self.syncNeoCon.name, self.syncNeoCon.neoDict["URL"]))

        # action grid
#        ITEMTYPE, DIAGRAMITEM, GRAPHDBITEM, MATCH, ACTION
        self.gridSyncActions.setModel(self.createSyncActionModel())
        self.gridSyncActions.setColumnWidth(ITEMKEY, 50)
        self.gridSyncActions.setColumnWidth(ITEMTYPE, 125)
        self.gridSyncActions.setColumnWidth(DIAGRAMITEM, 400)
        self.gridSyncActions.setColumnWidth(ACTION, 120)
        self.gridSyncActions.setColumnWidth(GRAPHDBITEM, 400)
        self.gridSyncActions.setColumnWidth(MATCH, 80)
        
        self.gridSyncActions.setItemDelegateForColumn(ACTION, CBDelegate(self, [SYNCTO,SYNCNONE,SYNCFROM] ))
        header = self.gridSyncActions.horizontalHeader()
        header.setSectionResizeMode(ITEMKEY, QHeaderView.Fixed)  
        header.setSectionResizeMode(ITEMTYPE, QHeaderView.Fixed)  
        header.setSectionResizeMode(DIAGRAMITEM, QHeaderView.Interactive)
        header.setSectionResizeMode(GRAPHDBITEM, QHeaderView.Interactive)  
        header.setSectionResizeMode(MATCH, QHeaderView.Fixed)  
        header.setSectionResizeMode(ACTION, QHeaderView.Fixed)  
        header.setHighlightSections(False)
Ejemplo n.º 3
0
    def __init__(self, parent=None, mode=None, objectDict=None, designModel = None):
        """
        objectDict - Relationship Template object dictionary. For creating a new Relationship Template this will be None
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(TRPropertyBox, self).__init__(parent)
        self.parent = parent
        self.schemaModel = self.parent.schemaObject 
        self.settings = QSettings()
        self.formatChanged = False
        self.helper = Helper()
        self.setupUi(self)
        self.designModel = designModel
        self.modelData = self.designModel.modelData
        if objectDict is None:
            self.objectDict = self.designModel.newRelTemplateDict()
        else:
            self.objectDict = objectDict
        self.mode = mode
        
        # get the class that controls the data grid for relationship templates
        self.RelTemplateCypher = RelTemplateCypher(templateDict=self.objectDict)
        
        # get neocon object for this project page
        self.neoCon = NeoDriver(name=self.parent.pageItem.neoConName, promptPW=self.parent.pageItem.promptPW)
        
        # Properties Grid
        self.gridProps.setModel(self.createPropModel())
        comboPropList = [""] 
        comboPropList.extend(sorted(set(self.designModel.instanceList("Property") + self.schemaModel.instanceList("Property"))))
        
        dataTypeList = [dataType.value for dataType in DataType]
        self.gridProps.setItemDelegateForColumn(DATATYPE, CBDelegate(self, dataTypeList, setEditable=False ))

        self.gridProps.setItemDelegateForColumn(PROPERTY, CBDelegate(self, comboPropList, setEditable=True ))
        self.gridProps.setItemDelegateForColumn(PROPDEF, NeoEditDelegate(self))
        self.gridProps.setColumnWidth(PROPERTY, 350)
        self.gridProps.setColumnWidth(DATATYPE, 125)       
        self.gridProps.setColumnWidth(PROPREQ, 100)
        self.gridProps.setColumnWidth(PROPDEF, 150)
        self.gridProps.setColumnWidth(EXISTS, 100)
        self.gridProps.setSelectionBehavior(QAbstractItemView.SelectItems) 
        self.gridProps.setSelectionMode(QAbstractItemView.SingleSelection)

        header = self.gridProps.horizontalHeader()
        header.setSectionResizeMode(PROPERTY, QHeaderView.Interactive)  
        header.setSectionResizeMode(DATATYPE, QHeaderView.Fixed)  
        header.setSectionResizeMode(PROPREQ, QHeaderView.Fixed) 
        header.setSectionResizeMode(PROPDEF, QHeaderView.Interactive)  
        header.setSectionResizeMode(EXISTS, QHeaderView.Fixed)

        # constraints grid
        self.gridConstraints.setModel(self.createConstraintsModel())
        conTypeList = ["Property Exists"]
        self.gridConstraints.setItemDelegateForColumn(CONTYPE, CBDelegate(self, conTypeList, setEditable=False ))      
        self.gridConstraints.setColumnWidth(CONTYPE, 120)
        self.gridConstraints.setColumnWidth(CONPROP, 350)
        header = self.gridConstraints.horizontalHeader()
         
        header.setSectionResizeMode(CONTYPE, QHeaderView.Fixed) 
        header.setSectionResizeMode(CONPROP, QHeaderView.Interactive)
        
        # populate the rel template dropdowns
        self.loadTemplateDropdowns()
        
        # add the data grid widget.  
        self.relGrid = DataGridWidget(self, neoCon=self.neoCon, genCypher=self.RelTemplateCypher)
        self.relGridLayout = QVBoxLayout(self.dataTabFrame)
        self.relGridLayout.setObjectName("relGridLayout")
        self.relGridLayout.addWidget(self.relGrid)    
        
        #populate ui data from object
        self.populateUIfromObject()
        # populate combo boxes used on constraint and index grids
        self.updateComboBoxes()
        # sync definition checkboxes with constraints
        self.syncDefCheckBoxes()     
        
        if self.mode == "NEW":
            self.txtRelTemplateName.setFocus()               
        else: 
            # disable definition fields
            self.txtRelTemplateName.setEnabled(False)
            self.cboRelName.setEnabled(False)
            # disable from and to nodes if they have been defined
            if self.cmbFromTemplate.currentIndex() > 0:
                self.cmbFromTemplate.setEnabled(False)
            if self.cmbToTemplate.currentIndex() > 0:
                self.cmbToTemplate.setEnabled(False)
Ejemplo n.º 4
0
 def updateComboBoxes(self):
     propList = [""] + [ self.gridProps.model().item(row,PROPERTY).data(Qt.EditRole) for row in range(0,self.gridProps.model().rowCount())]
     self.gridConstraints.setItemDelegateForColumn(CONPROP, CBDelegate(self, propList, setEditable=True ))        
Ejemplo n.º 5
0
    def __init__(self, parent=None, model=None, name=None, tabType=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(PathTemplateTab, self).__init__(parent)
        self.setupUi(self)
        self.parent = parent
        self.model = model
        self.tabType = tabType
        self.tabName = name
        saveIndex, pathTemplateDict = self.model.getDictByName(
            topLevel=self.tabType, objectName=name)
        self.pathTemplateDict = pathTemplateDict
        self.helper = Helper()

        self.lastTreeViewWidgetItem = None

        # add cypher CypherEditGridWidget
        global unNamedFileCounter
        unNamedFileCounter = unNamedFileCounter + 1
        fileName = "{}".format("Unsaved-0{}".format(unNamedFileCounter))
        self.cypherEditGrid = CypherEditGridWidget(parent=parent,
                                                   fileName=fileName,
                                                   fileText="",
                                                   mode=MODENEW)
        self.frmDataGridLayout = QVBoxLayout(self.frmDataGrid)
        self.frmDataGridLayout.setObjectName("frmDataGridLayout")
        self.frmDataGridLayout.setContentsMargins(1, 1, 1, 1)
        self.frmDataGridLayout.setSpacing(1)
        self.frmDataGridLayout.addWidget(self.cypherEditGrid)

        # setup output grid model
        self.gridOutput.setModel(self.createOutputModel())
        self.gridOutput.setSelectionBehavior(QAbstractItemView.SelectItems)
        self.gridOutput.setSelectionMode(QAbstractItemView.SingleSelection)
        #        SOURCE, SOURCENAME, COLTYPE, COLVAL, COLNAME, DISPLAYIT, SORT, GROUP
        self.gridOutput.setColumnWidth(SOURCE, 200)
        self.gridOutput.setColumnWidth(SOURCENAME, 200)
        self.gridOutput.setColumnWidth(COLTYPE, 100)
        self.gridOutput.setColumnWidth(COLVAL, 200)
        self.gridOutput.setColumnWidth(COLNAME, 200)
        self.gridOutput.setColumnWidth(DISPLAYIT, 75)
        self.gridOutput.setColumnWidth(SORT, 75)
        self.gridOutput.setColumnWidth(GROUP, 75)
        # header
        header = self.gridOutput.horizontalHeader()
        header.setSectionResizeMode(SOURCE, QHeaderView.Interactive)
        header.setSectionResizeMode(SOURCENAME, QHeaderView.Interactive)
        header.setSectionResizeMode(COLTYPE, QHeaderView.Fixed)
        header.setSectionResizeMode(COLVAL, QHeaderView.Interactive)
        header.setSectionResizeMode(COLNAME, QHeaderView.Interactive)
        header.setSectionResizeMode(DISPLAYIT, QHeaderView.Fixed)
        header.setSectionResizeMode(SORT, QHeaderView.Fixed)
        header.setSectionResizeMode(GROUP, QHeaderView.Fixed)

        # column type
        colTypeList = ["", "Property", "Label", "Function"]
        self.gridOutput.setItemDelegateForColumn(
            COLTYPE, CBDelegate(self, colTypeList, setEditable=True))
        # sort
        sortList = ["No", "Ascending", "Descending"]
        self.gridOutput.setItemDelegateForColumn(
            SORT, CBDelegate(self, sortList, setEditable=True))
        # group
        groupList = ["No", "Yes"]
        self.gridOutput.setItemDelegateForColumn(
            GROUP, CBDelegate(self, groupList, setEditable=True))

        # path treeview setup
        self.tvPath.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tvPath.customContextMenuRequested.connect(self.openMenu)
        self.tvPath.setDragDropMode(QAbstractItemView.DragOnly)

        # initiliaze UI from pathTemplateDict
        self.initUI()