本文整理汇总了Java中org.openide.ErrorManager.annotate方法的典型用法代码示例。如果您正苦于以下问题:Java ErrorManager.annotate方法的具体用法?Java ErrorManager.annotate怎么用?Java ErrorManager.annotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.ErrorManager
的用法示例。
在下文中一共展示了ErrorManager.annotate方法的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: setSpacesPerTab
import org.openide.ErrorManager; //导入方法依赖的package包/类
public void setSpacesPerTab(int spacesPerTab) {
if (spacesPerTab <= 0) {
IllegalArgumentException iae = new IllegalArgumentException("Invalid argument"); //NOI18N
ErrorManager errMan = Lookup.getDefault().lookup(ErrorManager.class);
if (errMan != null) {
Toolkit.getDefaultToolkit().beep();
errMan.annotate(iae, ErrorManager.USER, iae.getMessage(), NbBundle.getMessage(FormatterIndentEngine.class, "MSG_NegativeValue"), null, null); //NOI18N
} else {
throw iae;
}
}
int old = getFormatter().getSpacesPerTab();
getFormatter().setSpacesPerTab(spacesPerTab);
if (old != spacesPerTab) {
setValue(SimpleValueNames.SPACES_PER_TAB,
new Integer(spacesPerTab), SPACES_PER_TAB_PROP);
firePropertyChange(SPACES_PER_TAB_PROP,
new Integer(old),
new Integer(spacesPerTab)
);
}
}
示例7: 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;
}
示例8: 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);
}
}
}
示例9: 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);
}
}
示例10: 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());
}
示例11: 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());
}
示例12: 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());
}
示例13: 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;
}
}
示例14: notifyException
import org.openide.ErrorManager; //导入方法依赖的package包/类
/**
* Notify annotated exception to user. Just shortcut to ErrorManager.
*/
public static void notifyException (String desc, Throwable ex) {
ErrorManager err = ErrorManager.getDefault();
if (desc != null) {
err.annotate (ex, desc);
}
err.notify (err.EXCEPTION, ex); // show stack trace to user
}
示例15: invalidArgument
import org.openide.ErrorManager; //导入方法依赖的package包/类
/** Displays ErrorManager window with the localized message. If bundleKey parameter is not founded in bundle
* it is considered as displayable text value. */
public static void invalidArgument(String bundleKey) {
IllegalArgumentException iae=new IllegalArgumentException("Invalid argument"); //NOI18N
Toolkit.getDefaultToolkit().beep();
ErrorManager errMan=(ErrorManager)Lookup.getDefault().lookup(ErrorManager.class);
if (errMan!=null) {
errMan.annotate(iae, ErrorManager.USER, iae.getMessage(), getString(bundleKey), null, null); //NOI18N
}
throw iae;
}