Example #1
0
void ConstraintWidget::removeColumns(void)
{
	if(sender()==columns_tab)
		updateColumnsCombo(Constraint::SOURCE_COLS);
	else
		updateColumnsCombo(Constraint::REFERENCED_COLS);
}
Example #2
0
void TriggerWidget::setAttributes(DatabaseModel *model, Table *parent_table, OperationList *op_list, Trigger *trigger)
{
	unsigned count=0, i;
	Column *column=NULL;

	if(!parent_table)
		throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	BaseObjectWidget::setAttributes(model, op_list, trigger, parent_table);

	ref_table_sel->setModel(model);
	function_sel->setModel(model);

	if(trigger)
	{
		constr_trig_chk->setChecked(trigger->getReferencedTable());
		cond_expr_txt->setPlainText(Utf8String::create(trigger->getCondition()));
		deferrable_chk->setChecked(trigger->isDeferrable());
		deferral_type_cmb->setCurrentIndex(deferral_type_cmb->findText(~trigger->getDeferralType()));
		firing_mode_cmb->setCurrentIndex(firing_mode_cmb->findText(~trigger->getFiringType()));

		insert_chk->setChecked(trigger->isExecuteOnEvent(EventType::on_insert));
		delete_chk->setChecked(trigger->isExecuteOnEvent(EventType::on_delete));
		update_chk->setChecked(trigger->isExecuteOnEvent(EventType::on_update));
		truncate_chk->setChecked(trigger->isExecuteOnEvent(EventType::on_truncate));
		ref_table_sel->setSelectedObject(trigger->getReferencedTable());
		function_sel->setSelectedObject(trigger->getFunction());

		columns_tab->blockSignals(true);
		arguments_tab->blockSignals(true);

		count=trigger->getColumnCount();
		for(i=0; i < count; i++)
		{
			column=trigger->getColumn(i);
			columns_tab->addRow();
			addColumn(column, i);
		}

		count=trigger->getArgumentCount();
		for(i=0; i < count; i++)
		{
			arguments_tab->addRow();
			arguments_tab->setCellText(trigger->getArgument(i), i, 0);
		}

		columns_tab->enableButtons(ObjectTableWidget::ADD_BUTTON, (column_cmb->count()!=0));
		arguments_tab->blockSignals(false);
		columns_tab->blockSignals(false);
	}

	updateColumnsCombo();
}
Example #3
0
void ConstraintWidget::selectReferencedTable(void)
{
	Table *table=dynamic_cast<Table *>(ref_table_sel->getSelectedObject());

	if(!table)
	{
		ref_column_cmb->clear();
		ref_columns_tab->blockSignals(true);
		ref_columns_tab->removeRows();
		ref_columns_tab->setEnabled(false);
		ref_columns_tab->blockSignals(false);
	}
	else
	{
		ref_columns_tab->setEnabled(true);
		updateColumnsCombo(Constraint::REFERENCED_COLS);
	}
}
Example #4
0
void IndexWidget::setAttributes(DatabaseModel *model, Table *parent_obj, OperationList *op_list, Index *index)
{
	unsigned i, count;

	if(!parent_obj)
		throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	BaseObjectWidget::setAttributes(model, op_list, index, parent_obj);

	op_class_sel->setModel(model);
	updateColumnsCombo();

	if(index)
	{
		indexing_cmb->setCurrentIndex(indexing_cmb->findText(~index->getIndexingType()));

		fill_factor_chk->setChecked(index->getFillFactor() >= 10);

		if(fill_factor_chk->isChecked())
			fill_factor_sb->setValue(index->getFillFactor());
		else
			fill_factor_sb->setValue(90);

		concurrent_chk->setChecked(index->getIndexAttribute(Index::CONCURRENT));
		fast_update_chk->setChecked(index->getIndexAttribute(Index::FAST_UPDATE));
		unique_chk->setChecked(index->getIndexAttribute(Index::UNIQUE));
		cond_expr_txt->setPlainText(Utf8String::create(index->getConditionalExpression()));

		elements_tab->blockSignals(true);
		count=index->getElementCount();
		for(i=0; i < count; i++)
		{
			elements_tab->addRow();
			showElementData(index->getElement(i), i);
		}
		elements_tab->blockSignals(false);

		selectIndexingType();
	}
}
Example #5
0
void ConstraintWidget::setAttributes(DatabaseModel *model, BaseObject *parent_obj, OperationList *op_list, Constraint *constr)
{
	ObjectType obj_type;
	unsigned count, i, row;
	Column *column=nullptr;
	Table *ref_table=nullptr;
	vector<ExcludeElement> excl_elems;

	if(!parent_obj)
		throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	obj_type=parent_obj->getObjectType();
	if(obj_type!=OBJ_TABLE && obj_type!=OBJ_RELATIONSHIP)
		throw Exception(ERR_OPR_OBJ_INV_TYPE,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	BaseObjectWidget::setAttributes(model, op_list, constr, parent_obj);

	info_frm->setVisible(this->table!=nullptr);
	ref_table_sel->setModel(model);

	if(this->table)
		count=table->getObjectCount(OBJ_COLUMN);
	else
		count=relationship->getAttributeCount();

	columns_tab->blockSignals(true);
	for(i=0, row=0; i < count; i++)
	{
		if(this->table)
			column=dynamic_cast<Column *>(table->getObject(i, OBJ_COLUMN));
		else
			column=relationship->getAttribute(i);

		if(constr && constr->isColumnExists(column, Constraint::SOURCE_COLS))
		{
			columns_tab->addRow();
			addColumn(column, Constraint::SOURCE_COLS, row);
			row++;
		}
	}

	updateColumnsCombo(Constraint::SOURCE_COLS);
	columns_tab->setButtonsEnabled(ObjectTableWidget::ADD_BUTTON, (column_cmb->count()!=0));
	columns_tab->blockSignals(false);

	if(constr)
	{
		excl_elems = constr->getExcludeElements();

		indexing_chk->setChecked(constr->getIndexType()!=BaseType::null);
		indexing_cmb->setCurrentIndex(indexing_cmb->findText(~constr->getIndexType()));

		constr_type_cmb->setCurrentIndex(constr_type_cmb->findText(~constr->getConstraintType()));
		constr_type_cmb->setEnabled(false);
		constr_type_lbl->setEnabled(false);

    expression_txt->setPlainText(constr->getExpression());
		no_inherit_chk->setChecked(constr->isNoInherit());
		deferrable_chk->setChecked(constr->isDeferrable());
		deferral_cmb->setCurrentIndex(deferral_cmb->findText(~constr->getDeferralType()));
		match_cmb->setCurrentIndex(match_cmb->findText(~constr->getMatchType()));
		on_delete_cmb->setCurrentIndex(on_delete_cmb->findText(~constr->getActionType(Constraint::DELETE_ACTION)));
		on_update_cmb->setCurrentIndex(on_update_cmb->findText(~constr->getActionType(Constraint::UPDATE_ACTION)));

		fill_factor_chk->setChecked(constr->getFillFactor()!=0);
		if(fill_factor_chk->isChecked())
		 fill_factor_sb->setValue(constr->getFillFactor());

		ref_table=dynamic_cast<Table *>(constr->getReferencedTable());
		if(ref_table)
		{
			ref_columns_tab->blockSignals(true);
			ref_table_sel->setSelectedObject(ref_table);

			count=ref_table->getColumnCount();
			for(i=0, row=0; i < count; i++)
			{
				column=ref_table->getColumn(i);
				if(constr->isColumnExists(column, Constraint::REFERENCED_COLS))
				{
					ref_columns_tab->addRow();
					addColumn(column, Constraint::REFERENCED_COLS, row);
					row++;
				}
			}

			updateColumnsCombo(Constraint::REFERENCED_COLS);
			ref_columns_tab->setButtonsEnabled(ObjectTableWidget::ADD_BUTTON, (column_cmb->count()!=0));
			ref_columns_tab->blockSignals(false);
		}
	}

	excl_elems_wgt->setAttributes(model, parent_obj, excl_elems);
}
Example #6
0
void ConstraintWidget::setAttributes(DatabaseModel *model, BaseObject *parent_obj, OperationList *op_list, Constraint *constr)
{
	ObjectType obj_type;
	unsigned count, i, row;
	Column *column=NULL;
	Table *ref_table=NULL;

	if(!parent_obj)
		throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	BaseObjectWidget::setAttributes(model, op_list, constr, parent_obj);

	info_frm->setVisible(this->table!=NULL);
	ref_table_sel->setModel(model);

	obj_type=parent_obj->getObjectType();

	if(obj_type==OBJ_TABLE)
		count=table->getColumnCount();
	else
		count=relationship->getAttributeCount();

	columns_tab->blockSignals(true);
	for(i=0, row=0; i < count; i++)
	{
		if(obj_type==OBJ_TABLE)
			column=table->getColumn(i);
		else
			column=relationship->getAttribute(i);

		if(constr && constr->isColumnExists(column, Constraint::SOURCE_COLS))
		{
			columns_tab->addRow();
			addColumn(column, Constraint::SOURCE_COLS, row);
			row++;
		}
	}

	updateColumnsCombo(Constraint::SOURCE_COLS);
	columns_tab->setButtonsEnabled(ObjectTableWidget::ADD_BUTTON, (column_cmb->count()!=0));
	columns_tab->blockSignals(false);

	if(constr)
	{
		constr_type_cmb->setCurrentIndex(constr_type_cmb->findText(~constr->getConstraintType()));
		constr_type_cmb->setEnabled(false);
		constr_type_lbl->setEnabled(false);

		check_expr_txt->setPlainText(Utf8String::create(constr->getCheckExpression()));
		deferrable_chk->setChecked(constr->isDeferrable());
		deferral_cmb->setCurrentIndex(deferral_cmb->findText(~constr->getDeferralType()));
		match_cmb->setCurrentIndex(match_cmb->findText(~constr->getMatchType()));
		fill_factor_sb->setValue(constr->getFillFactor());
		on_delete_cmb->setCurrentIndex(on_delete_cmb->findText(~constr->getActionType(false)));
		on_update_cmb->setCurrentIndex(on_update_cmb->findText(~constr->getActionType(true)));

		ref_table=dynamic_cast<Table *>(constr->getReferencedTable());
		if(ref_table)
		{
			ref_columns_tab->blockSignals(true);
			ref_table_sel->setSelectedObject(ref_table);

			count=ref_table->getColumnCount();
			for(i=0, row=0; i < count; i++)
			{
				column=ref_table->getColumn(i);
				if(constr->isColumnExists(column, Constraint::REFERENCED_COLS))
				{
					ref_columns_tab->addRow();
					addColumn(column, Constraint::REFERENCED_COLS, row);
					row++;
				}
			}

			updateColumnsCombo(Constraint::REFERENCED_COLS);
			ref_columns_tab->setButtonsEnabled(ObjectTableWidget::ADD_BUTTON, (column_cmb->count()!=0));
			ref_columns_tab->blockSignals(false);
		}
	}
}