<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Ok,<br>
<br>
3) First you need to create a class that implements the
ResourceGenerator interface (Check
org.jboss.forge.addon.maven.resources.MavenResourceGenerator for an
example). Forge will automatically find your ResourceGenerator class
and use it to create the GitIgnoreResource (be sure to create tests
that assert this behavior)<br>
<br>
7) Basically the
org.jboss.forge.git.gitignore.GitIgnoreTemplateCompleter.candidates(String)
method is only what you need. Create a class that implements
UICompleter, and add that behavior to the getCompletionProposals
method.<br>
<br>
2) Right, I moved it to projects-api under a "ui" subpackage and
removed it from the javaee-impl. That should work.<br>
<br>
8) Your getMetadata should be something like: <br>
<br>
super.getMetadata().name("GIT: Ignore").description("Add pattern to
.gitignore").category(Categories.create("Git"));<br>
<br>
that will be translated to "git-ignore" in shell.<br>
<br>
<br>
<div class="moz-cite-prefix">On 09/02/2013 04:52 PM, Ivan St. Ivanov
wrote:<br>
</div>
<blockquote
cite="mid:CACYLA9GXX4c8YZgPCkNiKo3bDC-2rmLqJVmURhKi057cvNo0RA@mail.gmail.com"
type="cite">
<div dir="ltr">Hey George,
<div><br>
</div>
<div>3) Could you please explain me a little bit, just for my
curiosity? How would Forge know that when I "cd" to .gitignore
file it is not merely FileResource but it is
GitIgnoreResource? Thanks!</div>
<div><br>
</div>
<div>7) I mean the GitIgnoreTemplateCompleter. There in the
beginning of the complete method you can see some acrobatics
with the CommandCompleterState parameter. I was wondering how
that can be done in the new API</div>
<div><br>
</div>
<div>2) At the moment <span
style="font-family:arial,sans-serif;font-size:13px">AbstractProjectUICommand
is in the <b>javaee-impl</b> project. I don't want to
introduce dependency to that just to extend that class in
order to use the getSelectedProject. That is why I thought
that maybe we can find a better place for this abstract
class.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">8)
OK, so if my getMetadata method declared that the name of
the command is:</span></div>
<div><font face="arial, sans-serif"><br>
</font></div>
<div><font face="arial, sans-serif">super.getMetadata().name("GIT:
Add pattern to .gitignore")</font><br>
</div>
<div><font face="arial, sans-serif"><br>
</font></div>
<div><font face="arial, sans-serif">How would that map to a
shell command? Should we have some kind of convention for
these names?</font></div>
<div><font face="arial, sans-serif"><br>
</font></div>
<div><font face="arial, sans-serif">Thanks again!</font></div>
<div><font face="arial, sans-serif">Ivan</font></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Sep 2, 2013 at 5:13 PM, George
Gastaldi <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:ggastald@redhat.com" target="_blank">ggastald@redhat.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Hi Ivan!<br>
<br>
3) You can safely use instanceof. It should work. Another
option is using the reify method, so it will convert your
resource to the desired type if it's not the expected type
or return null if it's not possible.<br>
<br>
7) The completer API has completely changed from Forge 1.
Now you just need to return a list of the objects that
matches the value passed as a parameter. Do you need
anything specific that it is not covered in the
UICompleter interface? Which completer are you trying to
migrate? <br>
<br>
2) You no longer need getSelectedProject in
AbstractGitCommand, use the one from
AbstractProjectUICommand. I don't think this code fits in
another place, but we can review that.<br>
<br>
8) In Forge 2, the shell no longer has a "sub-command"
concept (Eg: cdi setup was replaced by cdi-setup). The
shell addon automatically converts spaces into dashes so
it's easier to find the command you need from the first
auto-complete.<br>
<br>
Best Regards,<br>
<br>
George Gastaldi
<div>
<div class="h5"><br>
<br>
<br>
<div>On 09/02/2013 08:30 AM, Ivan St. Ivanov wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hey George!
<div><br>
</div>
<div>Thanks a lot for the quick feedback!</div>
<div><br>
</div>
<div>I'm afraid though that I did not get some of
the answers I needed:</div>
<div><br>
</div>
<div>3) How do you get the current resource
(@Current as of Forge 1)? Is
it context.getInitialSelection().get()? <b>How
can I check that it is of any particular type
(e.g. GitIgnoreResource)</b>?</div>
<div><br>
</div>
<div>[George]: <span
style="font-family:arial,sans-serif;font-size:13px">Yes,
the current resource is always retrieved using
UIContext.getInitialSelection, which can be
safely assigned to a
UISelection<Resource<?>> variable.</span></div>
<div><br>
</div>
<div>[Ivan]: I did not get how can I check whether
a file resource is of GitIgnoreResource type.
What I can think of: check whether the current
resource is file and that its name is
GitIgnoreResource.RESOURCE_NAME. I'm afraid that
instanceof will not work. What I am not sure is
how Forge knows that a certain resource is of
certain type (or more precisely: of certain
subtype of FileResource)</div>
<div><br>
</div>
<div><br>
</div>
<div>7) How did you migrate existing completers? I
see that the completer interface has changed. I
am afraid I can't figure out how I can rework
complete methods from Forge 1, that were <b>using CommandCompleterState
parameter</b>. I couldn't find samples</div>
<div><br>
</div>
<div>[George]: <span
style="font-family:arial,sans-serif;font-size:13px">In
the UICommand.initializeUI method, you call
setCompleter for the desired injected input</span></div>
<div><br>
</div>
<div>[Ivan]: Yes, I found how to assign a
completer to an input. However I was not sure
how to adapt an already existing completer,
which received as parameter a
CommandCompleterState object. The existing
completers used that object and I don't know how
to rework them to use the UIContext interface
for the same purpose</div>
<div><br>
</div>
<div><br>
</div>
<div>2) I see that in javaee-impl you have
implemented an abstract command class that
exposes a class that returns the current project
(or null):
org.jboss.forge.addon.javaee.ui.AbstractProjectUICommand.
I copy-pasted the getSelectedProject method to
an abstract Git UI command class that I created
just becayse I saw that addon-ui does not have
access to the project API (outherwise I would
put it in the AbstractUICommand class). <b>Can
we find a better place for this code?</b> In
Forge 1 we just @Inject-ed a Project instance,
but now I am not sure what to do</div>
<div><br>
</div>
<div>[George]: <span
style="font-family:arial,sans-serif;font-size:13px">Make
your addon depend on the projects addon and
you shall access these classes normally</span></div>
<div><br>
</div>
<div>[Ivan]: Actually I did what you proposed. But
now we have one and the same "protected Project
getSelectedProject(UIContext context)" method
in org.jboss.forge.addon.javaee.ui.AbstractProjectUICommand
and
in org.jboss.forge.addon.git.ui.AbstractGitCommand.
Can we find a better place for a class like
AbstractProjecUICommand that is accessible from
anywhere where we develop commands relying on a
context of a project? Maybe in projects-impl?
Both javaee and git depend on that.</div>
<div><br>
</div>
<div><br>
</div>
<div>And one additional question:</div>
<div><br>
</div>
<div>8) In Forge 1 every plugin had a short name
that we entered on the command line. Now I see
that commands have some long strings as names
(e.g. "JPA: New Entity"). What does the user
have to enter in the shell if they want to
create a new entity?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Ivan</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Sep 2, 2013 at
12:34 AM, George Gastaldi <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:ggastald@redhat.com"
target="_blank">ggastald@redhat.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="auto">
<div>Those are some excellent questions,
I'll answer then inline:</div>
<div><br>
Em 01/09/2013, às 17:15, "Ivan St. Ivanov"
<<a moz-do-not-send="true"
href="mailto:ivan.st.ivanov@gmail.com"
target="_blank">ivan.st.ivanov@gmail.com</a>>
escreveu:<br>
<br>
</div>
<div>
<blockquote type="cite">
<div>
<div dir="ltr">Hey folks!
<div><br>
</div>
<div>This weekend I've been hacking
on migrating the git-tools to
Forge 2 (<a moz-do-not-send="true"
href="https://issues.jboss.org/browse/FORGE-1128" target="_blank">https://issues.jboss.org/browse/FORGE-1128</a>).
And I can say that I have pretty
much finished the task (although I
haven't started yet with the
git-tools-tests, but I will do
that as well).</div>
<div><br>
</div>
<div>And I have the following
questions and observations:</div>
<div><br>
</div>
<div>1) How do you declare that a UI
command requires to be executed in
the context of a project or in a
context of a certain resource? In
Forge 1 we had the
@RequiresProject and
@RequiresResource annotations, but
now we only have @RequiresFacet (I
hope it works ;)). What I do here
is: implement isEnabled and work
with the initialSelection method
of the UIContext to check what is
selected. BTW I find quite more
declarative approaches in Forge 1
than in Forge 2.</div>
<div><br>
</div>
</div>
</div>
</blockquote>
</div>
Exactly, this is the way to do it. We
haven't migrated @RequiresProject and
@RequiresResources yet, so you're doing the
right thing.
<div>
<div><br>
<blockquote type="cite">
<div>
<div dir="ltr">
<div>2) In Forge 1 we had one
plugin class that represented a
command with a lot of options as
methods of that class. Did I get
it right that in Forge 2 I have
to create a separate UICommand
implementation for every option
(i.e. method) of the plugin
class? I don't say it's bad, I
just want to understand whether
this is the way</div>
<div><br>
</div>
</div>
</div>
</blockquote>
</div>
Right again. We prototyped in a separate
branch the "command-per-method" strategy
but we haven't completed it yet.</div>
<div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div>3) How do you get the current
resource (@Current as of Forge 1)?
Is
it context.getInitialSelection().get()?
How can I check that it is of any
particular type
(e.g. GitIgnoreResource)?</div>
<div><br>
</div>
</div>
</blockquote>
</div>
Yes, the current resource is always
retrieved using
UIContext.getInitialSelection, which can
be safely assigned to a
UISelection<Resource<?>>
variable.</div>
<div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div>4) Is there such a thing as
setup command? I think there's no
need, but still I'd like to ask</div>
</div>
</blockquote>
</div>
There is not, but setup commands should be
implemented as UICommands as you may have
already noticed.</div>
<div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div>5) If a facet has to write a
message to a provider (GUI,
shell), how does it do it?
Commands do that via the Result
object, but I didn't get how
facets can. Or should they at all
write anything?</div>
</div>
</blockquote>
</div>
Facets can't write messages for now, but
we should consider doing it so it if makes
sense.</div>
<div><br>
</div>
<div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div>6) I saw that some of the git
commands in Forge 1 fire pickup
events:</div>
<div>Event<PickupResource>::fire(new
PickupResource(gitIgnoreResource()));<br>
</div>
<div>How is this done in Forge 2. I
would appreciate a sample in
existing plugin</div>
</div>
</blockquote>
</div>
You have to call UIContext.setSelection in
your UICommand.execute method.</div>
<div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div>7) How did you migrate existing
completers? I see that the
completer interface has changed. I
am afraid I can't figure out how I
can rework complete methods from
Forge 1, that were
using CommandCompleterState
parameter. I couldn't find samples</div>
</div>
</blockquote>
</div>
In the UICommand.initializeUI method, you
call setCompleter for the desired injected
input</div>
<div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div>And of course I have some
questions about the git-tools
implementation that have nothing
to do with the migration:</div>
<div><br>
</div>
<div>1) At the moment the GitUtils
class, which I have made an
interface and plan to export as
addon, exposes some JGit classes
as parameters. Do you think it's a
good idea to wrap them in our own
classes like you have done with
the JDT parser API for example?</div>
</div>
</blockquote>
</div>
That would be a good idea, so it could be
possible to use native git if needed.</div>
<div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div>2) I see that in javaee-impl
you have implemented an abstract
command class that exposes a class
that returns the current project
(or null):
org.jboss.forge.addon.javaee.ui.AbstractProjectUICommand.
I copy-pasted the
getSelectedProject method to an
abstract Git UI command class that
I created just becayse I saw that
addon-ui does not have access to
the project API (outherwise I
would put it in the
AbstractUICommand class). Can we
find a better place for this code?
In Forge 1 we just @Inject-ed a
Project instance, but now I am not
sure what to do</div>
</div>
</blockquote>
</div>
Make your addon depend on the projects
addon and you shall access these classes
normally</div>
<div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div>So, that's all from me for now.
Next to come - the questions about
the migration about the tests ;)</div>
<div><br>
</div>
</div>
</blockquote>
</div>
Bring'em on! :)</div>
<div><br>
<blockquote type="cite">
<div dir="ltr">
<div>Cheers,</div>
<div>Ivan</div>
</div>
</blockquote>
<blockquote type="cite">
<div><span>_______________________________________________</span><br>
<span>forge-dev mailing list</span><br>
<span><a moz-do-not-send="true"
href="mailto:forge-dev@lists.jboss.org"
target="_blank">forge-dev@lists.jboss.org</a></span><br>
<span><a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/forge-dev"
target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a></span></div>
</blockquote>
</div>
</div>
<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:forge-dev@lists.jboss.org"
target="_blank">forge-dev@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/forge-dev"
target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
forge-dev mailing list
<a moz-do-not-send="true" href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a></pre>
</blockquote>
<br>
</div>
</div>
</div>
<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/forge-dev"
target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
forge-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/forge-dev">https://lists.jboss.org/mailman/listinfo/forge-dev</a></pre>
</blockquote>
<br>
</body>
</html>