コード例 #1
0
ファイル: rulewidget.cpp プロジェクト: inghumberto/pgmodeler
void RuleWidget::applyConfiguration(void)
{
	try
	{
		Rule *rule=nullptr;
		unsigned count, i;

		startConfiguration<Rule>();

		rule=dynamic_cast<Rule *>(this->object);
		rule->setEventType(EventType(event_cmb->currentText()));
		rule->setExecutionType(ExecutionType(exec_type_cmb->currentText()));
		rule->setConditionalExpression(cond_expr_txt->toPlainText().toUtf8());
		rule->removeCommands();

		count=commands_tab->getRowCount();

		for(i=0; i < count; i++)
			rule->addCommand(commands_tab->getCellText(i,0).toUtf8());

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #2
0
ファイル: domainwidget.cpp プロジェクト: jorgenio/pgmodeler
void DomainWidget::applyConfiguration(void)
{
    try
    {
        Domain *domain=nullptr;
        startConfiguration<Domain>();

        domain=dynamic_cast<Domain *>(this->object);
        domain->setType(data_type->getPgSQLType());
        domain->setDefaultValue(def_value_edt->text());
        domain->setExpression(check_expr_txt->toPlainText());

        if(!constr_name_edt->text().isEmpty())
            domain->setConstraintName(constr_name_edt->text());

        domain->setNotNull(not_null_chk->isChecked());

        BaseObjectWidget::applyConfiguration();
        finishConfiguration();
    }
    catch(Exception &e)
    {
        cancelConfiguration();
        throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
    }
}
コード例 #3
0
void OperatorClassWidget::applyConfiguration(void)
{
	try
	{
		OperatorClass *op_class=nullptr;
		unsigned i, count;

		startConfiguration<OperatorClass>();

		op_class=dynamic_cast<OperatorClass *>(this->object);
		op_class->setDefault(op_class->isDefault());
		op_class->setFamily(dynamic_cast<OperatorFamily *>(family_sel->getSelectedObject()));
		op_class->setIndexingType(IndexingType(indexing_cmb->currentText()));
		op_class->setDataType(data_type->getPgSQLType());

		op_class->removeElements();
		count=elements_tab->getRowCount();

		for(i=0; i < count; i++)
			op_class->addElement(elements_tab->getRowData(i).value<OperatorClassElement>());

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #4
0
void DatabaseWidget::applyConfiguration(void)
{
	try
	{
		//Apply the basic configurations
		BaseObjectWidget::applyConfiguration();

		model->setAuthor(author_edt->text().toUtf8());
		model->setTemplateDB(templatedb_edt->text());

		if(encoding_cmb->currentIndex() > 0)
			model->setEncoding(EncodingType(encoding_cmb->currentText()));

		if(lccollate_cmb->currentIndex() > 0)
			model->setLocalization(LC_COLLATE, lccollate_cmb->currentText());
		else
			model->setLocalization(LC_COLLATE, "");

		if(lcctype_cmb->currentIndex() > 0)
			model->setLocalization(LC_CTYPE, lcctype_cmb->currentText());
		else
			model->setLocalization(LC_CTYPE, "");

		finishConfiguration();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #5
0
void EventTriggerWidget::applyConfiguration(void)
{
	try
	{
		EventTrigger *event_trig=nullptr;

		startConfiguration<EventTrigger>();
		event_trig=dynamic_cast<EventTrigger *>(this->object);
		BaseObjectWidget::applyConfiguration();

		event_trig->setEvent(EventTriggerType(event_cmb->currentText()));
		event_trig->setFunction(dynamic_cast<Function *>(function_sel->getSelectedObject()));

		event_trig->clearFilter();
		for(unsigned row=0; row < filter_tab->getRowCount(); row++)
			event_trig->setFilter(ParsersAttributes::TAG.toUpper(), filter_tab->getCellText(row, 0));

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #6
0
ファイル: castwidget.cpp プロジェクト: Halfnhav/pgmodeler
void CastWidget::applyConfiguration(void)
{
	try
	{
		Cast *cast=nullptr;

		startConfiguration<Cast>();

		cast=dynamic_cast<Cast *>(this->object);
		cast->setDataType(Cast::SRC_TYPE, src_datatype->getPgSQLType());
		cast->setDataType(Cast::DST_TYPE, trg_datatype->getPgSQLType());
		cast->setInOut(input_output_chk->isChecked());

		if(implicit_rb->isChecked())
			cast->setCastType(Cast::IMPLICIT);
		else
			cast->setCastType(Cast::ASSIGNMENT);

		cast->setCastFunction(dynamic_cast<Function*>(conv_func_sel->getSelectedObject()));

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #7
0
void TextboxWidget::applyConfiguration(void)
{
	try
	{
		Textbox *txtbox=nullptr;

		startConfiguration<Textbox>();

		txtbox=dynamic_cast<Textbox *>(this->object);
		txtbox->setComment(text_txt->toPlainText().toUtf8());
		txtbox->setTextAttribute(Textbox::ITALIC_TXT, italic_chk->isChecked());
		txtbox->setTextAttribute(Textbox::BOLD_TXT, bold_chk->isChecked());
		txtbox->setTextAttribute(Textbox::UNDERLINE_TXT, underline_chk->isChecked());
		txtbox->setTextColor(color_select_tb->palette().color(QPalette::Button));
		txtbox->setFontSize(font_size_sb->value());

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #8
0
ファイル: operatorwidget.cpp プロジェクト: K-Lean/pgmodeler
void OperatorWidget::applyConfiguration(void)
{
	try
	{
		unsigned i;
		Operator *oper=nullptr;
		startConfiguration<Operator>();

		oper=dynamic_cast<Operator *>(this->object);

		BaseObjectWidget::applyConfiguration();

		oper->setHashes(hashes_chk->isChecked());
		oper->setMerges(merges_chk->isChecked());

		for(i=Operator::LEFT_ARG; i <= Operator::RIGHT_ARG; i++)
			oper->setArgumentType(arg_types[i]->getPgSQLType(), i);

		for(i=Operator::FUNC_OPERATOR; i <= Operator::FUNC_RESTRICT; i++)
			oper->setFunction(dynamic_cast<Function *>(functions_sel[i]->getSelectedObject()), i);

		for(i=Operator::OPER_COMMUTATOR; i <= Operator::OPER_NEGATOR; i++)
			oper->setOperator(dynamic_cast<Operator *>(operators_sel[i]->getSelectedObject()), i);

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #9
0
void AggregateWidget::applyConfiguration(void)
{
	try
	{
		Aggregate *aggregate=nullptr;
		unsigned count, i;

		startConfiguration<Aggregate>();

		aggregate=dynamic_cast<Aggregate *>(this->object);
		aggregate->setInitialCondition(initial_cond_txt->toPlainText());
		aggregate->setStateType(state_type->getPgSQLType());

		aggregate->removeDataTypes();
		count=input_types_tab->getRowCount();

		for(i=0; i < count; i++)
			aggregate->addDataType(input_types_tab->getRowData(i).value<PgSQLType>());

		aggregate->setFunction(Aggregate::TRANSITION_FUNC, dynamic_cast<Function *>(transition_func_sel->getSelectedObject()));
		aggregate->setFunction(Aggregate::FINAL_FUNC, dynamic_cast<Function *>(final_func_sel->getSelectedObject()));
		aggregate->setSortOperator(dynamic_cast<Operator *>(sort_op_sel->getSelectedObject()));

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #10
0
void CollationWidget::applyConfiguration(void)
{
	try
	{
		Collation *collation=nullptr;

		startConfiguration<Collation>();

		collation=dynamic_cast<Collation *>(this->object);
		BaseObjectWidget::applyConfiguration();

		if(encoding_cmb->currentIndex() > 0)
			collation->setEncoding(EncodingType(encoding_cmb->currentText()));

		if(locale_cmb->currentIndex() > 0)
			collation->setLocale(locale_cmb->currentText());

		if(lccollate_cmb->currentIndex() > 0)
			collation->setLocalization(LC_COLLATE, lccollate_cmb->currentText());

		if(lcctype_cmb->currentIndex() > 0)
			collation->setLocalization(LC_CTYPE, lcctype_cmb->currentText());

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #11
0
ファイル: rolewidget.cpp プロジェクト: Tbxhs/pgmodeler
void RoleWidget::applyConfiguration(void)
{
	Role *role=NULL, *aux_role=NULL;
	unsigned count, i, type_id,
			role_types[3]={ Role::REF_ROLE, Role::MEMBER_ROLE, Role::ADMIN_ROLE };

	try
	{
		startConfiguration<Role>();

		role=dynamic_cast<Role *>(this->object);
		role->setSysid(sysid_sb->value());
		role->setConnectionLimit(conn_limit_sb->value());
		role->setPassword(passwd_edt->text());

		if(validity_chk->isChecked())
			role->setValidity(validity_dte->dateTime().toString("yyyy-MM-dd hh:mm"));
		else
			role->setValidity("");

		role->setOption(Role::OP_SUPERUSER, superusr_chk->isChecked());
		role->setOption(Role::OP_CREATEDB, create_db_chk->isChecked());
		role->setOption(Role::OP_CREATEROLE, create_user_chk->isChecked());
		role->setOption(Role::OP_ENCRYPTED, encrypt_pass_chk->isChecked());
		role->setOption(Role::OP_INHERIT, inh_perm_chk->isChecked());
		role->setOption(Role::OP_LOGIN, can_login_chk->isChecked());

		for(type_id=0; type_id < 3; type_id++)
		{
			count=members_tab[type_id]->getRowCount();
			if(count > 0) role->removeRoles(role_types[type_id]);

			for(i=0; i < count; i++)
			{
				aux_role=reinterpret_cast<Role *>(members_tab[type_id]->getRowData(i).value<void *>());
				role->addRole(role_types[type_id], aux_role);
			}
		}

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #12
0
ファイル: tagwidget.cpp プロジェクト: Fisiu/pgmodeler
void TagWidget::applyConfiguration(void)
{
	try
	{
    Tag *tag=nullptr;
    vector<BaseObject *> tagged_tabs;

    startConfiguration<Tag>();
    tag=dynamic_cast<Tag *>(this->object);

    BaseObjectWidget::applyConfiguration();

    tag->setElementColor(ParsersAttributes::TABLE_NAME, tab_name_color_tb->palette().color(QPalette::Button), Tag::FILL_COLOR1);
    tag->setElementColor(ParsersAttributes::TABLE_SCHEMA_NAME, sch_name_color_tb->palette().color(QPalette::Button), Tag::FILL_COLOR1);

    tag->setElementColors(ParsersAttributes::TABLE_TITLE,
                          QString("%1,%2,%3")
                          .arg(title_fcolor1_tb->palette().color(QPalette::Button).name())
                          .arg(title_fcolor2_tb->palette().color(QPalette::Button).name())
                          .arg(title_bcolor_tb->palette().color(QPalette::Button).name()));

    tag->setElementColors(ParsersAttributes::TABLE_BODY,
                          QString("%1,%2,%3")
                          .arg(body_fcolor1_tb->palette().color(QPalette::Button).name())
                          .arg(body_fcolor2_tb->palette().color(QPalette::Button).name())
                          .arg(body_bcolor_tb->palette().color(QPalette::Button).name()));

    tag->setElementColors(ParsersAttributes::TABLE_EXT_BODY,
                          QString("%1,%2,%3")
                          .arg(extbody_fcolor1_tb->palette().color(QPalette::Button).name())
                          .arg(extbody_fcolor2_tb->palette().color(QPalette::Button).name())
                          .arg(extbody_bcolor_tb->palette().color(QPalette::Button).name()));

    model->getObjectReferences(tag, tagged_tabs);
    while(!tagged_tabs.empty())
    {
      dynamic_cast<BaseTable *>(tagged_tabs.back())->setModified(true);
      tagged_tabs.pop_back();
    }

    finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #13
0
ファイル: triggerwidget.cpp プロジェクト: Bumanji/pgmodeler
void TriggerWidget::applyConfiguration(void)
{
	try
	{
		Trigger *trigger=NULL;
		unsigned i, count;
		Column *column=NULL;

		startConfiguration<Trigger>();

		trigger=dynamic_cast<Trigger *>(this->object);
		trigger->setFiringType(FiringType(firing_mode_cmb->currentText()));
		trigger->setExecutePerRow(exec_per_row_chk->isChecked());
		trigger->setDeferrable(deferrable_chk->isChecked());
		trigger->setDeferralType(DeferralType(deferral_type_cmb->currentText()));
		trigger->setCondition(cond_expr_txt->toPlainText());
		trigger->setFunction(dynamic_cast<Function *>(function_sel->getSelectedObject()));
		trigger->setReferecendTable(dynamic_cast<Table *>(ref_table_sel->getSelectedObject()));
		trigger->setEvent(EventType::on_insert, insert_chk->isChecked());
		trigger->setEvent(EventType::on_update, update_chk->isChecked());
		trigger->setEvent(EventType::on_delete, delete_chk->isChecked());
		trigger->setEvent(EventType::on_truncate, truncate_chk->isChecked());
		trigger->removeArguments();
		trigger->removeColumns();

		count=arguments_tab->getRowCount();
		for(i=0; i < count; i++)
			trigger->addArgument(arguments_tab->getCellText(i, 0));

		count=columns_tab->getRowCount();
		for(i=0; i < count; i++)
		{
			column=reinterpret_cast<Column *>(columns_tab->getRowData(i).value<void *>());
			trigger->addColumn(column);
		}

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #14
0
ファイル: parameterwidget.cpp プロジェクト: Bumanji/pgmodeler
void ParameterWidget::applyConfiguration(void)
{
	try
	{
		parameter.setIn(param_in_chk->isChecked());
		parameter.setOut(param_out_chk->isChecked());
		parameter.setDefaultValue(default_value_edt->text());
		parameter.setType(data_type->getPgSQLType());

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #15
0
ファイル: tablewidget.cpp プロジェクト: brucepc/pgmodeler
void TableWidget::applyConfiguration(void)
{
	try
	{
		Table *table=nullptr;

		if(!this->new_object)
			op_list->registerObject(this->object, Operation::OBJECT_MODIFIED);

		table=dynamic_cast<Table *>(this->object);
		table->setWithOIDs(with_oids_chk->isChecked());
		table->setGenerateAlterCmds(gen_alter_cmds_chk->isChecked());

		BaseObjectWidget::applyConfiguration();

		try
		{
			if(model->getRelationship(table, nullptr))
				model->validateRelationships();

			model->updateTableFKRelationships(table);
		}
		catch(Exception &e)
		{
			Messagebox msg_box;

			if(e.getErrorType()==ERR_INVALIDATED_OBJECTS)
				msg_box.show(e);
			else
				throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
		}

		op_list->finishOperationChain();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		op_list->ignoreOperationChain(true);
		this->cancelConfiguration();
		op_list->ignoreOperationChain(false);
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #16
0
void OperatorFamilyWidget::applyConfiguration(void)
{
	try
	{
		OperatorFamily *op_family=NULL;

		startConfiguration<OperatorFamily>();
		op_family=dynamic_cast<OperatorFamily *>(this->object);
		op_family->setIndexingType(IndexingType(indexing_cmb->currentText()));

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #17
0
ファイル: tablespacewidget.cpp プロジェクト: Ox0000/pgmodeler
void TablespaceWidget::applyConfiguration(void)
{
	try
	{
		Tablespace *tablespc=nullptr;

		startConfiguration<Tablespace>();

		tablespc=dynamic_cast<Tablespace *>(this->object);
		tablespc->setDirectory(directory_edt->text());
		BaseObjectWidget::applyConfiguration();

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #18
0
ファイル: tagwidget.cpp プロジェクト: InnovaMex/pgmodeler
void TagWidget::applyConfiguration(void)
{
	try
	{
		Tag *tag=nullptr;
    vector<BaseObject *> tagged_tabs;
		QStringList attribs={ ParsersAttributes::TABLE_TITLE, ParsersAttributes::TABLE_BODY,
													ParsersAttributes::TABLE_EXT_BODY };

    startConfiguration<Tag>();
    tag=dynamic_cast<Tag *>(this->object);

    BaseObjectWidget::applyConfiguration();

		tag->setElementColor(ParsersAttributes::TABLE_NAME, color_pickers[ParsersAttributes::TABLE_NAME]->getColor(0), Tag::FILL_COLOR1);
		tag->setElementColor(ParsersAttributes::TABLE_SCHEMA_NAME, color_pickers[ParsersAttributes::TABLE_SCHEMA_NAME]->getColor(0), Tag::FILL_COLOR1);

    for(auto &attr : attribs)
		{
			tag->setElementColors(attr,
														QString("%1,%2,%3")
														.arg(color_pickers[attr]->getColor(Tag::FILL_COLOR1).name())
														.arg(color_pickers[attr]->getColor(Tag::FILL_COLOR2).name())
														.arg(color_pickers[attr]->getColor(Tag::BORDER_COLOR).name()));
		}

    model->getObjectReferences(tag, tagged_tabs);
    while(!tagged_tabs.empty())
    {
      dynamic_cast<BaseTable *>(tagged_tabs.back())->setModified(true);
      tagged_tabs.pop_back();
    }

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #19
0
ファイル: extensionwidget.cpp プロジェクト: Ox0000/pgmodeler
void ExtensionWidget::applyConfiguration(void)
{
	try
	{
		Extension *extension=nullptr;

		startConfiguration<Extension>();
		extension=dynamic_cast<Extension *>(this->object);
		BaseObjectWidget::applyConfiguration();
		extension->setHandlesType(handles_type_chk->isChecked());
		extension->setVersion(Extension::CUR_VERSION, cur_ver_edt->text());
		extension->setVersion(Extension::OLD_VERSION, old_ver_edt->text());

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #20
0
ファイル: databasewidget.cpp プロジェクト: Ox0000/pgmodeler
void DatabaseWidget::applyConfiguration(void)
{
	try
	{
		//Apply the basic configurations
		BaseObjectWidget::applyConfiguration();

		model->setAuthor(author_edt->text().toUtf8());
		model->setTemplateDB(templatedb_edt->text());
		model->setConnectionLimit(connlim_sb->value());

		if(encoding_cmb->currentIndex() > 0)
			model->setEncoding(EncodingType(encoding_cmb->currentText()));
		else
			model->setEncoding(EncodingType(BaseType::null));

		if(lccollate_cmb->currentText()!=trUtf8("Default"))
			model->setLocalization(Collation::_LC_COLLATE, lccollate_cmb->currentText());
		else
			model->setLocalization(Collation::_LC_COLLATE, QString());

		if(lcctype_cmb->currentText()!=trUtf8("Default"))
			model->setLocalization(Collation::_LC_CTYPE, lcctype_cmb->currentText());
		else
			model->setLocalization(Collation::_LC_CTYPE, QString());

		model->setDefaultObject(def_schema_sel->getSelectedObject(), OBJ_SCHEMA);
		model->setDefaultObject(def_owner_sel->getSelectedObject(), OBJ_ROLE);
		model->setDefaultObject(def_collation_sel->getSelectedObject(), OBJ_COLLATION);
		model->setDefaultObject(def_tablespace_sel->getSelectedObject(), OBJ_TABLESPACE);

		finishConfiguration();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #21
0
ファイル: columnwidget.cpp プロジェクト: Tbxhs/pgmodeler
void ColumnWidget::applyConfiguration(void)
{
	try
	{
		Column *column=NULL;

		startConfiguration<Column>();

		column=dynamic_cast<Column *>(this->object);
		column->setNotNull(notnull_chk->isChecked());
		column->setDefaultValue(def_value_txt->toPlainText());
		column->setType(data_type->getPgSQLType());

		BaseObjectWidget::applyConfiguration();

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #22
0
ファイル: viewwidget.cpp プロジェクト: Bumanji/pgmodeler
void ViewWidget::applyConfiguration(void)
{
	try
	{
		View *view=NULL;

		startConfiguration<View>();

		view=dynamic_cast<View *>(this->object);
		(*view)=aux_view;

		BaseObjectWidget::applyConfiguration();

		this->model->updateViewRelationships(view);

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #23
0
ファイル: sequencewidget.cpp プロジェクト: Halfnhav/pgmodeler
void SequenceWidget::applyConfiguration(void)
{
	try
	{
		Sequence *sequence=nullptr;

		startConfiguration<Sequence>();
		sequence=dynamic_cast<Sequence *>(this->object);

		BaseObjectWidget::applyConfiguration();

		sequence->setCycle(cyclic_chk->isChecked());
		sequence->setValues(minimum_edt->text(), maximum_edt->text(), increment_edt->text(),
												start_edt->text(), cache_edt->text());
		sequence->setOwnerColumn(dynamic_cast<Column *>(column_sel->getSelectedObject()));
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #24
0
ファイル: conversionwidget.cpp プロジェクト: Ox0000/pgmodeler
void ConversionWidget::applyConfiguration(void)
{
	try
	{
		Conversion *conv=nullptr;

		startConfiguration<Conversion>();
		conv=dynamic_cast<Conversion *>(this->object);

		BaseObjectWidget::applyConfiguration();

		conv->setEncoding(Conversion::SRC_ENCODING, src_encoding_cmb->currentText());
		conv->setEncoding(Conversion::DST_ENCODING, trg_encoding_cmb->currentText());
		conv->setDefault(default_conv_chk->isChecked());
		conv->setConversionFunction(dynamic_cast<Function*>(conv_func_sel->getSelectedObject()));

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #25
0
ファイル: indexwidget.cpp プロジェクト: Tbxhs/pgmodeler
void IndexWidget::applyConfiguration(void)
{
	try
	{
		Index *index=NULL;
		unsigned i, count;

		startConfiguration<Index>();

		index=dynamic_cast<Index *>(this->object);
		index->setIndexAttribute(Index::FAST_UPDATE, fast_update_chk->isChecked());
		index->setIndexAttribute(Index::CONCURRENT, concurrent_chk->isChecked());
		index->setIndexAttribute(Index::UNIQUE, unique_chk->isChecked());
		index->setConditionalExpression(cond_expr_txt->toPlainText().toUtf8());
		index->setIndexingType(IndexingType(indexing_cmb->currentText()));

		if(fill_factor_chk->isChecked())
			index->setFillFactor(fill_factor_sb->value());
		else
			index->setFillFactor(0);

		index->removeElements();
		count=elements_tab->getRowCount();

		for(i=0; i < count; i++)
			index->addElement(elements_tab->getRowData(i).value<IndexElement>());

		BaseObjectWidget::applyConfiguration();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #26
0
ファイル: indexwidget.cpp プロジェクト: jotawolf/pgmodeler
void IndexWidget::applyConfiguration(void)
{
	try
	{
		Index *index=nullptr;
		vector<IndexElement> idx_elems;

		startConfiguration<Index>();

		index=dynamic_cast<Index *>(this->object);

		BaseObjectWidget::applyConfiguration();

		index->setIndexAttribute(Index::FAST_UPDATE, fast_update_chk->isChecked());
		index->setIndexAttribute(Index::CONCURRENT, concurrent_chk->isChecked());
		index->setIndexAttribute(Index::UNIQUE, unique_chk->isChecked());
		index->setIndexAttribute(Index::BUFFERING, buffering_chk->isChecked());
    index->setPredicate(predicate_txt->toPlainText().toUtf8());
		index->setIndexingType(IndexingType(indexing_cmb->currentText()));

		if(fill_factor_chk->isChecked())
			index->setFillFactor(fill_factor_sb->value());
		else
			index->setFillFactor(0);

		elements_wgt->getElements(idx_elems);
		index->addIndexElements(idx_elems);

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #27
0
ファイル: tablewidget.cpp プロジェクト: Ox0000/pgmodeler
void TableWidget::applyConfiguration(void)
{
    try
    {
        Table *table=nullptr;
        vector<BaseRelationship *> rels;

        if(!this->new_object)
            op_list->registerObject(this->object, Operation::OBJECT_MODIFIED);
        else
            registerNewObject();

        table=dynamic_cast<Table *>(this->object);
        table->setWithOIDs(with_oids_chk->isChecked());
        table->setGenerateAlterCmds(gen_alter_cmds_chk->isChecked());
        table->setUnlogged(unlogged_chk->isChecked());
        table->setTag(dynamic_cast<Tag *>(tag_sel->getSelectedObject()));

        BaseObjectWidget::applyConfiguration();

        try
        {
            table->saveRelObjectsIndexes();

            if(model->getRelationship(table, nullptr))
                model->validateRelationships();

            model->updateTableFKRelationships(table);
        }
        catch(Exception &e)
        {
            Messagebox msg_box;

            if(e.getErrorType()==ERR_INVALIDATED_OBJECTS)
                msg_box.show(e);
            else
                throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
        }

        op_list->finishOperationChain();
        finishConfiguration();

        if(RelationshipView::getLineConnectinMode()==RelationshipView::CONNECT_FK_TO_PK)
        {
            /* Forcing the update of relationships connected to the table in order to reconfigure the line
             in case of the relationship is using the CONNECT_FK_TO_PK line mode */
            rels=model->getRelationships(table);
            for(auto &rel : rels)
            {
                if(rel->getRelationshipType()==Relationship::RELATIONSHIP_11 ||
                        rel->getRelationshipType()==Relationship::RELATIONSHIP_1N ||
                        rel->getRelationshipType()==Relationship::RELATIONSHIP_FK)
                    rel->setModified(true);
            }
        }
    }
    catch(Exception &e)
    {
        throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
    }
}
コード例 #28
0
void TypeWidget::applyConfiguration(void)
{
	try
	{
		Type *type=nullptr;
		unsigned i, count;

		startConfiguration<Type>();
		type=dynamic_cast<Type *>(this->object);

		BaseObjectWidget::applyConfiguration();

		//Configuring an enumaration type
		if(enumeration_rb->isChecked())
		{
			type->setConfiguration(Type::ENUMERATION_TYPE);

			count=enumerations_tab->getRowCount();
			for(i=0; i < count; i++)
				type->addEnumeration(enumerations_tab->getCellText(i,0).toUtf8());
		}
		//Configuration a composite type
		else if(composite_rb->isChecked())
		{
			type->setConfiguration(Type::COMPOSITE_TYPE);

			count=attributes_tab->getRowCount();
			for(i=0; i < count; i++)
				type->addAttribute(attributes_tab->getRowData(i).value<TypeAttribute>());
		}
		//Configuration a range type
		else if(range_rb->isChecked())
		{
			type->setConfiguration(Type::RANGE_TYPE);
			type->setCollation(collation_sel->getSelectedObject());
			type->setSubtype(range_subtype->getPgSQLType());
			type->setSubtypeOpClass(dynamic_cast<OperatorClass *>(opclass_sel->getSelectedObject()));
			type->setFunction(Type::CANONICAL_FUNC, dynamic_cast<Function *>(functions_sel[Type::CANONICAL_FUNC]->getSelectedObject()));
			type->setFunction(Type::SUBTYPE_DIFF_FUNC, dynamic_cast<Function *>(functions_sel[Type::SUBTYPE_DIFF_FUNC]->getSelectedObject()));
		}
		//Configuring a base type
		else
		{
			type->setConfiguration(Type::BASE_TYPE);
			type->setLikeType(like_type->getPgSQLType());
			type->setElement(element_type->getPgSQLType());
			type->setInternalLength(internal_len_sb->value());
			type->setByValue(by_value_chk->isChecked());
			type->setPreferred(preferred_chk->isChecked());
			type->setCollatable(collatable_chk->isChecked());

			if(!delimiter_edt->text().isEmpty())
				type->setDelimiter(delimiter_edt->text().at(0).toLatin1());

			type->setDefaultValue(default_value_edt->text());
			type->setCategory(CategoryType(category_cmb->currentText()));
			type->setAlignment(PgSQLType(alignment_cmb->currentText()));
			type->setStorage(StorageType(storage_cmb->currentText()));

			for(i=Type::INPUT_FUNC; i <= Type::ANALYZE_FUNC; i++)
				type->setFunction(i, dynamic_cast<Function *>(functions_sel[i]->getSelectedObject()));
		}

		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #29
0
ファイル: functionwidget.cpp プロジェクト: Bumanji/pgmodeler
void FunctionWidget::applyConfiguration(void)
{
	try
	{
		Function *func=NULL;
		unsigned count, i;
		Parameter param;
		QString str_aux;


		startConfiguration<Function>();

		func=dynamic_cast<Function *>(this->object);
		func->setLanguage(model->getObject(language_cmb->currentText(), OBJ_LANGUAGE));
		func->setFunctionType(func_type_cmb->currentText());
		func->setWindowFunction(window_func_chk->isChecked());
		func->setExecutionCost(exec_cost_spb->value());
		func->setRowAmount(rows_ret_spb->value());
		func->setBehaviorType(behavior_cmb->currentText());
		func->setSecurityType(security_cmb->currentText());
		func->removeParameters();

		count=parameters_tab->getRowCount();

		for(i=0; i < count; i++)
		{
			param.setName(parameters_tab->getCellText(i,0));
			param.setType(parameters_tab->getRowData(i).value<PgSQLType>());

			str_aux=parameters_tab->getCellText(i,2);
			param.setIn(str_aux.indexOf("IN") >= 0);
			param.setOut(str_aux.indexOf("OUT") >= 0);

			param.setDefaultValue(parameters_tab->getCellText(i,3));

			func->addParameter(param);
		}


		if(language_cmb->currentText()==~LanguageType(LanguageType::c))
		{
			func->setLibrary(library_edt->text());
			func->setSymbol(symbol_edt->text());
		}
		else
			func->setSourceCode(source_code_txt->toPlainText());

		if(simple_rb->isChecked() || set_rb->isChecked())
		{
			func->setReturnType(ret_type->getPgSQLType());
			func->setReturnSetOf(set_rb->isChecked());
		}
		else
		{
			func->removeReturnedTableColumns();
			count=return_tab->getRowCount();

			for(i=0; i<count; i++)
			{
				func->addReturnedTableColumn(return_tab->getCellText(i,0),
																		 return_tab->getRowData(i).value<PgSQLType>());
			}
		}

		BaseObjectWidget::applyConfiguration();

		validateConfiguredFunction();
		finishConfiguration();
	}
	catch(Exception &e)
	{
		cancelConfiguration();
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
コード例 #30
0
void ConstraintWidget::applyConfiguration(void)
{
	try
	{
		Constraint *constr=nullptr;
		unsigned i, col_id, count;
		Column *column=nullptr;
		ObjectTableWidget *aux_col_tab=nullptr;
		vector<ExcludeElement> excl_elems;

		startConfiguration<Constraint>();

		constr=dynamic_cast<Constraint *>(this->object);
		constr->setConstraintType(ConstraintType(constr_type_cmb->currentText()));
    constr->setExpression(expression_txt->toPlainText().toUtf8());

		if(fill_factor_chk->isChecked())
			constr->setFillFactor(fill_factor_sb->value());
		else
			constr->setFillFactor(0);

		constr->setMatchType(MatchType(match_cmb->currentText()));
		constr->setDeferrable(deferrable_chk->isChecked());
		constr->setDeferralType(DeferralType(deferral_cmb->currentText()));
    constr->setActionType(ActionType(on_delete_cmb->currentText()),Constraint::DELETE_ACTION);
    constr->setActionType(ActionType(on_update_cmb->currentText()),Constraint::UPDATE_ACTION);
		constr->setNoInherit(no_inherit_chk->isChecked());

		if(indexing_chk->isChecked())
			constr->setIndexType(IndexingType(indexing_cmb->currentText()));
		else
			constr->setIndexType(BaseType::null);

		if(constr->getConstraintType()==ConstraintType::foreign_key)
			constr->setReferencedTable(dynamic_cast<BaseTable *>(ref_table_sel->getSelectedObject()));

		constr->removeColumns();
		for(col_id=Constraint::SOURCE_COLS; col_id <= Constraint::REFERENCED_COLS; col_id++)
		{
			aux_col_tab=(col_id==Constraint::SOURCE_COLS ? columns_tab : ref_columns_tab);

			count=aux_col_tab->getRowCount();
			for(i=0; i < count; i++)
			{
				column=reinterpret_cast<Column *>(aux_col_tab->getRowData(i).value<void *>());
				constr->addColumn(column, col_id);
			}
		}

		excl_elems_wgt->getElements(excl_elems);
		constr->addExcludeElements(excl_elems);

		//Raises an error if the user try to create a primary key that has columns added by relationship (not supported)
		if(constr->getConstraintType()==ConstraintType::primary_key &&
			 constr->isReferRelationshipAddedColumn())
			throw Exception(ERR_PK_USING_COLS_ADDED_BY_REL,__PRETTY_FUNCTION__,__FILE__,__LINE__);

		BaseObjectWidget::applyConfiguration();

		/* Raises an error if the constraint type requires at least one column to be assinged and
		there is no columns configured on the form */
		if(((constr->getConstraintType()==ConstraintType::foreign_key ||
				 constr->getConstraintType()==ConstraintType::primary_key) &&
				constr->getColumnCount(Constraint::SOURCE_COLS)==0) ||
			 (constr->getConstraintType()==ConstraintType::foreign_key &&
				constr->getColumnCount(Constraint::REFERENCED_COLS)==0))
			throw Exception(ERR_CONSTR_NO_COLUMNS,__PRETTY_FUNCTION__,__FILE__,__LINE__);

		finishConfiguration();

		//For the foreign keys, updates the fk relationships on the model
		if(constr->getConstraintType()==ConstraintType::foreign_key)
			this->model->updateTableFKRelationships(dynamic_cast<Table *>(this->table));
	}
	catch(Exception &e)
	{
		Messagebox msg_box;

		cancelConfiguration();
		msg_box.show(e);
	}
}