In the Java editor in the IDE, type an abbreviation listed below, press the expansion key (which is Tab, by default), and then the expanded text shown below will be generated.
Description: Convert FileObject to DataObject
Expands to:
try {Example:
${dobType type="org.openide.loaders.DataObject" editable="false" default="DataObject"} ${dob newVarName default="dob"} = ${dobType}.find(${fo instanceof="org.openide.filesystems.FileObject" default="fo"});
${cursor}
} catch (${etype type="org.openide.loaders.DataObjectNotFoundException" default="DataObjectNotFoundException" editable="false"} ${exName newVarName default="ex" editable="false"}) {
${exctype type="org.openide.util.Exceptions" editable="false" default=""}.printStackTrace(${exName});
}
try {
DataObject dataObject = DataObject.find(myFo);
} catch (DataObjectNotFoundException dataObjectNotFoundException) {
Exceptions.printStackTrace(dataObjectNotFoundException);
}
Description: Convert FileObject to java.io.File
Expands to:
${fileType type="java.io.File" default="File" editable="false"} ${file newVarName default="f"} = ${FileUtilType type="org.openide.filesystems.FileUtil" editable="false")}.toFile(${fo instanceof="org.openide.filesystems.FileObject" default="fo"});Example:
${cursor}
File file = FileUtil.toFile(myFo);
Description: Convert java.io.File to FileObject
Expands to:
${fileType type="org.openide.filesystems.FileObject" default="FileObject" editable="false"} ${file newVarName default="f"} = ${FileUtilType type="org.openide.filesystems.FileUtil" editable="false")}.toFileObject(${FileUtilType}.normalizeFile(${f instanceof="java.io.File" default="f"}));Example:
${cursor}
FileObject fileObject = FileUtil.toFileObject(FileUtil.normalizeFile(myFile));
Description: Find all implementations of a certain type registered in META-INF/services.
Expands to:
${coltype type="java.util.Collection" default="Collection" editable="false"} ${obj newVarName default="obj"} = ${lkptype editable="false" default="Lookup" type="org.openide.util.Lookup"}.getDefault().lookupAll(${Type}.class);Example:
${cursor}
Collection<? extends Type> collection = Lookup.getDefault().lookupAll(Type.class);
Variation: lka (i.e., the first character is lowercase)
Description: Find all implementations of a certain type from a local lookup, e.g., TopComponent, Node, or DataObject.
Example:
Collection<? extends Type> collection = myNode.lookupAll(Type.class);
Description: Find a single typed implementation registered in META-INF/services.
Expands to:
${Type} ${obj newVarName default="obj"} = ${lkptype editable="false" default="Lookup" type="org.openide.util.Lookup"}.getDefault().lookup(${Type}.class);Example:
${cursor}
Type type = Lookup.getDefault().lookup(Type.class);
Variation: lkp (i.e., the first character is lowercase)
Description: Find a single implementation of a certain type from a local lookup, e.g., TopComponent, Node, or DataObject.
Example:
Type type = myNode.lookup(Type.class);
Description: Assign a single typed instance from META-INF/services to a Result object, to which you can listen for changes.
Expands to:
${coltype type="org.openide.util.Lookup.Result" default="Lookup.Result" editable="false"} ${obj newVarName default="res"} = ${lkptype editable="false" default="Lookup" type="org.openide.util.Lookup"}.getDefault().lookupResult(${Type}.class);Example:
${cursor}
Lookup.Result<? extends Type> res = Lookup.getDefault().lookupResult(Type.class);
Variation: lkr (i.e., the first character is lowercase)
Description: Assign a single typed instance from a local lookup to a Result object, to which you can listen for changes.
Example:
Result<? extends Type> all = myNode.lookupResult(Type.class);
Description: Create a lookup for a local object, e.g., TopComponent, Node, or DataObject.
Expands to:
${Type} ${obj newVarName default="obj"} = ${prov instanceof="org.openide.util.Lookup.Provider"}.getLookup().lookup(${Type}.class);Example:
${cursor}
Type type = myNode.getLookup().lookup(Type.class);
Description: Create code for writing text obtained from a Bundle.properties file into the status bar.
Expands to:
${coltype type="org.openide.awt.StatusDisplayer" default="StatusDisplayer" editable="false"}.getDefault().setStatusText(${bundletype type="org.openide.util.NbBundle" default="NbBundle" editable="false"}.getMessage(getClass(), "${KEY}"));Example:
${cursor}
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(getClass(), "KEY"));
Description: Get a text from a Bundle.properties file.
Expands to:
${coltype type="org.openide.util.NbBundle" default="NbBundle" editable="false"}.getMessage(${classVar editable="false" currClassName default="getClass()"}.class, "${KEY}")Example:
NbBundle.getMessage(DemoAction.class, "KEY")
Variation: nbb (i.e., add an additional 'b' character)
Description: Pass in parameters for formatting the text.
Example:
NbBundle.getMessage(DemoAction.class, "KEY", params)