Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Rule-based validation causing dependency cycles.
Rule-based validation causing dependency cycles. [message #644397] Fri, 10 December 2010 21:38 Go to next message
No real name is currently offline No real nameFriend
Messages: 101
Registered: August 2010
Senior Member
Hi,

I wrote some java validators for my model (about 10 of them). Now, I want the user to be able to select which one of these validators to run. So I created a preference page in the UI plugin for the DSL. I write the selected rules to a prefereneStore(). However, in My<DSL>JavaValidator.java I need to access this preferenceStore to get the user selections to figure out which methods in the validator shoudl be executed. Thus, in the plugin.xml of the grammar project, I have to add the UI plugin as a runtime dependency.

This ends up creating a cycle depdency since the grammar depends on the UI, and the UI depends on the grammar. Is there a way to resolve this somehow (short of moving the prefereces into a new plugin of its own)?

Thanks.
Re: Rule-based validation causing dependency cycles. [message #644445 is a reply to message #644397] Sat, 11 December 2010 12:24 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi,

simply create a lightweight service that provides something like
boolean shouldExecute(Validation) and provide an implementation in the
UI by means of dependency injection that reads the data from the
preferences and an implementation for the runtime that simply returns true.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 10.12.10 22:38, schrieb pgbackup@yahoo.com:
> Hi,
>
> I wrote some java validators for my model (about 10 of them). Now, I
> want the user to be able to select which one of these validators to run.
> So I created a preference page in the UI plugin for the DSL. I write the
> selected rules to a prefereneStore(). However, in
> My<DSL>JavaValidator.java I need to access this preferenceStore to get
> the user selections to figure out which methods in the validator shoudl
> be executed. Thus, in the plugin.xml of the grammar project, I have to
> add the UI plugin as a runtime dependency.
>
> This ends up creating a cycle depdency since the grammar depends on the
> UI, and the UI depends on the grammar. Is there a way to resolve this
> somehow (short of moving the prefereces into a new plugin of its own)?
>
> Thanks.
Re: Rule-based validation causing dependency cycles. [message #644927 is a reply to message #644445] Tue, 14 December 2010 19:26 Go to previous message
No real name is currently offline No real nameFriend
Messages: 101
Registered: August 2010
Senior Member
Hi,

Thank you for the help. I got this working. Here is some sample code if anyone else is interesed.

public interface IRunRuleCheckProvider {

	public boolean shouldRunCheck(String ruleName);
}


Runtime
public class MyHLMRunRuleCeck implements IRunRuleCheckProvider {

	// Overridden in the UI.
	@Override
	public boolean shouldRunCheck(String ruleName) {
		System.out.println("in myHLMRunRuleCheck");
		return false;
	}
}


UI
public class MyHLMDoRunRuleCheck implements IRunRuleCheckProvider {

	@Override
	public boolean shouldRunCheck(String ruleName) {
		System.out.println("in myHLmDoRunRuleCheck");
		return true;
	}
}


UiModule
	public Class<? extends IRunRuleCheckProvider> bindIRunRuleCheckProvider() {
		System.out.println("Got here");
		return MyHLMDoRunRuleCheck.class;
	}


In <DSL>JavaValidator
	@Inject
	private IRunRuleCheckProvider rcp;
Previous Topic:Embedded Xtext Editor in Dialog
Next Topic:Strange problems with "Duplicate names validation"
Goto Forum:
  


Current Time: Tue Apr 23 06:37:12 GMT 2024

Powered by FUDForum. Page generated in 0.04235 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top