| // |
| // Licensed to the Apache Software Foundation (ASF) under one |
| // or more contributor license agreements. See the NOTICE file |
| // distributed with this work for additional information |
| // regarding copyright ownership. The ASF licenses this file |
| // to you under the Apache License, Version 2.0 (the |
| // "License"); you may not use this file except in compliance |
| // with the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, |
| // software distributed under the License is distributed on an |
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| // KIND, either express or implied. See the License for the |
| // specific language governing permissions and limitations |
| // under the License. |
| // |
| |
| = DefFaqMapApisToTasks |
| :jbake-type: wiki |
| :jbake-tags: wiki, devfaq, needsreview |
| :jbake-status: published |
| :keywords: Apache NetBeans wiki DefFaqMapApisToTasks |
| :description: Apache NetBeans wiki DefFaqMapApisToTasks |
| :toc: left |
| :toc-title: |
| :syntax: true |
| |
| == What API do I use for ... |
| |
| Here is a list of common things people need to do, and a very short description of how you do them. From here, use the Javadoc and tutorials to get more information. |
| |
| == I want to ... |
| |
| === Show my component in the main window |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-openide-windows/overview-summary.html[Window System API]. You will want to create a subclass of link:http://bits.netbeans.org/dev/javadoc/org-openide-windows/org/openide/windows/TopComponent.html[TopComponent], a JPanel-like class, and call its `open()` method to show it. |
| |
| === Write to the output window |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-openide-io/overview-summary.html[I/O API]. Call `IOProvider.getDefault().getInputOutput("Something")`. The object returned has getters for standard output, standard error and input streams which write to and read from a tab in the output window. |
| |
| === Show a Tree, List or other control with a list of some objects |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-openide-nodes/overview-summary.html[Nodes API] to create a hierarchy of link:http://bits.netbeans.org/dev/javadoc/org-openide-nodes/org/openide/nodes/Node.html[Node] objects, each representing one object in your data model. Then use the link:http://bits.netbeans.org/dev/javadoc/org-openide-explorer/overview-summary.html[Explorer API] to show the Nodes - it contains tree, list, table, combo box and other controls which can show a hierarchy of Nodes. Nodes are very easy to add popup menus to, decorate with icons and html-ized display names, etc. and are a lot less work than using Swing components directly. See also the link:http://platform.netbeans.org/tutorials/nbm-nodesapi2.html[Nodes API Tutorial]. |
| |
| === Provide an Editor for a particular kind of file |
| |
| Use the new File Type template. You will end up using the link:http://bits.netbeans.org/dev/javadoc/org-openide-loaders/overview-summary.html[Data Systems API] (DataObject, DataLoader, etc.) and link:http://bits.netbeans.org/dev/javadoc/org-openide-nodes/overview-summary.html[Nodes API] primarily, plus the link:http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/overview-summary.html[Filesystems API] for accessing and parsing the file. The link:http://bits.netbeans.org/dev/javadoc/org-openide-text/overview-summary.html[Text API] provides general support for creating editors for files. |
| |
| === Add a menu item to the main menu |
| |
| No specific NetBeans APIs are needed - you can just create a subclass of Swing's `AbstractAction`, and link:DevFaqActionAddMenuBar.asciidoc[register it in your modules layer.xml file]. Or, use the new Action template in the IDE to generate a subclass of `SystemAction` for you and all the registration code, and fill in the action-performing logic. |
| |
| === Show content in the Navigator window when a file of a certain type is selected |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-netbeans-spi-navigator/overview-summary.html[Navigator API] to create a navigator panel provider; you then somehow parse the file and can create any component you want to show in the Navigator, and populate it with whatever you want. |
| |
| === Show a progress bar |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-netbeans-api-progress/overview-summary.html[Progress API] - call `ProgressHandleFactory` to create a `ProgressHandle` for you. That is an object with methods for setting the progress, status text, number of steps, etc. and is fairly self-explanatory. Remember to make sure the code showing progress is not running in the AWT Event thread. |
| |
| === Set the main window's statusbar text |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-openide-awt/overview-summary.html[UI Utilities API]. Simply call `StatusDisplayer.getDefault().setStatusText()`. |
| |
| === Allow other modules to register objects and then find those objects dynamically at runtime |
| |
| Define a folder in the link:DevFaqSystemFilesystem.asciidoc[System Filesystem] in the XML layer file of your module. Other modules can register instances of whatever class you specify by declaring `.instance` files in their own XML layer files. You can find them at runtime using `Lookups.forPath("path/to/my/folder")` to get an instance of link:DevFaqLookup.asciidoc[Lookup] that you can query for these objects. |
| |
| === Save some settings persistently |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-openide-util/overview-summary.html[Utilities API], specifically link:http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/NbPreferences.html[NbPreferences] - which is just an implementation of the JDK's Preferences API which stores things in the user's settings directory rather than globally. It's just like using standard JDK Preferences. |
| |
| === Run some code at application startup/shutdown |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-openide-modules/overview-summary.html[Module System API]. Implement a subclass of link:http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/ModuleInstall.html[ModuleInstall] and override `restored()`, `close()`, etc. Remember it is best to avoid running code on startup unless you really need to. |
| |
| === Add a Panel to the Options dialog |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-options-api/overview-summary.html[Options API], implementing link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-options-api/org/netbeans/spi/options/OptionsCategory.html[OptionsCategory] to define the category in the dialog and link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-options-api/org/netbeans/spi/options/OptionsPanelController.html[OptionsPanelController] to manage the UI component. |
| |
| === Find/listen to/manipulate the set of open projects |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectuiapi/overview-summary.html[Project UI API], specifically link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectuiapi/org/netbeans/api/project/ui/OpenProjects.html[OpenProjects]. |
| |
| === Create a graph editor such as the Mobility Pack uses |
| |
| Use the link:http://bits.netbeans.org/dev/javadoc/org-netbeans-api-visual/overview-summary.html[Visual Library], which builds on top of Swing to make animated, graph-oriented UIs easy to build. More info, tutorials and webcasts can be found in the link:http://platform.netbeans.org/graph[platform.netbeans.org/graph] project. |
| |
| === Apache Migration Information |
| |
| The content in this page was kindly donated by Oracle Corp. to the |
| Apache Software Foundation. |
| |
| This page was exported from link:http://wiki.netbeans.org/DefFaqMapApisToTasks[http://wiki.netbeans.org/DefFaqMapApisToTasks] , |
| that was last modified by NetBeans user Skygo |
| on 2013-12-13T23:52:13Z. |
| |
| |
| *NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed. |