Refine search
/** Prints the exception to the log file and (possibly) notifies the user. * Guesses at the severity. * @param t the exception to notify * @see #UNKNOWN * @see #notify(int, Throwable) */ public final void notify(Throwable t) { notify(UNKNOWN, t); }
/** Logs the message to log file and (possibly) tells the user. * Uses a default severity. * @param s the log message */ public final void log(String s) { // not yet: after phase III: * @deprecated {@link Logger#log} log(INFORMATIONAL, s); }
/** Annotates given exception with given values. All the * previous annotations are kept and this new is added at * the top of the annotation stack (index 0 of the annotation * array). * * @param t the exception * @param localizedMessage localized message for the user or null * @return the same exception <code>t</code> (as a convenience) */ public final Throwable annotate(Throwable t, String localizedMessage) { return annotate(t, UNKNOWN, null, localizedMessage, null, null); }
@Override public String getDisplayName() { if (isTopLevelNode) { String s = NbBundle.getMessage(SiteDocsNode.class, "LBL_Site_Pages"); DataObject dob = getOriginal().getLookup().lookup(DataObject.class); FileObject file = dob.getPrimaryFile(); try { s = file.getFileSystem().getStatus().annotateName(s, Collections.singleton(file)); } catch (FileStateInvalidException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } return s; } return getOriginal().getDisplayName(); }
/** * This finally produces the java platform's XML that represents the basic * platform's properties. The XML is returned in the resulting Set. * @return singleton Set with java platform's instance DO inside. */ public java.util.Set instantiate() throws IOException { //Workaround #44444 this.detectPanel.storeSettings (this.wizard); CDCPlatform newPlatform = getPlatform(); final String systemName = platform.getAntName(); FileObject platformsFolder = FileUtil.getConfigFile( "Services/Platforms/org-netbeans-api-java-Platform"); //NOI18N if (platformsFolder.getFileObject(systemName,"xml")!=null) { //NOI18N String msg = NbBundle.getMessage(CDCWizardIterator.class,"ERROR_InvalidName"); throw (IllegalStateException)ErrorManager.getDefault().annotate( new IllegalStateException(msg), ErrorManager.USER, null, msg,null, null); } DataObject dobj = PlatformConvertor.create(newPlatform, DataFolder.findFolder(platformsFolder),systemName); JavaPlatform platform = (JavaPlatform) dobj.getNodeDelegate().getLookup().lookup(JavaPlatform.class); return Collections.singleton(platform); }
/** @see "#20467" */ private static void doNotify(RequestProcessor.Task todo, Throwable ex) { ErrorManager err = ErrorManager.getDefault (); err.annotate(ex, ErrorManager.EXCEPTION, null, NbBundle.getMessage (RequestProcessor.class, "EXC_IN_REQUEST_PROCESSOR"), SLOW ? todo.item : null, null ); err.notify(ex); }
private Project getProject( File projectDir ) { if (projectDir == null) { // #46744 return null; } try { File normProjectDir = FileUtil.normalizeFile(projectDir); FileObject fo = FileUtil.toFileObject(normProjectDir); if (fo != null) { return ProjectManager.getDefault().findProject(fo); } } catch (IOException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); // Return null } return null; }
/*private*/ static CssUserAgentInfo getUserAgentInfo() { // XXX FIXME The userAgentInfo might not be correct as singleton, but it should be // passed as argument (there might be more user agents available). CssUserAgentInfo userAgentInfo = (CssUserAgentInfo)Lookup.getDefault().lookup(CssUserAgentInfo.class); if (userAgentInfo == null) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new NullPointerException("No CssUserAgentInfo available! Using dummy one!")); // NOI18N userAgentInfo = new DummyUserAgentInfo(); } return userAgentInfo; }
/** Add the line offset into the jump history */ private void addPositionToJumpList(String url, Line l, int column) { DataObject dataObject = getDataObject (url); if (dataObject != null) { EditorCookie ec = dataObject.getLookup().lookup(EditorCookie.class); if (ec != null) { try { StyledDocument doc = ec.openDocument(); JEditorPane[] eps = ec.getOpenedPanes(); if (eps != null && eps.length > 0) { JumpList.addEntry(eps[0], NbDocument.findLineOffset(doc, l.getLineNumber()) + column); } } catch (java.io.IOException ioex) { ErrorManager.getDefault().notify(ioex); } } } }
/** Provides the wizard panel with the current data--either * the default data or already-modified settings, if the user used the previous and/or next buttons. * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>. * @param settings the object representing wizard panel state, as originally supplied to {@link WizardDescriptor#WizardDescriptor(WizardDescriptor.Iterator,Object)} */ public void readSettings(Object settings) { this.wizard = (TemplateWizard)settings; DataObject template = wizard.getTemplate (); if (template != null) { extension = template.getPrimaryFile().getExt(); } try { targetFolder = wizard.getTargetFolder(); } catch (IOException x) { ErrorManager.getDefault().notify(x); } }
private void ensureSavingFirst() throws IOException { //#65420 it can happen the manifest is currently being edited. save it // and cross fingers because it can be in inconsistent state try { DataObject dobj = DataObject.find(manifestFile); SaveCookie safe = dobj.getLookup().lookup(SaveCookie.class); if (safe != null) { safe.save(); } } catch (DataObjectNotFoundException ex) { Util.err.notify(ErrorManager.WARNING, ex); } } }
private static boolean isRemotePlatform(final JavaPlatform platform) { JavaPlatformManagerProvider impl = Lookup.getDefault().lookup(JavaPlatformManagerProvider.class); if (impl == null) { ProfilerUtils.getProfilerErrorManager().log(Level.WARNING.intValue(), "No instance of JavaPlatformManagerProvider found in Lookup"); //NOI18N return false; } for (JavaPlatformProvider jpp : impl.getPlatforms()) { if ( (platform.getPlatformId() != null) && (platform.getPlatformId().equals(jpp.getPlatformId())) && (platform.getProperties().containsKey("platform.host")) ) {//NOI18N return true; } } return false; }
public static void loadLayerActions(String path, ArrayList lst) { try { FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource(path); // NOI18N if (fo != null) { DataObject dobj = DataObject.find(fo); FolderLookup actionRegistry = new FolderLookup((DataFolder)dobj); Lookup.Template query = new Lookup.Template(Object.class); Lookup lookup = actionRegistry.getLookup(); Iterator it2 = lookup.lookup(query).allInstances().iterator(); if (it2.hasNext()) { lst.add(null); } while (it2.hasNext()) { Object next = it2.next(); if (next instanceof Action) { lst.add(next); } else if (next instanceof JSeparator) { lst.add(null); } } } } catch (DataObjectNotFoundException ex) { // data folder for existing fileobject expected ErrorManager.getDefault().notify(ex); } }
/** * Installs platform detected using CDCPlatformDetector.detectPlatform method * @param platform CDCPlatform as a result of detection * @param systemName name of platform, this name should not exist, otherwise IllegalStateException will be thrown * @throws IOException when some I/O issue occur */ public final void installPlatform(CDCPlatform platform, String systemName) throws IOException { FileObject platformsFolder = FileUtil.getConfigFile( "Services/Platforms/org-netbeans-api-java-Platform"); //NOI18N if (platformsFolder.getFileObject(systemName,"xml")!=null) { //NOI18N String msg = NbBundle.getMessage(CDCPlatformDetector.class,"ERROR_InvalidName"); throw (IllegalStateException)ErrorManager.getDefault().annotate( new IllegalStateException(msg), ErrorManager.USER, null, msg,null, null); } PlatformConvertor.create(platform, DataFolder.findFolder(platformsFolder),systemName); }
protected final MavenProject getMavenProject() { Project proj = FileOwnerQuery.getOwner(environment.getFileObject()); if (proj != null) { ProjectURLWatcher watch = proj.getLookup().lookup(ProjectURLWatcher.class); assert watch != null; return watch.getMavenProject(); } ErrorManager.getDefault().log(ErrorManager.WARNING, "File " + environment.getFileObject() + " has maven2 code completion but doesn't belong to a maven2 project."); //NOI18N return null; }
public String get(String key) { String trans = key; try { trans = NbBundle.getMessage(cls, key); } catch (java.util.MissingResourceException x) { ErrorManager.getDefault().notify(x); } return trans; }
protected final String annotateName(final String name) { String annotatedName = name; if (files != null && files.iterator().hasNext()) { try { FileObject fo = files.iterator().next(); annotatedName = fo.getFileSystem().getStatus().annotateName(name, files); } catch (FileStateInvalidException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } } return annotatedName; }
public void run() { // TODO - wait for the file to be created // Open brower on the doc directory FileObject doc = project.getProjectDirectory().getFileObject("doc"); // NOI18N if (doc != null) { FileObject index = doc.getFileObject("index.html"); // NOI18N if (index != null) { try { URL url = FileUtil.toFile(index).toURI().toURL(); HtmlBrowser.URLDisplayer.getDefault().showURL(url); } catch (MalformedURLException ex) { ErrorManager.getDefault().notify(ex); } } } } };
private Collection<MultiDataObject.Entry> collectLocaleEntries(Collection<MultiDataObject.Entry> col) { for (String bundleName : getBundleNames()) { MultiDataObject dobj = ResourceUtils.getPropertiesDataObject(sourceFile, bundleName, false); if (dobj != null) { if (col == null) col = new LinkedList<MultiDataObject.Entry>(); col.add(dobj.getPrimaryEntry()); col.addAll(dobj.secondaryEntries()); try { String baseName = dobj.getName() + "_"; // NOI18N for (FileObject fo : dobj.getPrimaryFile().getParent().getChildren()) { String fileName = fo.getNameExt(); if (fileName.endsWith(".properties") && fileName.startsWith(baseName)) { // NOI18N DataObject dobj2 = DataObject.find(fo); if (dobj2 instanceof PropertiesDataObject) { col.add(((MultiDataObject)dobj2).getPrimaryEntry()); } } } } catch (IOException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } } } DesignResourceMap parent = getDesignParent(); return parent != null ? parent.collectLocaleEntries(col) : col; }