Java Code Examples for org.openide.loaders.DataObject#getLookup()
The following examples show how to use
org.openide.loaders.DataObject#getLookup() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoverageSideBar.java From netbeans with Apache License 2.0 | 6 votes |
private void runAction(String action) { Project project = getProject(); if (project != null) { Lookup lookup = project.getLookup(); if (fileForDocument != null) { try { DataObject dobj = DataObject.find(fileForDocument); lookup = dobj.getLookup(); } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace(ex); } } ActionProvider provider = project.getLookup().lookup(ActionProvider.class); if (provider != null) { if (provider.isActionEnabled(action, lookup)) { provider.invokeAction(action, lookup); } } } }
Example 2
Source File: PropertiesDataObjectTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testLookup() throws Exception { clearWorkDir(); File propFile = new File(getWorkDir(), "foo.properties"); propFile.createNewFile(); DataObject propDO = DataObject.find(FileUtil.toFileObject(propFile)); Lookup lookup = propDO.getLookup(); PropertiesEncoding encoding = lookup.lookup(PropertiesEncoding.class); assertNotNull(encoding); assertSame(encoding, lookup.lookup(FileEncodingQueryImplementation.class)); }
Example 3
Source File: JmeGenericControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public JmeGenericControl(Control control, DataObject dataObject) { //TODO: lookup content! (control etc) super(Children.LEAF, new ProxyLookup(dataObject.getLookup(), new DynamicLookup(new InstanceContent()))); lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent(); this.control = control; this.dobject = dataObject; lookupContents.add(this); lookupContents.add(control); setName(control.getClass().getName()); }
Example 4
Source File: SimpleES.java From netbeans with Apache License 2.0 | 4 votes |
public SimpleES(DataObject obj, Entry entry, CookieSet set, Callable<Pane> paneFactory) { super(obj, obj.getLookup(), new Environment(obj, entry)); this.set = set; this.factory = paneFactory; }
Example 5
Source File: CSSUtils.java From netbeans with Apache License 2.0 | 4 votes |
/** * Opens the specified file at the given position. The position is either * offset (when {@code lineNo} is -1) or line/column otherwise. * This method has been copied (with minor modifications) from UiUtils * class in csl.api module. This method is not CSS-specific. It was placed * into this file just because there was no better place. * * @param fob file that should be opened. * @param lineNo line where the caret should be placed * (or -1 when the {@code columnNo} represents an offset). * @param columnNo column (or offset when {@code lineNo} is -1) * where the caret should be placed. * @return {@code true} when the file was opened successfully, * returns {@code false} otherwise. */ private static boolean openAt(FileObject fob, int lineNo, int columnNo) { try { DataObject dob = DataObject.find(fob); Lookup dobLookup = dob.getLookup(); EditorCookie ec = dobLookup.lookup(EditorCookie.class); LineCookie lc = dobLookup.lookup(LineCookie.class); OpenCookie oc = dobLookup.lookup(OpenCookie.class); if ((ec != null) && (lc != null) && (columnNo != -1)) { StyledDocument doc; try { doc = ec.openDocument(); } catch (UserQuestionException uqe) { String title = NbBundle.getMessage( CSSUtils.class, "CSSUtils.openQuestion"); // NOI18N Object value = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation( uqe.getLocalizedMessage(), title, NotifyDescriptor.YES_NO_OPTION)); if (value != NotifyDescriptor.YES_OPTION) { return false; } uqe.confirmed(); doc = ec.openDocument(); } if (doc != null) { boolean offset = (lineNo == -1); int line = offset ? NbDocument.findLineNumber(doc, columnNo) : lineNo; int column = offset ? columnNo - NbDocument.findLineOffset(doc, line) : columnNo; if (line != -1) { Line l = lc.getLineSet().getCurrent(line); if (l != null) { l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column); return true; } } } } if (oc != null) { oc.open(); return true; } } catch (IOException ioe) { Logger.getLogger(CSSUtils.class.getName()).log(Level.INFO, null, ioe); } return false; }
Example 6
Source File: AbstractSceneExplorerNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public AbstractSceneExplorerNode(Children children, DataObject dataObject) { super(children, new ProxyLookup(dataObject.getLookup(), new DynamicLookup(new InstanceContent()))); this.dataObject = dataObject; lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent(); }
Example 7
Source File: AbstractSceneExplorerNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public AbstractSceneExplorerNode(DataObject dataObject) { super(Children.LEAF, new ProxyLookup(dataObject != null ? dataObject.getLookup() : Lookup.EMPTY, new DynamicLookup(new InstanceContent()))); this.dataObject = dataObject; lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent(); }
Example 8
Source File: JShellDataObject.java From netbeans with Apache License 2.0 | 2 votes |
/** Constructor. * @param obj data object to work on * @param set set to add/remove save cookie from */ public SimpleES (DataObject obj, MultiDataObject.Entry entry) { super(obj, obj.getLookup(), new ESEnv(obj, entry)); }
Example 9
Source File: DataEditorSupport.java From netbeans with Apache License 2.0 | 2 votes |
/** Editor support for given data object. The content of editor is taken * from the primary file of the data object. The lookup can be anything, * but it is recommended to use {@link DataObject#getLookup()}. * * @param obj object to create editor for * @param lkp lookup to use. if <code>null</code>, then {@link DataObject#getLookup()} is used. * @param env environment responsible for loading/storing the strams * @since 7.28 */ public DataEditorSupport(DataObject obj, @NullAllowed Lookup lkp, CloneableEditorSupport.Env env) { super (env, lkp == null ? obj.getLookup() : lkp); this.obj = obj; }