Re: MultiView Element help

geertjan wielenga <[email protected]> Thu, 13 Jul 2017 13:42:37 +0200
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Organization Oracle Corporation
Message-ID <[email protected]>
http://plugins.netbeans.org/plugin/14239/jpanel-template-sample

Install the above, works fine in NetBeans IDE 8.2, and you'll have a new 
sample project in the New Project dialog that does what you're looking for.

Gj


On 13-7-2017 6:18, merlin dragonfire wrote:
>
> I am trying to create my own custom "form" for Java Netbeans. Sort-of 
> like the swing GUI project templates that you can find in the Netbeans 
> new file window. I, so far, have been able to create and register a 
> Java template to the Netbeans new file prompt. Now I have ran into a 
> problem. I cannot figure out how to add a multi-view window to the 
> template. I have been trying to use the new file type to create it but 
> it does not show up.
>
> Sorry if this is confusing.
>
>
>   Here is an Example Representation of What I Have So-Far:
>
>  1. MyExampleTemplate.java.template
>  2. package-info.java
>  3. MyExampleVisualElement.java
>
> ------------------------------------------------------------------------
> |// Most of this is automatically generated by the Netbeans New File 
> Template. // I have Included These Files in the case they do not 
> generate the 
> [email protected](...)@Messages(...)publicfinalclassMyExampleVisualElementextendsJPanelimplementsMultiViewElement{privateMyExampleDataObjectobj;privateJToolBartoolbar 
> =newJToolBar();privatetransientMultiViewElementCallbackcallback;publicMyExampleVisualElement(Lookuplkp){//Is 
> this good or do I need to do somthing here to connect it?obj 
> =lkp.lookup(MyExampleDataObject.class);assertobj 
> !=null;initComponents();}@OverridepublicStringgetName(){return"MyExampleVisualElement";}//Warning 
> as well as initComponents() Generated by Form. 
> @OverridepublicJComponentgetVisualRepresentation(){returnthis;}@OverridepublicJComponentgetToolbarRepresentation(){returntoolbar;}@OverridepublicAction[]getActions(){returnnewAction[0];}@OverridepublicLookupgetLookup(){returnobj.getLookup();}//Overriden 
> blank void methods excluded from example: componentOpened, 
> componentClosed, componentShowing, componentHidden, 
> componentActivated, componentDeactivated 
> @OverridepublicUndoRedogetUndoRedo(){returnUndoRedo.NONE;}@OverridepublicvoidsetMultiViewCallback(MultiViewElementCallbackcallback){this.callback 
> =callback;}@OverridepublicCloseOperationStatecanCloseElement(){returnCloseOperationState.STATE_OK;}}|
>
>  4. MyExampleDataObject.java
>
> ------------------------------------------------------------------------
> |@Messages({...})@MIMEResolver.ExtensionRegistration(...)@DataObject.Registration(...)@ActionReferences({...})publicclassMyExampleDataObjectextendsMultiDataObject{publicMyExampleDataObject(FileObjectpf,MultiFileLoaderloader)throwsDataObjectExistsException,IOException{super(pf,loader);registerEditor("application/my-meta-data+xml",true);}@OverrideprotectedintassociateLookup(){return1;}@MultiViewElement.Registration(...)@Messages(...)publicstaticMultiViewEditorElementcreateEditor(Lookuplkp){returnnewMultiViewEditorElement(lkp);}}|
>
> After running I can create my object in Java however their is no 
> /'Visual'/ button on the bar. Only the /'Source'/ and /'History'/ 
> Buttons show up.
>
> Anyway I simply want to now the correct format required by Netbeans 
> and its OpenIDE as to how to utilize multi-windows. An example or a 
> link to an example would be fine.
>
> I have tried looking at the Netbeans Documentation however I find it 
> to be confusing and unhelpful. I believe that the problem may be 
> occurring do to the fact that I am trying to add a template to an 
> existing Netbeans extension type(ex:.java, .xml, .exe). I have tried 
> to look online howerever I can only fine examples and tutorials for 
> creating such items for new unregistered extentions(ex: .mytag, 
> .pasta, .fish, .abc).
>
> Some sites I have looked at but did not help are, svn Multiview API 
> Old Tutorial 
> <https://svn.netbeans.org/svn/platform%7Eplatform-content/trunk/tutorials/67/nbm-multiview-api-old.html>, 
> and the Javadoc 
> <http://bits.netbeans.org/8.0/javadoc/org-netbeans-core-multiview/overview-summary.html>.
>
> To Duplicate:
>
>  1. Create a Netbeans Module Project
>      1. In the Netbeans IDE 8.2 go-to the New Project button → Select
>         /Netbeans Modules/ → /Module/ and then Click Next
>      2. Should be a radio button Defaulted on 🔘/Standalone Module/ →
>         Next to the /Netbeans Platform/ Label → /Development IDE/ then
>         enter in a name like 'NewFileExample' and Click Next
>      3. Create a Code Name Base and Click Finish
>  2. Insert a 16x16 picture ether in |.gif| or |.png| format into the
>     file or somewhere accessible.
> 3.
>
>     Create a /'New File Type'/
>
>      1. Make sure to be selected in your project's package where the
>         Bundle object is located → Go to New File → Select /Module
>         Development/ → then /File Type/ then Click Next
>      2. type in a custom MIME Type such as /'text/x-mymime'/
>      3. select the 🔘/by Filename Extension/ radio button then → go to
>         the text box next to the /Extension(s):/ box.
>      4. From here there are three different things i have overall
>         tried. Choose one of the file extensions:
>           * |.java|
>           * |.mycustomextention|
>           * |.form|
>      5. Click Next
>      6. Enter in a Class Prefix like /'ExampleFile'/ then below select
>         the image file that we got ready in Step 2. (Make sure that
>         the ☑/Use Multiveiw/ Checkbox is checked)
>     7.
>
>         check the generated files list below to match this:
>
>         Created Files:
>
>           * src/../[file path]/../ [*/MyClassPrefix/*] DataObject.java
>           * src/../[file path]/../ [*/MyClassPrefix/*]
>             Template.[/myextention/]
>           * src/../[file path]/../ [*/MyClassPrefix/*] VisualElement.form
>           * src/../[file path]/../ [*/MyClassPrefix/*] VisualElement.java
>           * src/../[file path]/../package-info.java /(unless already
>             created)/
>           * /[file path to image]// [*/IconName/*] .png
>
>         Modified Files:
>
>           * nbproject/project.xml
>           * src/../[file path]/../package-info.java /(unless not
>             created yet)/
>     8.
>
>         Click Finish
>
> 4.
>
>     If you used the file Extention |.java| rename your template file
>     extention to: |.java.template| and go into the
>     |package-info.java| to change |content =
>     "MyClassPrefixTemplate.java"| to |content =
>     "MyClassPrefixTemplate.java.template"|
>
>  5. Click run to run the code.
>
> The Outcomes I got were:
>
> # For |.java| a generated |java| file in the Others template with only 
> /'Source'/ and /'History'/.
> # For a custom extension like |.mycustomextension| a generated 
> |mycustomextension| file in the Others template with only 
> /'Source'/ and /'History'/.
> # For |.form| a generated |.from| file in the Others template with only 
> /'Source'/ and /'History'/ however if a generated |form| and 
> |java|file is created the their will be other Bars that show up.
>
> Sorry about if this is confusing.
> thanks,
> Merlin D.
>
>
> __________________________________________________________________________________
>
>
>
> also here is an added item to help clarify as an example :
>
> I am trying to do something _like_ this:
>
> ​[Note: this is just an example as well as the file still being .java 
> with some other extension (ex: .world ) that would function similarly 
> to a .form]