Пример #1
0
    def __init__(self,
                 parent=None,
                 mode=None,
                 objectDict=None,
                 designModel=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(TPPropertyBox, self).__init__(parent)
        self.setupUi(self)
        self.parent = parent
        self.schemaModel = self.parent.schemaObject
        self.settings = QSettings()
        self.helper = Helper()
        self.designModel = designModel
        self.modelData = self.designModel.modelData
        if objectDict is None:
            self.objectDict = self.designModel.newPathTemplateDict()
        else:
            self.objectDict = objectDict
        self.mode = mode

        # get the class that controls the data grid for relationship templates
        self.CypherGenPath = CypherGenPath(parent=self,
                                           templateDict=self.objectDict)

        # get neocon object for this project page
        self.neoCon = NeoDriver(name=self.parent.pageItem.neoConName,
                                promptPW=self.parent.pageItem.promptPW)

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

        # add the data grid widget.
        self.nodeGrid = DataGridWidget(self,
                                       neoCon=self.neoCon,
                                       genCypher=self.CypherGenPath)
        self.nodeGridLayout = QVBoxLayout(self.dataTabFrame)
        self.nodeGridLayout.setObjectName("nodeGridLayout")
        self.nodeGridLayout.addWidget(self.nodeGrid)

        self.populatingMetaBox = False

        #populate ui data from object
        self.populateUIfromObject()

        if self.mode == "NEW":
            self.txtPathTemplateName.setFocus()
        else:
            # disable definition fields
            self.txtPathTemplateName.setEnabled(False)
Пример #2
0
    def __init__(self, parent=None, fileName=None, fileText=None, mode=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(CypherEditGridWidget, self).__init__(parent)
        self.setupUi(self)
        self.parent = parent
        self.settings = QSettings()
        self.initUI()
        self.initScintilla()
        self.helper = Helper()
        self.mode = mode
        self.tabType = "CYPHER"
        self.tabName = fileName
        self.tabIndex = None  # this is the index into the tabWidget of the tab this widget is on
        self.fileName = fileName
        self.fileText = fileText
        self.resultSet = None

        # create a neocon object for this file tab
        self.neoDriver = NeoDriver(name=self.parent.pageItem.neoConName,
                                   promptPW=self.parent.pageItem.promptPW)

        # add the data grid widget.
        self.dataGridGeneric = DataGridGeneric()
        self.dataGrid = DataGridWidget(self,
                                       neoCon=self.neoDriver,
                                       genCypher=self.dataGridGeneric)
        self.nodeGridLayout = QVBoxLayout(self.frmDataGrid)
        self.nodeGridLayout.setObjectName("nodeGridLayout")
        self.nodeGridLayout.setContentsMargins(1, 1, 1, 1)
        self.nodeGridLayout.setSpacing(1)
        self.nodeGridLayout.addWidget(self.dataGrid)

        if self.mode == MODENEW:
            if not self.fileText is None:
                self.loadText()

        if self.mode == MODEEDIT:
            self.loadFile()

        # position the splitter
        self.show(
        )  # you have to do this to force all the widgets sizes to update
        half = int((self.frmEditnGrid.height() / 2))
        self.splitter.setSizes([half, half])
Пример #3
0
    def __init__(self, parent=None, rightClickPos=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(CopyNodeToDiagramDlg, self).__init__(parent)
        self.setupUi(self)
        self.parent = parent
        self.settings = QSettings()
        self.rightClickPos = rightClickPos
        self.designModel = self.parent.model
        self.syncNeoCon = self.designModel.modelNeoCon
        self.itemDict = self.parent.itemDict
        self.helper = Helper()
        self.neoTypeFunc = NeoTypeFunc()
        self.nodeGrid = None

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

        # load  node template dropdown and disable it
        dropdownList = []
        dropdownList.append("No Template Selected")
        dropdownList.extend(
            sorted(self.designModel.instanceList("Node Template")))
        self.cboNodeTemplates.addItems(dropdownList)
        self.rbFilterTemplate.setChecked(True)

        # get neocon object for this project page
        self.neoCon = NeoDriver(name=self.parent.parent.pageItem.neoConName,
                                promptPW=self.parent.parent.pageItem.promptPW)

        # add the data grid widget.
        self.addNodeCypher = AddNodeCypher()

        self.nodeGrid = DataGridWidget(self,
                                       neoCon=self.neoCon,
                                       genCypher=self.addNodeCypher)
        self.nodeGridLayout = QVBoxLayout(self.frmDataGrid)
        self.nodeGridLayout.setObjectName("nodeGridLayout")
        self.nodeGridLayout.addWidget(self.nodeGrid)
Пример #4
0
 def resetPassword(self):
     '''login to Neo4j and reset the password
     '''
     # get the currently selected schema tab's neocon name
     newConName = self.parent.pageItem.neoConName
     # get the neocon dictionary from settings
     newConDict = self.settings.value("NeoCon/connection/{}".format(newConName))
     newConDict["userid"]=self.editUserID.text()
     savePW = self.helper.putText(self.editPW.text())
     newConDict["password"]=savePW
     # create a new neoCon using the userid/password the person entered on this form
     self.newNeoCon = NeoDriver(name=newConName,  neoDict = newConDict)
     
     QApplication.setOverrideCursor(Qt.WaitCursor)
     rc, msg = self.changePassword(userName=self.editUserID.text(), pw=self.editNewPW.text(), forceChange=False)
     if rc:
         self.helper.displayErrMsg("Change Password", msg)
     else:
         self.helper.displayErrMsg("Change Password Error", msg)
     QApplication.restoreOverrideCursor()         
Пример #5
0
    def __init__(self, parent=None, pageItem=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(CypherPageWidget, self).__init__(parent)
        self.pageType = "CYPHER"
        self.settings = QSettings()
        self.parent = parent
        self.pageItem = pageItem

        self.setupUi(self)
        self.initUI()
        self.helper = Helper()
        self.treeViewUpdate.connect(self.populateTree)

        ########################################################################
        # Schema editor setup
        ########################################################################
        self.schemaNeoDriver = NeoDriver(name=self.pageItem.neoConName,
                                         promptPW=self.pageItem.promptPW)

        self.schemaModel = SchemaModel(self, neoDriver=self.schemaNeoDriver)
        self.refreshSchemaModel()
        self.schemaModel.setUpdateTreeViewMethod(
            method=self.on_btnRefresh_clicked)
        self.tvSchema.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tvSchema.customContextMenuRequested.connect(self.openMenu)
        self.clearTree()
        self.populateTree()

        # display a default cypher tab
        self.on_btnNew_clicked()

        # display an error message if the schema connection doesn't work
        rc, msg = self.schemaModel.testSchemaConnection()
        if rc == False:
            self.helper.displayErrMsg("Connect Schema",
                                      "The Connection Failed: {}".format(msg))
Пример #6
0
    def initSettings(self, ):
        '''
        get the system settings needed to start NodeEra.
        If a system setting doesn't exist then create it with default value - this happens on initial startup
        '''
        self.settings = QSettings()
        try:
            self.expirationDate = self.helper.getText(
                self.settings.value("License/expirationDate"))
            if self.expirationDate is None:
                self.expirationDate = 'No expiration date set'
                self.settings.setValue(
                    "License/expirationDate",
                    self.helper.putText(self.expirationDate))
        except:
            self.expirationDate = 'No expiration date set'
            self.settings.setValue("License/expirationDate",
                                   self.helper.putText(self.expirationDate))

        try:
            self.currentVersion = self.settings.value("License/currentVersion")
            if self.currentVersion is None:
                self.currentVersion = currentVersion
                self.settings.setValue("License/currentVersion",
                                       self.currentVersion)
            elif self.currentVersion != currentVersion:
                self.currentVersion = currentVersion
                self.settings.setValue("License/currentVersion",
                                       self.currentVersion)
        except:
            self.currentVersion = currentVersion
            self.settings.setValue("License/currentVersion",
                                   self.currentVersion)

        try:
            self.winSize = self.settings.value("MainWindow/Size")
            if self.winSize is None:
                self.winSize = QSize(800, 500)
        except:
            self.winSize = QSize(800, 500)

        try:
            self.position = self.settings.value("MainWindow/Position")
            if self.position is None:
                self.position = QPoint(0, 0)
        except:
            self.position = QPoint(0, 0)

        try:
            self.recentList = self.settings.value("Default/RecentList")
            if self.recentList is None:
                self.recentList = []
                self.settings.setValue("Default/RecentList", self.recentList)
        except:
            self.recentList = []
            self.settings.setValue("Default/RecentList", self.recentList)

        try:
            self.defaultLoggingPath = self.settings.value(
                "Default/LoggingPath")
            if self.defaultLoggingPath is None:
                self.logDir = os.getcwd()
                self.logDir = os.path.realpath(os.path.abspath(self.logDir))
                self.settings.setValue("Default/LoggingPath", self.logDir)
        except:
            self.logDir = os.getcwd()
            self.logDir = os.path.realpath(os.path.abspath(self.logDir))
            self.settings.setValue("Default/LoggingPath", self.logDir)

        try:
            self.defaultProjPath = self.settings.value("Default/ProjPath")
            if self.defaultProjPath is None:
                self.defaultProjPath = os.getcwd()
                self.defaultProjPath = os.path.realpath(
                    os.path.abspath(self.defaultProjPath))
                self.settings.setValue("Default/ProjectPath",
                                       self.defaultProjPath)
        except:
            self.defaultProjPath = os.getcwd()
            self.defaultProjPath = os.path.realpath(
                os.path.abspath(self.defaultProjPath))
            self.settings.setValue("Default/ProjectPath", self.defaultProjPath)

        # default custom formats for diagram objects
        # Display Format - Instance Node
        try:
            test = self.settings.value("Default/Format/InstanceNode")
            if test is None:
                self.settings.setValue("Default/Format/InstanceNode",
                                       INodeFormat().formatDict)
        except:
            self.settings.setValue("Default/Format/InstanceNode",
                                   INodeFormat().formatDict)

        # Display Format - Instance Relationship
        try:
            test = self.settings.value("Default/Format/InstanceRelation")
            if test is None:
                self.settings.setValue("Default/Format/InstanceRelation",
                                       IRelFormat().formatDict)
        except:
            self.settings.setValue("Default/Format/InstanceRelation",
                                   IRelFormat().formatDict)

        # Display Format - Template Node
        try:
            test = self.settings.value("Default/Format/TemplateNode")
            if test is None:
                self.settings.setValue("Default/Format/TemplateNode",
                                       TNodeFormat().formatDict)
        except:
            self.settings.setValue("Default/Format/TemplateNode",
                                   TNodeFormat().formatDict)

        # Display Format - Template Relationship
        try:
            test = self.settings.value("Default/Format/TemplateRelation")
            if test is None:
                self.settings.setValue("Default/Format/TemplateRelation",
                                       TRelFormat().formatDict)
        except:
            self.settings.setValue("Default/Format/TemplateRelation",
                                   TRelFormat().formatDict)

        # page setup
        try:
            test = self.settings.value("Default/PageSetup")
            if test is None:
                self.settings.setValue("Default/PageSetup",
                                       PageSetup().objectDict)
        except:
            self.settings.setValue("Default/PageSetup", PageSetup().objectDict)

        # default project neocon
        try:
            defaultNeoConName = self.settings.value("NeoCon/Default")
            if defaultNeoConName is None:
                self.settings.setValue("NeoCon/Default", "LOCAL")
        except:
            self.settings.setValue("NeoCon/Default", "LOCAL")

        # LOCAL neocon definition
        try:
            self.localNeoCon = self.settings.value("NeoCon/connection/LOCAL")
            if self.localNeoCon is None:
                self.settings.setValue("NeoCon/connection/LOCAL",
                                       NeoDriver().localNeoConDict())
        except:
            self.settings.setValue("NeoCon/connection/LOCAL",
                                   NeoDriver().localNeoConDict())

        # default lexer font size
        try:
            defaultLexerFontSize = self.settings.value("Lexer/FontSize")
            if defaultLexerFontSize is None:
                self.settings.setValue("Lexer/FontSize", "10")
        except:
            self.settings.setValue("Lexer/FontSize", "10")

        # validate all neocons have the prompt dictionary key which was added in 1.04
        self.settings.beginGroup("NeoCon/connection")
        neoKeys = self.settings.childKeys()
        for key in neoKeys:
            neoDict = self.settings.value(key)
            promptVal = neoDict.get("prompt", None)
            if promptVal is None:
                neoDict["prompt"] = "False"
                self.settings.setValue(key, neoDict)

        self.settings.endGroup()
Пример #7
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)