org.openide.loaders.DataObjectNotFoundException Java Examples
The following examples show how to use
org.openide.loaders.DataObjectNotFoundException.
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: HideField.java From netbeans with Apache License 2.0 | 6 votes |
public void run() { try { EditorCookie cook = DataObject.find(file).getLookup().lookup(EditorCookie.class); if (cook == null) { return; } JEditorPane[] arr = cook.getOpenedPanes(); if (arr == null) { return; } arr[0].setCaretPosition(caret); InstantRenamePerformer.invokeInstantRename(arr[0]); } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace(ex); } }
Example #2
Source File: JAXBWizardOpenXSDIntoEditorAction.java From netbeans with Apache License 2.0 | 6 votes |
protected void performAction(Node[] nodes) { Node node = nodes[ 0 ]; FileObject fo = node.getLookup().lookup(FileObject.class ); try { if ( fo != null ) { DataObject dataObject = DataObject.find( fo ); if ( dataObject != null ) { EditCookie ec = dataObject.getCookie(EditCookie.class ); if ( ec != null ) { ec.edit(); } } } } catch ( DataObjectNotFoundException donfe ) { donfe.printStackTrace(); } }
Example #3
Source File: TomcatModuleConfiguration.java From netbeans with Apache License 2.0 | 6 votes |
/** * WebappConfiguration initialization. This method should be called before * this class is being used. * * @param contextXml context.xml file. */ private void init(File contextXml) { //this.contextXml = contextXml; try { getContext(); } catch (ConfigurationException e) { LOGGER.log(Level.INFO, null, e); } if (contextDataObject == null) { try { contextDataObject = DataObject.find(FileUtil.toFileObject(FileUtil.normalizeFile(contextXml))); contextDataObject.addPropertyChangeListener(this); } catch(DataObjectNotFoundException donfe) { LOGGER.log(Level.FINE, null, donfe); } } }
Example #4
Source File: ResourceHyperlinkProcessor.java From netbeans with Apache License 2.0 | 6 votes |
private static boolean openFile(FileObject file) { if (file == null) { return false; } DataObject dObj; try { dObj = DataObject.find(file); } catch (DataObjectNotFoundException ex) { return false; } EditorCookie editorCookie = dObj.getCookie(EditorCookie.class); if (editorCookie == null) { return false; } editorCookie.open(); return true; }
Example #5
Source File: RecentFiles.java From netbeans with Apache License 2.0 | 6 votes |
private static Icon findIconForPath(String path) { FileObject fo = RecentFiles.convertPath2File(path); final Icon i; if (fo == null) { i = null; } else { DataObject dObj; try { dObj = DataObject.find(fo); } catch (DataObjectNotFoundException e) { dObj = null; } i = dObj == null ? null : new ImageIcon(dObj.getNodeDelegate().getIcon( BeanInfo.ICON_COLOR_16x16)); } return i; }
Example #6
Source File: MarkOccurrencesTest.java From netbeans with Apache License 2.0 | 6 votes |
private JavaSource openFile(String name) throws DataObjectNotFoundException, IOException, InterruptedException, InvocationTargetException { String dataDir = getDataDir().getAbsoluteFile().getPath(); File sample = new File(dataDir+"/projects/java_editor_test/src/markOccurrences",name); assertTrue("file "+sample.getAbsolutePath()+" does not exist",sample.exists()); fileObject = FileUtil.toFileObject(sample); dataObject = DataObject.find(fileObject); JavaSource js = JavaSource.forFileObject(fileObject); final EditorCookie ec = dataObject.getCookie(EditorCookie.class); ec.openDocument(); ec.open(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { JEditorPane[] panes = ec.getOpenedPanes(); editorPane = panes[0]; } }); return js; }
Example #7
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
public ModelSource createTestModelSource(FileObject fo, boolean editable) throws CatalogModelException{ final DataObject dobj; final CatalogModel catalogModel = createCatalogModel(fo); try { dobj = DataObject.find(fo); } catch (DataObjectNotFoundException ex) { throw new CatalogModelException(ex); } Lookup lookup = Lookups.proxy(new Lookup.Provider() { public Lookup getLookup() { return Lookups.fixed(new Object[] { dobj.getPrimaryFile(), getDocument(dobj.getPrimaryFile()), dobj, catalogModel }); } } ); return new ModelSource(lookup, editable); }
Example #8
Source File: RemoteStyleSheetCache.java From netbeans with Apache License 2.0 | 6 votes |
/** * Closes the given collection of files. * * @param files files to close. */ private static void closeFiles(final Collection<FileObject> files) { if (EventQueue.isDispatchThread()) { for (FileObject file : files) { try { DataObject dob = DataObject.find(file); Closable close = dob.getLookup().lookup(Closable.class); if (close != null) { close.close(); } } catch (DataObjectNotFoundException dnfex) { Logger.getLogger(RemoteStyleSheetCache.class.getName()).log(Level.INFO, null, dnfex); } } } else { EventQueue.invokeLater(new Runnable() { @Override public void run() { closeFiles(files); } }); } }
Example #9
Source File: EventSupport.java From netbeans with Apache License 2.0 | 6 votes |
private void handleInvalidDataObjectImpl(DataObject invalidDO) { invalidDO.removePropertyChangeListener(wlistener); if (fobj.isValid()) { // file object still exists try to find new data object try { DataObject dobjNew = DataObject.find(fobj); synchronized (DataObjectListener.this) { if (dobjNew == dobj) { return; } dobj = dobjNew; dobj.addPropertyChangeListener(wlistener); } assignDocumentListener(dobjNew); resetState(true, false, -1, -1, false); } catch (DataObjectNotFoundException e) { //Ignore - invalidated after fobj.isValid () was called } catch (IOException ex) { // should not occur Exceptions.printStackTrace(ex); } } }
Example #10
Source File: I18nOptions.java From netbeans with Apache License 2.0 | 6 votes |
/** Getter for last resource property. */ public DataObject getLastResource2(DataObject srcDataObject) { String path = getPreferences().get(PROP_LAST_RESOURCE2,null); if(path == null) { return null; } FileObject f = (srcDataObject != null) ? findFileObject(srcDataObject, path) : findFileObject(path); if ((f != null) && !f.isFolder() && f.isValid()) { try { return DataObject.find(f); } catch (DataObjectNotFoundException e) { /* The file was probably deleted or moved. */ getPreferences().remove(PROP_LAST_RESOURCE2); } } return null; }
Example #11
Source File: GitStatusNode.java From netbeans with Apache License 2.0 | 6 votes |
/** * Provide cookies to actions. * If a node represents primary file of a DataObject * it has respective DataObject cookies. */ @SuppressWarnings("unchecked") // Adding getCookie(Class<Cookie> klass) results in name clash @Override public Cookie getCookie(Class klass) { FileObject fo = getLookup().lookup(FileObject.class); if (fo != null) { try { DataObject dobj = DataObject.find(fo); if (fo.equals(dobj.getPrimaryFile())) { return dobj.getCookie(klass); } } catch (DataObjectNotFoundException e) { // ignore file without data objects } } return super.getCookie(klass); }
Example #12
Source File: GoToActionOrViewAction.java From netbeans with Apache License 2.0 | 6 votes |
private int getOffset(Lookup context) { EditorCookie editorCookie = context.lookup(EditorCookie.class); if (editorCookie != null) { return getOffset(editorCookie); } FileObject fo = FileUtils.getFileObject(context); if (fo == null) { return DEFAULT_OFFSET; } try { editorCookie = DataObject.find(fo).getLookup().lookup(EditorCookie.class); return getOffset(editorCookie); } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace(ex); } return DEFAULT_OFFSET; }
Example #13
Source File: ModelUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Opens a pom file at location defined in InputLocation parameter * @since 2.77 * @param location */ public static void openAtSource(InputLocation location) { InputSource source = location.getSource(); if (source != null && source.getLocation() != null) { FileObject fobj = FileUtilities.convertStringToFileObject(source.getLocation()); if (fobj != null) { try { DataObject dobj = DataObject.find(NodeUtils.readOnlyLocalRepositoryFile(fobj)); EditCookie edit = dobj.getLookup().lookup(EditCookie.class); if (edit != null) { edit.edit(); } LineCookie lc = dobj.getLookup().lookup(LineCookie.class); lc.getLineSet().getOriginal(location.getLineNumber() - 1).show(Line.ShowOpenType.REUSE, Line.ShowVisibilityType.FOCUS, location.getColumnNumber() - 1); } catch (DataObjectNotFoundException ex) { LOG.log(Level.FINE, "dataobject not found", ex); } } } }
Example #14
Source File: JspHyperlinkProvider.java From netbeans with Apache License 2.0 | 6 votes |
private void openInEditor(FileObject fObj) { if (fObj != null) { DataObject dobj; try { dobj = DataObject.find(fObj); } catch (DataObjectNotFoundException e) { Exceptions.printStackTrace(e); return; } if (dobj != null) { Node.Cookie cookie = dobj.getLookup().lookup(EditCookie.class); if (cookie != null) { ((EditCookie) cookie).edit(); } } } }
Example #15
Source File: TomcatInstanceNode.java From netbeans with Apache License 2.0 | 6 votes |
/** * Open server.xml file in editor. */ public void editServerXml() { FileObject fileObject = getTomcatConf(); if (fileObject != null) { DataObject dataObject = null; try { dataObject = DataObject.find(fileObject); } catch(DataObjectNotFoundException ex) { Logger.getLogger(TomcatInstanceNode.class.getName()).log(Level.INFO, null, ex); } if (dataObject != null) { EditorCookie editorCookie = (EditorCookie)dataObject.getCookie(EditorCookie.class); if (editorCookie != null) { editorCookie.open(); } else { Logger.getLogger(TomcatInstanceNode.class.getName()).log(Level.INFO, "Cannot find EditorCookie."); // NOI18N } } } }
Example #16
Source File: RecentFileAction.java From constellation with Apache License 2.0 | 6 votes |
/** * Fills submenu with recently closed files got from RecentFiles support */ private void fillSubMenu() { List<HistoryItem> files = RecentFiles.getRecentFiles(); for (final HistoryItem hItem : files) { // Attempt to create a menu item for the history item. // We will skip the creation if the file object corresponding to the // history item is null (indicating that the file no longer exists) // or if there is an issue loading the icon corresponding to the file. try { final FileObject fo = RecentFiles.convertPath2File(hItem.getPath()); if (fo != null) { JMenuItem jmi = newSubMenuItem(fo); menu.add(jmi); } } catch (DataObjectNotFoundException ex) { } } ensureSelected(); }
Example #17
Source File: BookmarkUtils.java From netbeans with Apache License 2.0 | 6 votes |
public static EditorCookie findEditorCookie(BookmarkInfo info) { EditorCookie ec = null; FileBookmarks fileBookmarks = info.getFileBookmarks(); if (fileBookmarks != null) { FileObject fo = fileBookmarks.getFileObject(); if (fo != null) { try { DataObject dob = DataObject.find(fo); ec = dob.getCookie(EditorCookie.class); } catch (DataObjectNotFoundException ex) { // Leave ec == null } } } return ec; }
Example #18
Source File: IDEServicesImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Override @NbBundle.Messages({"LBL_OpenDocument=Open Document", "# {0} - to be opened documents path", "MSG_CannotOpen=Could not open document with path\n {0}", "# {0} - to be found documents path", "MSG_CannotFind=Could not find document with path\n {0}"}) public void openDocument(final String path, final int offset) { final FileObject fo = findFile(path); if ( fo != null ) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { DataObject od = DataObject.find(fo); boolean ret = NbDocument.openDocument(od, offset, -1, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); if(!ret) { notifyError(Bundle.LBL_OpenDocument(), Bundle.MSG_CannotOpen(path)); } } catch (DataObjectNotFoundException e) { IDEServicesImpl.LOG.log(Level.SEVERE, null, e); } } }); } else { notifyError(Bundle.LBL_OpenDocument(), Bundle.MSG_CannotFind(path)); } }
Example #19
Source File: FormRefactoringUpdate.java From netbeans with Apache License 2.0 | 6 votes |
private void saveFormForUndo() { if (!formDataObject.isValid()) { // 210787: Refresh formDataObject if it became obsolete FileObject fob = formDataObject.getPrimaryFile(); if (!fob.isValid()) { File file = FileUtil.toFile(fob); fob = FileUtil.toFileObject(file); } try { formDataObject = (FormDataObject)DataObject.find(fob); } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace(ex); } } saveForUndo(formDataObject.getFormFile()); // java file is backed up by java refactoring }
Example #20
Source File: CreateSiteTemplate.java From netbeans with Apache License 2.0 | 6 votes |
public CreateSiteTemplate(FileObject root, FileObject externalSiteRoot, WizardPanel wp) { this.root = root; this.manager = new ExplorerManager(); this.wp = wp; try { if (externalSiteRoot != null) { ExternalSiteRootNode externalSiteRootNode = new ExternalSiteRootNode(DataObject.find(externalSiteRoot).getNodeDelegate(), externalSiteRoot.isFolder()); manager.setRootContext(new OurFilteredNode(DataObject.find(root).getNodeDelegate(), externalSiteRootNode)); } else { manager.setRootContext(new OurFilteredNode(DataObject.find(root).getNodeDelegate(), root.isFolder())); } } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace(ex); } initComponents(); tree = new OutlineView(); tree.setTreeSortable(false); placeholder.setLayout(new BorderLayout()); placeholder.add(tree, BorderLayout.CENTER); nameTextField.getDocument().addDocumentListener(this); fileTextField.getDocument().addDocumentListener(this); fileTextField.setText(new File(System.getProperty("user.home")).getAbsolutePath()); // NOI18N }
Example #21
Source File: ConsoleFoldManager.java From netbeans with Apache License 2.0 | 6 votes |
static FoldTask getTask(FileObject f) { if (f == null) { return null; } try { DataObject d = DataObject.find(f); synchronized (fileTaskMap) { FoldTask ft = fileTaskMap.get(d); if (ft != null) { return ft; } ft = new FoldTask(); fileTaskMap.put(d, ft); return ft; } } catch (DataObjectNotFoundException ex) { return new FoldTask(); } }
Example #22
Source File: WarDeploymentConfiguration.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates a new instance of WarDeploymentConfiguration */ public WarDeploymentConfiguration(J2eeModule j2eeModule, Version serverVersion) { super(j2eeModule, serverVersion); this.j2eeModule = j2eeModule; this.serverVersion = serverVersion; file = j2eeModule.getDeploymentConfigurationFile("WEB-INF/weblogic.xml"); // NOI18N FileUtil.addFileChangeListener(weblogicXmlListener, file); getWeblogicWebApp(); DataObject dataObject = null; try { dataObject = DataObject.find(FileUtil.toFileObject(file)); dataObject.addPropertyChangeListener(this); } catch(DataObjectNotFoundException donfe) { Exceptions.printStackTrace(donfe); } this.dataObject = dataObject; }
Example #23
Source File: BeanInfoSource.java From netbeans with Apache License 2.0 | 6 votes |
/** Finds the bean info for classElement asspciated with this object */ void findBeanInfo(FileObject javafile) throws GenerateBeanException { javaEditor = null; try { this.javaDataObject = DataObject.find(javafile); FileObject parent = javafile.getParent(); FileObject bifile = parent.getFileObject(javafile.getName() + BEANINFO_NAME_EXT, "java"); // NOI18N if (bifile != null) { biDataObject = DataObject.find(bifile); javaEditor = biDataObject.getLookup().lookup(BIEditorSupport.class); } } catch (DataObjectNotFoundException ex) { throw new GenerateBeanException(); // Do nothing if no data object is found } }
Example #24
Source File: EditorContextImpl.java From netbeans with Apache License 2.0 | 6 votes |
private static DataObject getDataObject (String url) { FileObject file; try { file = URLMapper.findFileObject (new URL (url)); } catch (MalformedURLException e) { return null; } if (file == null) { return null; } try { return DataObject.find (file); } catch (DataObjectNotFoundException ex) { return null; } }
Example #25
Source File: CopyClassesUI.java From netbeans with Apache License 2.0 | 6 votes |
private final Vector getNodes() { Vector<Node> result = new Vector<Node>(javaObjects.size()); LinkedList<FileObject> q = new LinkedList<FileObject>(javaObjects); while (!q.isEmpty()) { FileObject f = q.removeFirst(); if (!VisibilityQuery.getDefault().isVisible(f)) { continue; } DataObject d = null; try { d = DataObject.find(f); } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace(ex); } if (d instanceof DataFolder) { for (DataObject o : ((DataFolder) d).getChildren()) { q.addLast(o.getPrimaryFile()); } } else if(d != null) { result.add(d.getNodeDelegate()); } } return result; }
Example #26
Source File: PrimefacesImplementation.java From netbeans with Apache License 2.0 | 6 votes |
/** * Updates index page of the webmodule - includes link to PrimeFaces's welcome page. */ @NbBundle.Messages({ "PrimefacesImplementation.index.welcome.primefaces.lbl=Primefaces welcome page" }) private static void updateIndexPage(WebModule webModule) throws DataObjectNotFoundException { FileObject indexFO = webModule.getDocumentBase().getFileObject("index.xhtml"); //NOI18N if (indexFO == null || !indexFO.isValid() || !indexFO.canWrite()) { return; } DataObject indexDO = DataObject.find(indexFO); JsfComponentUtils.enhanceFileBody( indexDO, "</h:body>", //NOI18N "<br />\n<h:link outcome=\"welcomePrimefaces\" value=\"" + Bundle.PrimefacesImplementation_index_welcome_primefaces_lbl() + "\" />"); //NOI18N JsfComponentUtils.reformat(indexDO); }
Example #27
Source File: JavaRefactoringsFactory.java From netbeans with Apache License 2.0 | 6 votes |
private static boolean isPackage(FileObject fileObject) { DataObject dataObject = null; try { dataObject = DataObject.find(fileObject); } catch (DataObjectNotFoundException dataObjectNotFoundException) { ErrorManager.getDefault().notify(dataObjectNotFoundException); return false; } if ((dataObject instanceof DataFolder) && RefactoringUtils.isFileInOpenProject(fileObject) && JavaRefactoringUtils.isOnSourceClasspath(fileObject) && !RefactoringUtils.isClasspathRoot(fileObject)){ return true; } return false; }
Example #28
Source File: SvnUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Returns the primary file from a DataObject if there is some * @param roots * @return */ public static File getPrimaryFile(File file) { File primaryFile = null; FileObject fo = FileUtil.toFileObject(file); if(fo != null) { DataObject dao = null; try { dao = DataObject.find(fo); } catch (DataObjectNotFoundException ex) { Subversion.LOG.log(Level.INFO, "No DataObject found for " + file, ex); } if(dao != null) { primaryFile = FileUtil.toFile(dao.getPrimaryFile()); } } if(primaryFile == null) { primaryFile = file; // consider it a fallback } return primaryFile; }
Example #29
Source File: ViewPomAction.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
@Override protected void performAction(Node[] activatedNodes) { for (Node node : activatedNodes) { ArtifactData data = node.getLookup().lookup(ArtifactData.class); if(data!=null && data.getPomPath()!=null){ FileObject fo = FileUtil.toFileObject(new File(data.getPomPath())); if(fo!=null){ try { DataObject dob = DataObject.find(fo); OpenCookie open = dob.getLookup().lookup(OpenCookie.class); if(open!=null){ open.open(); } } catch (DataObjectNotFoundException ex) { } } } } }
Example #30
Source File: StrutsConfigHyperlinkProvider.java From netbeans with Apache License 2.0 | 6 votes |
private void openInEditor(FileObject fObj){ if (fObj != null){ DataObject dobj = null; try{ dobj = DataObject.find(fObj); } catch (DataObjectNotFoundException e){ Exceptions.printStackTrace(e); return; } if (dobj != null){ Node.Cookie cookie = dobj.getCookie(OpenCookie.class); if (cookie != null) ((OpenCookie)cookie).open(); } } }