本文整理汇总了Java中org.openide.ErrorManager.getDefault方法的典型用法代码示例。如果您正苦于以下问题:Java ErrorManager.getDefault方法的具体用法?Java ErrorManager.getDefault怎么用?Java ErrorManager.getDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.ErrorManager
的用法示例。
在下文中一共展示了ErrorManager.getDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFiles
import org.openide.ErrorManager; //导入方法依赖的package包/类
protected final void setFiles(final Set<FileObject> files) {
fileSystemListeners = new HashSet<FileStatusListener>();
this.files = files;
if (files == null) {
return;
}
Set<FileSystem> hookedFileSystems = new HashSet<FileSystem>();
for (FileObject fo: files) {
try {
FileSystem fs = fo.getFileSystem();
if (hookedFileSystems.contains(fs)) {
continue;
}
hookedFileSystems.add(fs);
FileStatusListener fsl = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(fsl);
fileSystemListeners.add(fsl);
} catch (FileStateInvalidException e) {
ErrorManager err = ErrorManager.getDefault();
err.annotate(e, "Cannot get " + fo + " filesystem, ignoring..."); // NOI18N
err.notify(ErrorManager.INFORMATIONAL, e);
}
}
}
示例2: setFiles
import org.openide.ErrorManager; //导入方法依赖的package包/类
protected final void setFiles(final Set<FileObject> files) {
fileSystemListeners = new HashSet<FileStatusListener>();
this.files = files;
if (files == null) {
return;
}
Iterator<FileObject> it = files.iterator();
Set<FileSystem> hookedFileSystems = new HashSet<FileSystem>();
while (it.hasNext()) {
FileObject fo = it.next();
try {
FileSystem fs = fo.getFileSystem();
if (hookedFileSystems.contains(fs)) {
continue;
}
hookedFileSystems.add(fs);
FileStatusListener fsl = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(fsl);
fileSystemListeners.add(fsl);
} catch (FileStateInvalidException e) {
ErrorManager err = ErrorManager.getDefault();
err.annotate(e, "Cannot get " + fo + " filesystem, ignoring..."); // NOI18N
err.notify(ErrorManager.INFORMATIONAL, e);
}
}
}
示例3: save
import org.openide.ErrorManager; //导入方法依赖的package包/类
/** Tries to save given data object using its save cookie.
* Notifies user if excetions appear.
*/
private void save (DataObject dataObject) {
try {
SaveCookie sc = dataObject.getLookup().lookup(SaveCookie.class);
if (sc != null) {
sc.save();
}
listModel.removeElement(dataObject);
} catch (IOException exc) {
ErrorManager em = ErrorManager.getDefault();
Throwable t = em.annotate(
exc, NbBundle.getBundle(ExitDialog.class).getString("EXC_Save")
);
em.notify(ErrorManager.EXCEPTION, t);
}
}
示例4: getAnnotateLine
import org.openide.ErrorManager; //导入方法依赖的package包/类
/**
* Locates AnnotateLine associated with given line. The
* line is translated to Element that is used as map lookup key.
* The map is initially filled up with Elements sampled on
* annotate() method.
*
* <p>Key trick is that Element's identity is maintained
* until line removal (and is restored on undo).
*
* @param line
* @return found AnnotateLine or <code>null</code>
*/
private VcsAnnotation getAnnotateLine(int line) {
StyledDocument sd = (StyledDocument) doc;
int lineOffset = NbDocument.findLineOffset(sd, line);
Element element = sd.getParagraphElement(lineOffset);
VcsAnnotation al = elementAnnotations.get(element);
if (al != null) {
int startOffset = element.getStartOffset();
int endOffset = element.getEndOffset();
try {
int len = endOffset - startOffset;
String text = doc.getText(startOffset, len -1);
String content = al.getDocumentText();
if (text.equals(content)) {
return al;
}
} catch (BadLocationException e) {
ErrorManager err = ErrorManager.getDefault();
err.annotate(e, "CVS.AB: can not locate line annotation."); // NOI18N
err.notify(ErrorManager.INFORMATIONAL, e);
}
}
return null;
}
示例5: resolveModuleElm
import org.openide.ErrorManager; //导入方法依赖的package包/类
/** reade codenamebase + revision */
private void resolveModuleElm(String codeName) {
if (codeName != null) {
int slash = codeName.indexOf("/"); // NOI18N
if (slash == -1) {
codeNameBase = codeName;
codeNameRelease = -1;
} else {
codeNameBase = codeName.substring(0, slash);
try {
codeNameRelease = Integer.parseInt(codeName.substring(slash + 1));
} catch (NumberFormatException ex) {
ErrorManager emgr = ErrorManager.getDefault();
emgr.annotate(ex, "Content: \n" + getFileContent(source)); // NOI18N
emgr.annotate(ex, "Source: " + source); // NOI18N
emgr.notify(ErrorManager.INFORMATIONAL, ex);
codeNameRelease = -1;
}
}
} else {
codeNameBase = null;
codeNameRelease = -1;
}
}
示例6: parse
import org.openide.ErrorManager; //导入方法依赖的package包/类
/**
* Converts to InputSource and pass it.
*/
protected TreeDocumentRoot parse(FileObject fo) throws IOException, TreeException{
try {
URL url = fo.getURL();
InputSource in = new InputSource(url.toExternalForm()); //!!! we could try ti get encoding from MIME content type
in.setByteStream(fo.getInputStream());
return parse(in);
} catch (IOException ex) {
ErrorManager emgr = ErrorManager.getDefault();
emgr.annotate(ex, Util.THIS.getString("MSG_can_not_create_URL"));
emgr.notify(ex);
}
return null;
}
示例7: setFiles
import org.openide.ErrorManager; //导入方法依赖的package包/类
protected final void setFiles(final Set<FileObject> files) {
fileSystemListeners = new HashSet<FileStatusListener>();
this.files = files;
if (files == null) {
return;
}
Set<FileSystem> hookedFileSystems = new HashSet<FileSystem>();
for (FileObject fo : files) {
try {
FileSystem fs = fo.getFileSystem();
if (hookedFileSystems.contains(fs)) {
continue;
}
hookedFileSystems.add(fs);
FileStatusListener fsl = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(fsl);
fileSystemListeners.add(fsl);
} catch (FileStateInvalidException e) {
ErrorManager err = ErrorManager.getDefault();
err.annotate(e, "Cannot get " + fo + " filesystem, ignoring..."); // NOI18N
err.notify(ErrorManager.INFORMATIONAL, e);
}
}
}
示例8: doSave
import org.openide.ErrorManager; //导入方法依赖的package包/类
public static void doSave (DataObject dataObject) {
try {
SaveCookie sc = dataObject.getLookup().lookup(SaveCookie.class);
if (sc != null) {
sc.save();
}
} catch (IOException exc) {
ErrorManager em = ErrorManager.getDefault();
Throwable t = em.annotate(
exc, NbBundle.getBundle(ExitDialog.class).getString("EXC_Save")
);
em.notify(ErrorManager.EXCEPTION, t);
}
}
示例9: insertUpdate
import org.openide.ErrorManager; //导入方法依赖的package包/类
public void insertUpdate(DocumentEvent e) {
int start = e.getOffset();
int len = e.getLength();
try {
String s = e.getDocument().getText(start + len - 1, 1);
lastInsertedChar = s.charAt(0);
} catch (BadLocationException e1) {
ErrorManager err = ErrorManager.getDefault();
err.notify(e1);
}
}
示例10: equals
import org.openide.ErrorManager; //导入方法依赖的package包/类
public boolean equals(Object o) {
if (this == o) return true;
if (o instanceof DiskFileKey) {
DiskFileKey key = (DiskFileKey) o;
if (hashCode != key.hashCode) return false;
FileObject fo2 = key.fileObject;
FileObject fo = fileObject;
if (fo == fo2) return true;
try {
FileSystem fs = fo.getFileSystem();
FileSystem fs2 = fo2.getFileSystem();
if (fs.equals(fs2)) {
return fo.equals(fo2);
} else {
// fallback use absolute paths (cache them)
if (absolutePath == null) {
File f = FileUtil.toFile(fo);
absolutePath = f.getAbsolutePath();
}
if (key.absolutePath == null) {
File f2 = FileUtil.toFile(fo2);
key.absolutePath = f2.getAbsolutePath();
}
return absolutePath.equals(key.absolutePath);
}
} catch (FileStateInvalidException e) {
ErrorManager err = ErrorManager.getDefault();
err.notify(e);
}
}
return false;
}
示例11: setUp
import org.openide.ErrorManager; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
clearWorkDir();
MockServices.setServices(MockDD.class);
System.setProperty("netbeans.user", getWorkDirPath());
// init the whole system
TopLogging.initializeQuietly();
err = ErrorManager.getDefault();
assertNotNull("One Error manager found", err);
}
示例12: testErrorManagerCompatibilityAsDescribedInIssue79227
import org.openide.ErrorManager; //导入方法依赖的package包/类
public void testErrorManagerCompatibilityAsDescribedInIssue79227() throws Exception {
MockDD.lastDescriptor = null;
Exception ex = new ClassNotFoundException();
ErrorManager em = ErrorManager.getDefault();
String msg = "LocMsg";
em.annotate(ex, msg);
em.notify(ErrorManager.USER, ex); // Issue 65116 - don't show the exception to the user
waitEQ();
assertNotNull("Mock descriptor called", MockDD.lastDescriptor);
assertEquals("Info msg", NotifyDescriptor.INFORMATION_MESSAGE, MockDD.lastDescriptor.getMessageType());
}
示例13: testUIExceptionsTriggersTheDialog
import org.openide.ErrorManager; //导入方法依赖的package包/类
public void testUIExceptionsTriggersTheDialog() throws Exception {
MockDD.lastDescriptor = null;
Exception ex = new IOException();
ErrorManager em = ErrorManager.getDefault();
em.annotate(ex, ErrorManager.USER, "bla", "blaLoc", null, null);
Exceptions.printStackTrace(ex);
waitEQ();
assertNotNull("Mock descriptor called", MockDD.lastDescriptor);
assertEquals("Info msg", NotifyDescriptor.INFORMATION_MESSAGE, MockDD.lastDescriptor.getMessageType());
}
示例14: testUIExceptionsTriggersTheDialogWithWarningPlus1
import org.openide.ErrorManager; //导入方法依赖的package包/类
public void testUIExceptionsTriggersTheDialogWithWarningPlus1() throws Exception {
MockDD.lastDescriptor = null;
Exception ex = new IOException();
ErrorManager em = ErrorManager.getDefault();
em.annotate(ex, ErrorManager.USER, "bla", "blaLoc", null, null);
Logger.global.log(OwnLevel.UNKNOWN, "someerror", ex);
waitEQ();
assertNotNull("Mock descriptor called", MockDD.lastDescriptor);
assertEquals("Info msg", NotifyDescriptor.INFORMATION_MESSAGE, MockDD.lastDescriptor.getMessageType());
}
示例15: inputStream
import org.openide.ErrorManager; //导入方法依赖的package包/类
/**
* Always return fresh stream.
*/
public java.io.InputStream inputStream() throws java.io.IOException {
try {
URL peer = new URL(systemId);
return peer.openStream();
} catch (IOException ex) {
// #21556
// annotate exception as USER error, he provided wrong URL
ErrorManager err = ErrorManager.getDefault();
err.annotate(ex, ErrorManager.USER, null, null, null, null);
throw ex;
}
}