Пример #1
0
 def popuplate_data_type_cbo(self):
     """
     Fills the data type combobox widget with BaseColumn type names
     """
     self.cboDataType.clear()
     self.cboDataType.insertItems(0,
                                  BaseColumn.types_by_display_name().keys())
     self.cboDataType.setCurrentIndex(0)
Пример #2
0
 def current_type_info(self):
     """
     Returns a TYPE_INFO of a data type
     :rtype: str
     """
     text = self.cboDataType.itemText(self.cboDataType.currentIndex())
     try:
         return BaseColumn.types_by_display_name()[text].TYPE_INFO
     except:
         return ''
Пример #3
0
 def current_type_info(self):
     """
     Returns a TYPE_INFO of a data type
     :rtype: str
     """
     text = self.cboDataType.itemText(self.cboDataType.currentIndex())
     try:
         return BaseColumn.types_by_display_name()[text].TYPE_INFO
     except:
         return ''
Пример #4
0
    def populate_data_type_cbo(self):
        """
        Fills the data type combobox widget with BaseColumn type names.
        """
        self.cboDataType.clear()

        for name, col in BaseColumn.types_by_display_name().iteritems():
            # Specify columns to exclude
            if col.TYPE_INFO not in self._exclude_col_type_info:
                self.cboDataType.addItem(name)

        if self.cboDataType.count() > 0:
            self.cboDataType.setCurrentIndex(0)
Пример #5
0
    def populate_data_type_cbo(self):
        """
        Fills the data type combobox widget with BaseColumn type names.
        """
        self.cboDataType.clear()

        for name, col in BaseColumn.types_by_display_name().iteritems():
            # Specify columns to exclude
            if col.TYPE_INFO not in self._exclude_col_type_info:
                self.cboDataType.addItem(name)

        if self.cboDataType.count() > 0:
            self.cboDataType.setCurrentIndex(0)
Пример #6
0
    def change_data_type(self, index):
        """
        Called by type combobox when you select a different data type.
        """

        #ti = self.current_type_info()
        #if ti=='':
        #return

        text = self.cboDataType.itemText(index)
        ti = BaseColumn.types_by_display_name()[text].TYPE_INFO

        self.btnColProp.setEnabled(self.type_attribs[ti].has_key('property'))
        self.type_info = ti
        opts = self.type_attribs[ti]
        self.set_optionals(opts)
        self.set_min_max_defaults(ti)
Пример #7
0
    def change_data_type(self, index):
        """
        Called by type combobox when you select a different data type.
        """
        text = self.cboDataType.itemText(index)
        ti = BaseColumn.types_by_display_name()[text].TYPE_INFO

        if ti not in self.type_attribs:
            msg = self.tr('Column type attributes could not be found.')
            self.notice_bar.clear()
            self.notice_bar.insertErrorNotification(msg)

            return

        self.btnColProp.setEnabled(self.type_attribs[ti].has_key('property'))
        self.type_info = ti
        opts = self.type_attribs[ti]
        self.set_optionals(opts)
        self.set_min_max_defaults(ti)
Пример #8
0
    def change_data_type(self, index):
        """
        Called by type combobox when you select a different data type.
        """
        text = self.cboDataType.itemText(index)
        col_cls = BaseColumn.types_by_display_name().get(text, None)
        if col_cls is None:
            return

        ti = col_cls.TYPE_INFO
        if ti not in self.type_attribs:
            msg = self.tr('Column type attributes could not be found.')
            self.notice_bar.clear()
            self.notice_bar.insertErrorNotification(msg)

            return

        self.btnColProp.setEnabled(self.type_attribs[ti].has_key('property'))
        self.type_info = ti
        opts = self.type_attribs[ti]
        self.set_optionals(opts)
        self.set_min_max_defaults(ti)
Пример #9
0
    def __init__(self, **kwargs):
        """
        :param parent: Owner of this dialog
        :type parent: QWidget
        :param kwargs: Keyword dictionary of the following parameters;
         column  - Column you editing, None if its a new column
         entity  - Entity you are adding the column to
         profile - Current profile
         in_db   - Boolean flag to indicate if a column has been created in 
                   the database
         auto_add- True to automatically add a new column to the entity, 
                   default is False.
        """

        self.form_parent = kwargs.get('parent', self)
        self.column = kwargs.get('column', None)
        self.entity = kwargs.get('entity', None)
        self.profile = kwargs.get('profile', None)
        self.in_db = kwargs.get('in_db', False)
        self.is_new = kwargs.get('is_new', True)
        self.auto_entity_add = kwargs.get('auto_add', False)

        QDialog.__init__(self, self.form_parent)

        self.FK_EXCLUDE = [u'supporting_document', u'admin_spatial_unit_set']

        self.EX_TYPE_INFO = [
            'SUPPORTING_DOCUMENT', 'SOCIAL_TENURE',
            'ADMINISTRATIVE_SPATIAL_UNIT', 'ENTITY_SUPPORTING_DOCUMENT',
            'VALUE_LIST', 'ASSOCIATION_ENTITY', 'AUTO_GENERATED'
        ]

        self.setupUi(self)
        self.dtypes = {}

        self.type_info = ''

        # dictionary to hold default attributes for each data type
        self.type_attribs = {}
        self.init_type_attribs()

        # dictionary to act as a work area for the form fields.
        self.form_fields = {}
        self.init_form_fields()

        self.fk_entities = []
        self.lookup_entities = []

        # Exclude column type info in the list
        self._exclude_col_type_info = []

        if self.is_new:
            self.prop_set = None  # why not False??
        else:
            self.prop_set = True

        # the current entity should not be part of the foreign key parent table,
        # add it to the exclusion list
        self.FK_EXCLUDE.append(self.entity.short_name)

        self.type_names = \
                [unicode(name) for name in BaseColumn.types_by_display_name().keys()]

        self.cboDataType.currentIndexChanged.connect(self.change_data_type)
        self.btnColProp.clicked.connect(self.data_type_property)
        self.edtColName.textChanged.connect(self.validate_text)

        self.notice_bar = NotificationBar(self.notif_bar)
        self.init_controls()
Пример #10
0
    def __init__(self, **kwargs):
        """
        :param parent: Owner of this dialog
        :type parent: QWidget
        :param kwargs: Keyword dictionary of the following parameters;
         column  - Column you editing, None if its a new column
         entity  - Entity you are adding the column to
         profile - Current profile
         in_db   - Boolean flag to indicate if a column has been created in 
                   the database
         auto_add- True to automatically add a new column to the entity, 
                   default is False.
        """
        
        self.form_parent = kwargs.get('parent', self)
        self.column  = kwargs.get('column', None)
        self.entity  = kwargs.get('entity', None)
        self.profile = kwargs.get('profile', None)
        self.in_db = kwargs.get('in_db', False)
        self.is_new = kwargs.get('is_new', True)
        self.auto_entity_add = kwargs.get('auto_add', False)

        QDialog.__init__(self, self.form_parent)

        self.FK_EXCLUDE = [u'supporting_document', u'admin_spatial_unit_set']

        self.EX_TYPE_INFO =  ['SUPPORTING_DOCUMENT', 'SOCIAL_TENURE', 
                'ADMINISTRATIVE_SPATIAL_UNIT', 'ENTITY_SUPPORTING_DOCUMENT',
                'VALUE_LIST', 'ASSOCIATION_ENTITY', 'AUTO_GENERATED']

        self.setupUi(self)
        self.dtypes = {}

        self.type_info = ''
        
        # dictionary to hold default attributes for each data type
        self.type_attribs = {}
        self.init_type_attribs()

        # dictionary to act as a work area for the form fields.
        self.form_fields = {}
        self.init_form_fields()

        self.fk_entities = []
        self.lookup_entities = []

        # Exclude column type info in the list
        self._exclude_col_type_info = []

        if self.is_new:
            self.prop_set = None  # why not False??
        else:
            self.prop_set = True

        # the current entity should not be part of the foreign key parent table,
        # add it to the exclusion list
        self.FK_EXCLUDE.append(self.entity.short_name)

        self.type_names = \
                [unicode(name) for name in BaseColumn.types_by_display_name().keys()]

        self.cboDataType.currentIndexChanged.connect(self.change_data_type)
        self.btnColProp.clicked.connect(self.data_type_property)
        self.edtColName.textChanged.connect(self.validate_text)

        self.notice_bar = NotificationBar(self.notif_bar)
        self.init_controls()