Netbeans platform open file action


















The IDE launches with the new module installed. To confirm that the new module is working correctly, create a new project and then use the New File wizard to create an abc file:. For example, you can create a simple Java application and then open the New File wizard and choose the Empty Abc file type in the Other category. When you create the new file, specify a source package if you want to see the file in the Projects window.

By default the wizard for the new file type will create the file at the root level of the project. After you create the new abc file you can see that the file is displayed in the Projects window with the icon for the file type.

If you open the file in the editor you can see that the contents of the new file were generated from the file template. You can see that your file type is now recognized by the application.

In this section you will add an action that can be invoked from the popup menu when the user right-clicks the node of a file conforming to your new file type. When you click Finish, MyAction. In this example you will add some code that uses DialogDisplayer to open a dialog box when the action is invoked from the popup menu. Fix the missing import statements Ctrl-Shift-I and then confirm that your import statements are as shown below:.

To run the module you will first need to clean and build the module. When you right-click on a node of the abc file type you will see that My Action is one of the items in the popup menu. This tutorial demonstrated how to create and run a NetBeans module that you created from a Maven Archetype. You also learned a little about how to work with file types, but for more details you should look at the Ant-Based NetBeans File Type Tutorial. Send Us Your Feedback.

For more information about creating and developing applications, see the following resources. NetBeans Platform Learning Trail. If you have any questions about the NetBeans Platform, feel free to write to the mailing list, dev platform. Even though it is a separate product, there is little need to download the NetBeans Platform separately—you can develop the rich-client application in the IDE and then exclude the modules that are specific to the IDE but that are superfluous to your application.

Only when you want to use a different version of the platform than is included in the IDE, does it make sense to download the NetBeans Platform and install the modules that define the application into it. The NetBeans Platform provides an application's common requirements—such as menus, document management, and settings—right out of the box.

Building an application "on top of NetBeans" means that, instead of writing applications from scratch, you only provide the parts of your application that the NetBeans Platform doesn't already have. At the end of the development cycle, you bundle your application with the NetBeans Platform, saving you time and energy and resulting in a solid, reliable application.

The following table outlines the development cycle of NetBeans modules, from creation to distribution. Optionally, if the module will consist of a collection of module projects, use the module suite project template.

For example, the collection may make use of external JAR files. If this is the case, put the external JAR files on the module's classpath by using one or more library wrapper module project templates. After using a wizard, double-click the file that you would like to edit. Use the Source Editor to edit the file. A rich-client application is a complete, functioning, standalone Swing application, built on top of the NetBeans Platform.

The following table outlines the development cycle of rich-client applications, from creation to distribution. Optionally, before going further, brand the application by providing a splash screen and other external customizations.

Right-click the application node again, choose Branding , and then use the tabs Basic, Splash Screen, Window System, and Resource Bundles to brand these details of the application. The application's executable and its clusters are packaged in a ZIP distribution. The application's JNLP files are created. Right-click the application project and choose Project Properties. In the Installer panel, specify the installers you would like to create.

Close the Project Properties dialog, right-click the application project and choose Package as Installers. The installers are created in the application 'dist' folder, visible in the Files window Ctrl Select the right template for your project.

NetBeans Module. ZIP Distribution. Java Web Start. A library can contain multiple JAR files. The IDE contains a set of standard project templates and file templates for setting up modules. The standard distribution of the IDE contains the following module project templates:. Use a module project as the place where you code your module. Library Wrapper Module. Use library wrapper module projects to put one or more library JAR files on a module's classpath.

Module Suite. Use a module suite project to group and deploy a set of interdependent module projects and library wrapper module projects. NetBeans Platform Application. Use a NetBeans Platform Application project as the skeleton framework as the starting point of your own applications. Creates an action that can be invoked from a menu item, pop-up menu, toolbar button, or keyboard shortcut.

Code Generator. Creates a new menu item in the Insert Code popup in the editor of your choice. Java SE Library Descriptor. JavaHelp Help Set. Creates all the files needed for building a JavaHelp help set. Layout of Windows. Lets you design the layout of the windows in your application.

Project Template. Adds a new template to the New Project wizard. Quick Search Provider. Creates a new entry in the Quick Search field. Update Center. Registers an update center in the Plugins manager. As a result, the user does not need to manually register the Update Center via the Plugins manager. Creates a new window with an Open action invoked from a menu item. Creates a new wizard for creating, for example, new files in the IDE.

XML Layer. Creates a layer file for registering folders and files into the central registry, also known as the System FileSystem. Other file templates are used for bundling supporting items, such as project samples and JavaHelp help sets, with your modules. The IDE contains a set of standard project templates for module development.

Module projects, library wrapper module projects, and module suite projects have an Important Files node where the IDE stores the Ant script, layer. The following table lists the highlights of the Important Files node and whether each is found in a module project template, a library wrapper module project template, a module suite project, or all three:.

Use a module project template to create a module project. The module project is the place where you code your module. Module projects implement the module's features and functionality that extend the NetBeans APIs, which you kickstart by using file templates. In addition, module projects include the business logic that integrate the library wrapper module projects into the module. Code housed in module projects also provides, for example, the user interface for receiving and processing user input.

From the NetBeans Modules category, select Module. Click Next. Project Name. Specifies the folder in which the project will be housed, prepended by the project location, which is specified in the next field. Project Location. Specifies the location where you want to store the project metadata and source code. Project Folder.

Specifies the folder where you want to store the project metadata and source code. The folder is a concatenation of the project location and the project name.

Standalone Module. Specifies that the module does not belong to a module suite. In addition, you must specify which platform the module will be compiled and deployed against. Add to Module Suite. Specifies that the module belongs to a module suite. If the module suite is not currently open in the IDE, click Browse to locate the module suite in your filesystem. Code Name Base. Specifies a unique name for the module. A main package will be created with the same name as the code name base.

If your code name base is org. Module Display Name. Specifies the name that will be displayed in the Projects window. Localizing Bundle. Specifies location of the Bundle. Normally, the default suggestion should be appropriate.

OSGi Bundle. The difference will be visible in the Manifest file. Use a library wrapper module project template to create a library wrapper module project. Library wrapper module projects put one or more library JAR files on a module's classpath. You have to export some or all of the packages as public, and you need to have a regular module depend on it, or the library wrapper module becomes useless.

The wizard that you use to create the library wrapper module project automatically exports as public any packages it finds in the JARs. Specifies one or more JAR files that make up the library. You are encouraged to only include more than one JAR file if their versions are likely to increment at the same time.

Use a module suite project template to create a module suite. A module suite groups and deploys a set of interdependent module projects and library wrapper module projects.

For rich-client applications, the module suite project is a skeleton application to which you can attach a splash screen, a progress bar, a name for the application's executable, and a title for the application's titlebar.

Specifies the location where you want to store the project metadata. NetBeans Platform. Specifies the platform against which the module will be compiled and deployed. This template project provides a skeleton application to which you can attach a splash screen, a progress bar, a name for the application's executable, and a title for the application's titlebar. They are divided into specific APIs for dealing with different types of functionality. Templates that users build on when creating their own project.

Samples that illustrate some aspect of project functionality. Samples are a kind of project template; they have the same behavior as project templates, but they are used for a different purpose. A project template is made available to the IDE's New Project wizard once it has been registered in the layer. You use the New Project Template wizard to create the basic files and to register the template in the layer.

Before you can use the New Project Template wizard, you must have project in the IDE that is structured in exactly the way that you would like it to be available in the New Project wizard.

For example, if you are going to create a new project sample, you must first lay it out in the IDE. When you make the module that contains the new project template available as an NBM file, the user can install it via the Plugins manager and then, once it has been successfully installed, select it from the New Project wizard. As a result, the user does not need to manually register the Update Center in the Plugins manager. Once you have worked through a wizard, you build your module's functionality on top of the files that the wizard creates for you.

The following table lists the Javadoc that you will need to refer to when building on top of the skeleton API implementations:. Project API. Actions are defined by the Actions API. The Actions API is a standard representation of the actions a user can invoke. It provides an interface to such IDE elements as toolbars, menus, and keyboard shortcuts, allowing third parties to create actions that are sensitive to context and invocable in more than one way.

The Actions API offers the ability to write the action once, and have it automatically apply as appropriate. For example, a user action might both show up in a toolbar and be selected by a keyboard shortcut, all from the same implementation.

Actions are typically presented in pop-up menus, or attached to a component such as a window, node, or data object. The New Action wizard creates a new action. Always Enabled. Specifies that the action will be invoked from a menu item in the menu bar, from a toolbar button in a toolbar, or from a keyboard shortcut anywhere in the IDE. Conditionally Enabled. Specifies the classes for which the action will be created. This is normally one of your own business objects. However, optionally, you can also include one or more of the following, which creates the action for all classes that subclass them:.

User May Select Multiple Nodes. Specifies the conditions under which the action will be enabled. By default, will be enabled if one, and only one, node holding the business object of interest is selected. If checked, it will also be enabled if multiple nodes all holding the desired business object s are selected.

In the GUI Registration page, you have to specify how the user will be able to call the new action. Specifies where the action will be displayed in the Keymap section of the Options window. Global Menu Item. Specifies the menu where the action will be displayed as an item. You can also specify the position within the menu, and whether you want a separator to appear before it, after it, or both. Global Toolbar Button. Specifies the toolbar where the action will be displayed as a button.

You can also specify the position within the toolbar. Global Keyboard Shortcut. Specifies a shortcut that will invoke the action. Only if Conditionally Enabled is selected in the Action Type page can you set the following items:. File Type Context Menu Item. Specifies the file type where the action will be displayed in the pop-up menu.

Editor Context Menu Item. Specifies the IDE editor where the action will be displayed in the pop-up menu. Specifies the icon that will accompany the action.

For example, if the action will be invoked by a toolbar button, the icon specified here is displayed on the toolbar button.

Specifies the name of the package where the class will be housed. Tweak the layer. A code generator is an action that is added to the Insert Code popup, which the user invokes when pressing Alt-Insert. When invoked, the action is intended to insert code into the editor. Traditionally, code generators are only found in Java documents but, from NetBeans 6. A code generator is an item added to the popup that appears in an editor when Alt-Insert is pressed.

By default, for example, when you press Alt-Insert in a Java class, a constructor can be generated. Generate Code Generator Context Provider.

Specifies that a class should be created, and registered in the layer. Many file types are recognized by default by the IDE. Recognition of a file type is generally made possible via its extension. All JSP files have a.

On the basis of this distinction, the IDE provides distinct functionality for these file types. For example, if you have a file type with the file extension. Whether an XML file has an. If the namespace of each distinguishable XML file is distinct, the namespace is used to distinguish the file types in this case. The New File Type wizard creates a new file type. MIME Type. Filename Extension. The file extension can optionally be preceded by a dot. Separators are commas, spaces, or both.

Therefore, all of the following are valid:. XML Root Element. The value that you specify is the namespace associated with the root element of your XML document. Note that this is not the same thing as the name of the root element. For example, in the following example XML document, the namespace is "sample":. Class Name. Specifies the name of the new files that will be generated. Specifies the icon that will accompany the new file type.

For example, when you see the new file type in the Projects window, Files window, or Favorites window, it will be identified by the icon specified here.

Use MultiView. Specifies that additional files should be generated as the starting point of an extensible multiview editor. Use the New Action wizard to add actions to the new file type's pop-up menu. When you do so, select Conditionally Enabled in the first page of the New Action wizard. Use the New Wizard wizard to create a New File wizard that the user will use to create new files of the new type defined in the New File Type wizard.

Use the New Project Template wizard to add a sample project containing example files of the new file type to the New Project wizard. A module installer is a Java class that provides hooks for running code on startup or when a module is loaded.

It can also run cleanup code when a module is uninstalled or disabled. Note : In general, using a module installer is not recommended, because it slows down startup time. Before using a module installer, make sure that there is no declarative way of doing what you are trying to do.

The main declarative way of installing items is to use the org. ServiceProvider annotation or create an XML layer file that declares information about the items your module is installing. Applications can install modules dynamically. Any application can include the Update Center module, to allow users of that application to download digitally-signed upgrades and new features via the web, directly into the running application.

Installing an upgrade or a new release does not force users to download the entire application again. And in an application with multiple modules, upgrades of specific functionality can be incremental, further improving customer response time and time-to-market.

A module installer for a NetBeans module or activator for an OSGi bundle is a Java class that provides hooks for running code on startup or when a module is loaded. This specifies the name of the package where the module installer will be housed.

The module installer will always be named Installer. An Options panel is a category of the Options window. The Options window is where the user defines settings, such as the location of the web browser used by the IDE. Create Secondary Panel. Specifies that the category will be displayed as an addition to an existing panel, for example, the Miscellaneous panel such as the "Ant" or "GUI Builder" panel in the IDE's Miscellaneous panel.

Create Primary Panel. Specifies that the category will be displayed as a primary panel such as the "General" panel in the IDE. Class Prefix. Specifies the prefix of the source files generated by the wizard. Specifies the name of the package where the source files will be housed. Quick search providers are registered in the layer. Provider Class Name. Specifies the class name of the stub that the wizard will generate.

Specifies the package where the stub class will be generated. Category Display Name. Specifies the display name of the category that the stub will create. Command Prefix. Specifies prefix for narrowing the search to the category that the stub will create.

Position in Popup. Specifies the position of the new item in the within the Quick Search feature. A window component creates a window also known as 'view' for a module. The main class in each of the modules that define these windows subclasses Class TopComponent. Understanding and working with the TopComponent class is the key to creating useful and reliable windows in the IDE.

By using the Window wizard, you can be sure of the success of the initial development phase. Window Position. Specifies the location of the window component when open in the IDE. Depending on the modules installed in the platform that forms the basis of your application, you're able to choose from several window positions, including the following:.

The window component will be available as a button on the bottom bar of the IDE. The window component will be available as a button on the left sidebar of the IDE. The window component will be available as a button on the right side of the Source Editor. Open on Application Start. Specifies whether the window component is open by default or not. Keep preferred size when slided-in. Specifies that the size of the window when minimized will be determined by the preferred size property of the window.

When selected, the following line is added to the TopComponent's constructor: putClientProperty "netbeans. TRUE ;. Maximization not allowed. Specify that the window should not have one or more features that it has by default. Specifies the name of the new Action and TopComponent classes. Specifies the icon that will accompany the window component. For example, you will see the icon in the label of the window component. Place the window component in a different position.

In the layer. Add your own code to componentOpened and componentClosed to specify what will happen when the window opens and closes. The Wizard API lets you create wizard panels that have steps, graphics, left side-bar text, and a user panel on the right. The Wizard wizard in the IDE helps you by creating several of the basic Java source files, containing sample code, for you.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.

Related Hot Network Questions. Question feed.



0コメント

  • 1000 / 1000