Home » Modeling » OCL » EXTLibraryPackage ?
EXTLibraryPackage ? [message #545569] |
Thu, 08 July 2010 05:41  |
Eclipse User |
|
|
|
Hi, everyone,
This is almost the same with I post reply on the other topic,
I posted again because worry about you are not noticed.
I followed suggestion.
Visited " http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .ocl.doc/tutorials/oclInterpreterTutorial.html " that page again,
Read and practice that page said.
But I meet problem the same with before,
Here is the code I wrote:
============================================================ ====
public static <EClassifier,Constraint,EClass,EObject> void main(String[] args) {
boolean valid;
org.eclipse.ocl.expressions.OCLExpression<EClassifier> query=null;
try {
// create an OCL instance for Ecore
OCL< EPackage,org.eclipse.emf.ecore.EClassifier,EOperation,EStruc turalFeature,EEnumLiteral,EParameter,org.eclipse.emf.ecore.E Object,CallOperationAction,SendSignalAction,org.eclipse.ocl. ecore.Constraint,org.eclipse.emf.ecore.EClass,org.eclipse.em f.ecore.EObject > ocl;
ocl=OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
// create an OCL helper object
OCLHelper< org.eclipse.emf.ecore.EClassifier,EOperation,EStructuralFeat ure,org.eclipse.ocl.ecore.Constraint > helper=ocl.createOCLHelper();
// set the OCL context classifier
helper.setContext(EXTLibraryPackage.Literals.WRITER);
query=(org.eclipse.ocl.expressions.OCLExpression<EClassifier >) helper.createQuery("self.books->collect(b : Book | b.category)->asSet()");
// record success
valid=true;
}
catch (ParserException e) {
// record failure to parse
valid=false;
System.err.println(e.getLocalizedMessage());
}
}
============================================================ ====
I just copy and paste on my mechine,
but error happened on " helper.setContext(EXTLibraryPackage.Literals.WRITER); ",
and I knowed is missing " EXTLibraryPackage ",
I don't wanna using EXTLibraryPackage at all.
So, my question is:
How can I replace EXTLibraryPackage ?
I need to created Package my own at first ?
And how can I import into my program when I created Package ?
I tried many times and allways failed.
Error is happened and red line is below " helper.setContext(EXTLibraryPackage.Literals.WRITER); ".
This problem is bottered me for a few weeks,
If possible, would you tell me what to do next in detail ?
Best Regard
|
|
|
Re: EXTLibraryPackage ? [message #545880 is a reply to message #545569] |
Fri, 09 July 2010 08:46   |
Eclipse User |
|
|
|
Hi, Victorino,
Tools like Thunderbird ensure that we will every any post in any thread.
There's no need to re-post a follow-up question at the top level.
On the subject at hand, the OCL tutorial is meant to introduce a new
user of OCL to the API. It is not meant to just cut and paste the code.
Obviously, your application doesn't need to model books and libraries,
so the EXTLibraryPackage isn't going to be useful except for the
tutorial purpose.
You have generated your model using EMF, right? So, you have your own
package to work with. Operating on it with OCL is very similar to
working with the EXTLibraryPackage or any other EMF-generated package.
I'm afraid I just don't understand what you mean by "How can I replace
EXTLibraryPackage." You need to use your own package.
I think, perhaps, that you first need to become more familiar with using
the Java API that is generated for your model by EMF, and how to work
with your package's metadata, before tackling OCL.
Have a look at the starter documentation on the EMF website:
http://www.eclipse.org/modeling/emf
and the FAQs and snippets on their Wiki:
http://wiki.eclipse.org/EMF
Questions about EMF (such as about how to generate your model and access
its metadata) should be directed to the EMF newsgroup:
news://news.eclipse.org/eclipse.tools.emf
HTH,
Christian
On 08/07/10 05:41 AM, Victorino wrote:
> Hi, everyone,
> This is almost the same with I post reply on the other topic,
> I posted again because worry about you are not noticed.
>
> I followed suggestion.
> Visited "
> http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .ocl.doc/tutorials/oclInterpreterTutorial.html
> " that page again,
> Read and practice that page said.
> But I meet problem the same with before,
> Here is the code I wrote:
> ============================================================ ====
> public static <EClassifier,Constraint,EClass,EObject> void main(String[]
> args) {
> boolean valid;
> org.eclipse.ocl.expressions.OCLExpression<EClassifier> query=null;
> try {
> // create an OCL instance for Ecore
> OCL< EPackage,org.eclipse.emf.ecore.EClassifier,EOperation,EStruc
> turalFeature,EEnumLiteral,EParameter,org.eclipse.emf.ecore.E
> Object,CallOperationAction,SendSignalAction,org.eclipse.ocl.
> ecore.Constraint,org.eclipse.emf.ecore.EClass,org.eclipse.em
> f.ecore.EObject > ocl;
> ocl=OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
> // create an OCL helper object
> OCLHelper< org.eclipse.emf.ecore.EClassifier,EOperation,EStructuralFeat
> ure,org.eclipse.ocl.ecore.Constraint > helper=ocl.createOCLHelper();
> // set the OCL context classifier
> helper.setContext(EXTLibraryPackage.Literals.WRITER);
> query=(org.eclipse.ocl.expressions.OCLExpression<EClassifier >)
> helper.createQuery("self.books->collect(b : Book | b.category)->asSet()");
> // record success
> valid=true;
> }
> catch (ParserException e) {
> // record failure to parse
> valid=false;
> System.err.println(e.getLocalizedMessage());
> }
> }
> ============================================================ ====
> I just copy and paste on my mechine,
> but error happened on "
> helper.setContext(EXTLibraryPackage.Literals.WRITER); ",
> and I knowed is missing " EXTLibraryPackage ",
> I don't wanna using EXTLibraryPackage at all.
> So, my question is:
> How can I replace EXTLibraryPackage ?
> I need to created Package my own at first ?
> And how can I import into my program when I created Package ?
> I tried many times and allways failed.
> Error is happened and red line is below "
> helper.setContext(EXTLibraryPackage.Literals.WRITER); ".
> This problem is bottered me for a few weeks,
> If possible, would you tell me what to do next in detail ?
> Best Regard
|
|
|
Re: EXTLibraryPackage ? [message #546497 is a reply to message #545569] |
Tue, 13 July 2010 03:23   |
Eclipse User |
|
|
|
Sorry for late to answer.
I just can touch Internet now,
and what is " So, you have your own package to work with " means ?
I have " XXX.flowjobdiagram ", " XXX.flowjobdiagram.diagram ", and " XXX.flowjobdiagram.edit " them three, but I can't find your means " package ".
Would you mind discover for me or descript more detail ?
I use EMF to define my flowjob's diagram, so I can draw flowjob, and OCL is on flowjob,
according to you paste before, I don't know how to writing the " ... sexContext() " this line.
Because I don't have package.
And now, I wanna using OCLHelper to creating my whole OCL file in memory, is that possible ? How ?
Thx.
Best Regard
[Updated on: Tue, 13 July 2010 03:26] by Moderator
|
|
|
Re: EXTLibraryPackage ? [message #546599 is a reply to message #546497] |
Tue, 13 July 2010 09:47   |
Eclipse User |
|
|
|
Hi, Victorino,
Defining a diagram is not using EMF. I assume from the names of your
plug-ins that you:
(a) created an Ecore model named Flowjobdiagram.ecore
(b) used GMF to define a graphical syntax for it
(c) used EMF to generate the *.flowjobdiagram and
*.flowjobdiagram.edit plug-ins
(d) used GMF to generate the *.flowjobdiagram.diagram
plug-in
Is this correct?
If it is, then you already generated your package. Look in the
*.flowjobdiagram plug-in for an interface named something like
FlowjobdiagramPackage. That is "your package" that I have mentioned
several times already. It is what you need to use instead of
EXTLibraryPackage to work with OCL on your flow models.
Again, I cannot stress enough the importance of understanding EMF before
you attempt any one of
(a) working with OCL
(b) working with GMF
(c) working with any other Eclipse Modeling Project
technology
It is clear from your questions that you don't understand what an Ecore
package is, and this is of critical importance. Please, learn and
practise EMF first, from the resources available on the Eclipse website,
the various tutorials contributed by the EMF user community, and even
the excellent "Eclipse Modeling Framework" book. You will find it
difficult to get useful help about anything else without a basic
understanding of the concepts involved in modeling with EMF.
HTH,
Christian
On 13/07/10 03:23 AM, Victorino wrote:
> Sorry for late to answer.
> I just can touch Internet now,
> and what is " So, you have your own package to work with " means ?
> I have " XXX.flowjobdiagram ", " XXX.flowjobdiagram.diagram ", and "
> XXX.flowjobdiagram.edit " them three, but I can find your means "
> package ".
> Would you mind discover for me or descript more detail ?
> I use EMF to define my flowjob's diagram, so I can draw flowjob, and OCL
> is on flowjob,
> according to you paste before, I don't know how to writing the " ...
> sexContext() " this line.
> Because I don't have package.
> Best Regard
|
|
| | | |
Re: EXTLibraryPackage ? [message #546813 is a reply to message #545569] |
Wed, 14 July 2010 06:14   |
Eclipse User |
|
|
|
Sorry for bothered you again.
And when I check my mechine one more,
I found one Java file is named " flowjobPackage.java ",
Is it I am trying to looking for?
It's site in flowjobdiagram folder,
(flowjobdiagram -> src -> flowjobdiagram -> flowjobdiagramPackage.java)
(they are in ordered is: folder, folder, package, java file)
Is that I found?
And I will read the " basic " toturial again,
but for practice,
I need my own package.
Should I use this file to practice?
And " setContext " is make error the same.
============================================================ ====
helper.setContext(new File(" C:\\Users\\jjchou\\workspace\\flowjobdiagram\\src\\flowjobdi agram.java "));
============================================================ ====
Best Regard
[Updated on: Wed, 14 July 2010 06:29] by Moderator
|
|
|
Re: EXTLibraryPackage ? [message #546863 is a reply to message #546813] |
Wed, 14 July 2010 09:08   |
Eclipse User |
|
|
|
Hi, Victorino,
Yes, that should be the one. I hadn't expected the name to be
flowjobdiagramPackage (with an initial lower-case) because I thought
Ecore had an EClass constraint requiring initial capitals to match the
Java convention.
Anyhow, if this class implements the EPackage interface (extending
EPackageImpl) then it's your "package." Perhaps there has been
confusion in the overloaded term "package." In modeling terminology, a
package bears little resemblance to a Java package; it's just a reusable
collection of semantically related model elements.
This flowjobdiagramPackage class is what the OCL API needs to access
your model.
Cheers,
Christian
On 14/07/10 06:14 AM, Victorino wrote:
> Sorry for bothered you again.
> And when I check my mechine one more,
> I found one Java file is named " flowjobPackage.java ",
> Is it I am trying to looking for?
> It's site in flowjobdiagram folder,
> (flowjobdiagram -> src -> flowjobdiagram -> flowjobdiagramPackage.java)
> | | | |
> folder folder package java file
> Is that I found?
> And I will read the " basic " toturial again,
> but for practice,
> I need my own package.
> Should I use this file to practice?
> Best Regard
|
|
| |
Re: EXTLibraryPackage ? [message #547064 is a reply to message #546978] |
Thu, 15 July 2010 07:54   |
Eclipse User |
|
|
|
Hi, Victorino,
On 14/07/10 03:35 PM, Victorino wrote:
> I found the package already,
> but I can not use it.
I am sorry, but I simply don't understand. Why can you not use it?
Does it not have an eINSTANCE field that gives your code access to the
package?
> Because I don't know how grammer is?
Again, I don't understand. You don't know OCL syntax? You don't know
your flow-diagram model? If that's the case, how do you expect to
accomplish anything?
> And " flowjobdiagramPackage.java " and my " main.java " is different
> project,
Hunh? What does main.java have to do with anything? Is your problem
that you don't understand Java programming in the Eclipse IDE? There
are other resources to help with that.
> how can I used like the pages say,
> ============================================================ ========
> oclhelper.setContext(flowjobdiagramPackage);
> ============================================================ ========
Try this:
oclhelper.setContext(flowjobdiagramPackage.eINSTANCE);
(did you notice the eINSTANCE reference in the tutorial code?)
Java doesn't permit references to class names as expressions.
> I tried several way to use,
> but all of them are wrong,
> (including give the entirely path).
> Please tell me how to use?
I don't think I can, sorry. I have done my best.
> Thanks sincerely.
> Best Regard
|
|
|
Re: EXTLibraryPackage ? [message #547357 is a reply to message #545569] |
Fri, 16 July 2010 08:52  |
Eclipse User |
|
|
|
Nmnm...
I think you misunderstanding my means,
I means I wanna having another project which is different from " flowjobdiagramPackage.java " file,
and main method is inside at another project(not the same project with flowjobdiagramPackage.java file in),
Is that possible?
According your means,
I guest main method have to inside the same project, am I right?
And, really thanks for your reply.
Best Regard
[Updated on: Fri, 16 July 2010 08:54] by Moderator
|
|
|
Goto Forum:
Current Time: Tue Jul 22 18:24:42 EDT 2025
Powered by FUDForum. Page generated in 0.04639 seconds
|