<div dir="ltr">Hey George!<div><br></div><div>Thanks a lot for the quick feedback!</div><div><br></div><div>I&#39;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&lt;Resource&lt;?&gt;&gt; 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&#39;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&#39;t figure out how I can rework complete methods from Forge 1, that were <b>using CommandCompleterState parameter</b>. I couldn&#39;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&#39;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 &quot;protected Project getSelectedProject(UIContext context)&quot; 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. &quot;JPA: New Entity&quot;). 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">&lt;<a href="mailto:ggastald@redhat.com" target="_blank">ggastald@redhat.com</a>&gt;</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&#39;ll answer then inline:</div><div><br>Em 01/09/2013, às 17:15, &quot;Ivan St. Ivanov&quot; &lt;<a href="mailto:ivan.st.ivanov@gmail.com" target="_blank">ivan.st.ivanov@gmail.com</a>&gt; escreveu:<br>
<br></div><div class="im"><blockquote type="cite"><div><div dir="ltr">Hey folks!<div><br></div><div>This weekend I&#39;ve been hacking on migrating the git-tools to Forge 2 (<a 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&#39;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&#39;t migrated @RequiresProject and @RequiresResources yet, so you&#39;re doing the right thing. <div><div class="im"><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&#39;t say it&#39;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 &quot;command-per-method&quot; strategy but we haven&#39;t completed it yet.</div><div><div class="im"><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&lt;Resource&lt;?&gt;&gt; variable.</div><div><div class="im"><br><blockquote type="cite">
<div dir="ltr">
<div>4) Is there such a thing as setup command? I think there&#39;s no need, but still I&#39;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 class="im"><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&#39;t get how facets can. Or should they at all write anything?</div>
</div></blockquote></div>Facets can&#39;t write messages for now, but we should consider doing it so it if makes sense.</div><div><br></div><div><div class="im"><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&lt;PickupResource&gt;::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 class="im"><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&#39;t figure out how I can rework complete methods from Forge 1, that were using CommandCompleterState parameter. I couldn&#39;t find samples</div>
</div></blockquote></div>In the UICommand.initializeUI method, you call setCompleter for the desired injected input</div><div><div class="im"><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&#39;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 class="im"><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 class="im"><br><blockquote type="cite"><div dir="ltr"><div>So, that&#39;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&#39;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 href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a></span><br>
<span><a 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 href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a 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>