本文整理汇总了Java中org.openide.util.Exceptions.attachLocalizedMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Exceptions.attachLocalizedMessage方法的具体用法?Java Exceptions.attachLocalizedMessage怎么用?Java Exceptions.attachLocalizedMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.util.Exceptions
的用法示例。
在下文中一共展示了Exceptions.attachLocalizedMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: markModified
import org.openide.util.Exceptions; //导入方法依赖的package包/类
@Override
public void markModified() throws IOException {
if (cannotBeModified != null) {
final String notify = cannotBeModified;
IOException e = new IOException () {
@Override
public String getLocalizedMessage () {
return notify;
}
};
Exceptions.attachLocalizedMessage(e, cannotBeModified);
throw e;
}
modified = true;
}
示例2: getRelativePaths
import org.openide.util.Exceptions; //导入方法依赖的package包/类
/** Returns list of file path relative to current source root. The source is
* either zip file or userdir. It scans sub folders recursively.
* @return list of file path relative to current source root
*/
private List<String> getRelativePaths() {
if (relativePaths == null) {
if (source.isFile()) {
try {
// zip file
relativePaths = listZipFile(source);
} catch (IOException ex) {
Exceptions.attachLocalizedMessage(ex, NbBundle.getMessage(OptionsExportModel.class, "OptionsExportModel.invalid.zipfile", source));
Exceptions.printStackTrace(ex);
relativePaths = Collections.emptyList();
}
} else {
// userdir
relativePaths = getRelativePaths(source);
}
LOGGER.fine("relativePaths=" + relativePaths); //NOI18N
}
return relativePaths;
}
示例3: getComponentsModuleFolder
import org.openide.util.Exceptions; //导入方法依赖的package包/类
/** @return Module folder for TopComponents */
public FileObject getComponentsModuleFolder () throws IOException {
try {
if (compsModuleFolder == null) {
compsModuleFolder = FileUtil.createFolder(
getRootModuleFolder(), COMPS_FOLDER
);
}
return compsModuleFolder;
} catch (IOException exc) {
String annotation = NbBundle.getMessage(PersistenceManager.class,
"EXC_CompsFolder", COMPS_FOLDER);
Exceptions.attachLocalizedMessage(exc, annotation);
throw exc;
}
}
示例4: getGroupsLocalFolder
import org.openide.util.Exceptions; //导入方法依赖的package包/类
/** @return Folder for groups */
public FileObject getGroupsLocalFolder () throws IOException {
try {
if (groupsLocalFolder == null) {
groupsLocalFolder = FileUtil.createFolder(
getRootLocalFolder(), GROUPS_FOLDER
);
}
return groupsLocalFolder;
} catch (IOException exc) {
String annotation = NbBundle.getMessage(PersistenceManager.class,
"EXC_GroupsFolder", GROUPS_FOLDER);
Exceptions.attachLocalizedMessage(exc, annotation);
throw exc;
}
}
示例5: markModified
import org.openide.util.Exceptions; //导入方法依赖的package包/类
public void markModified() throws java.io.IOException {
if (cannotBeModified != null) {
IOException e = new IOException ();
Exceptions.attachLocalizedMessage(e, cannotBeModified);
throw e;
}
modified = true;
}
示例6: nodeRename
import org.openide.util.Exceptions; //导入方法依赖的package包/类
static void nodeRename(final Node n, final String newStr) {
// bugfix #21589 don't update name if there is not any change
if (n.getName().equals(newStr)) {
return;
}
if (EventQueue.isDispatchThread() && Boolean.TRUE.equals(n.getValue("slowRename"))) { // NOI18N
RP.post(new Runnable() {
@Override
public void run() {
nodeRename(n, newStr);
}
});
return;
}
try {
n.setName(newStr);
} catch (IllegalArgumentException exc) {
boolean needToAnnotate = Exceptions.findLocalizedMessage(exc) == null;
// annotate new localized message only if there is no localized message yet
if (needToAnnotate) {
String msg = NbBundle.getMessage(
TreeViewCellEditor.class, "RenameFailed", n.getName(), newStr
);
Exceptions.attachLocalizedMessage(exc, msg);
}
Exceptions.printStackTrace(exc);
}
}
示例7: notify
import org.openide.util.Exceptions; //导入方法依赖的package包/类
/** Notifies an exception to error manager or prints its it to stderr.
* @param ex exception to notify
*/
static void notify(Throwable ex) {
Throwable d = doNotNotify;
doNotNotify = null;
if (d == ex) {
return;
}
if( ex instanceof PropertyVetoException )
Exceptions.attachLocalizedMessage(ex, ex.getLocalizedMessage());
Exceptions.printStackTrace(ex);
}
示例8: markModified
import org.openide.util.Exceptions; //导入方法依赖的package包/类
public void markModified() throws IOException {
if (cannotBeModified != null) {
final String notify = cannotBeModified;
IOException e = new IOException () {
@Override
public String getLocalizedMessage () {
return notify;
}
};
Exceptions.attachLocalizedMessage(e, cannotBeModified);
throw e;
}
modified = true;
}
示例9: processMouseEvent
import org.openide.util.Exceptions; //导入方法依赖的package包/类
@Override
protected void processMouseEvent (MouseEvent me) {
try {
super.processMouseEvent (me);
} catch (ArrayIndexOutOfBoundsException aioobe) {
//Bug in BasicTabbedPaneUI$Handler: The focusIndex field is not
//updated when tabs are removed programmatically, so it will try to
//repaint a tab that's not there
Exceptions.attachLocalizedMessage(aioobe,
"Suppressed AIOOBE bug in BasicTabbedPaneUI"); //NOI18N
Logger.getAnonymousLogger().log(Level.WARNING, null, aioobe);
}
}
示例10: markModified
import org.openide.util.Exceptions; //导入方法依赖的package包/类
public void markModified() throws IOException {
if (cannotBeModified != null) {
final String notify = cannotBeModified;
IOException e = new IOException () {
public String getLocalizedMessage () {
return notify;
}
};
Exceptions.attachLocalizedMessage(e, cannotBeModified);
throw e;
}
modified = true;
}
示例11: performAction
import org.openide.util.Exceptions; //导入方法依赖的package包/类
private void performAction(Savable sc, Node n) {
UserQuestionException userEx = null;
for (;;) {
try {
if (userEx == null) {
sc.save();
} else {
userEx.confirmed();
}
StatusDisplayer.getDefault().setStatusText(
NbBundle.getMessage(SaveAction.class, "MSG_saved", getSaveMessage(sc, n))
);
} catch (UserQuestionException ex) {
NotifyDescriptor nd = new NotifyDescriptor.Confirmation(ex.getLocalizedMessage(),
NotifyDescriptor.YES_NO_OPTION);
Object res = DialogDisplayer.getDefault().notify(nd);
if (NotifyDescriptor.OK_OPTION.equals(res)) {
userEx = ex;
continue;
}
} catch (IOException e) {
Exceptions.attachLocalizedMessage(e,
NbBundle.getMessage(SaveAction.class,
"EXC_notsaved",
getSaveMessage(sc, n),
e.getLocalizedMessage ()));
Logger.getLogger (getClass ().getName ()).log (Level.SEVERE, null, e);
}
break;
}
}
示例12: write
import org.openide.util.Exceptions; //导入方法依赖的package包/类
/**
* Write the passed buffer to the backing storage, recording the line start in the mapping of lines to
* byte offsets.
*
* @param bb
* @throws IOException
*/
private synchronized void write(ByteBuffer bb, int lineCharLengthWithTabs, boolean completeLine) {
if (checkError()) {
return;
}
closed = false;
int start = -1;
try {
start = getStorage().write(bb);
} catch (ClosedByInterruptException cbiex) {
onWriteException();
} catch (java.nio.channels.AsynchronousCloseException ace) {
//Execution termination has sent ThreadDeath to the process in the
//middle of a write
Exceptions.printStackTrace(ace);
onWriteException();
} catch (IOException ioe) {
//Out of disk space
if (ioe.getMessage().indexOf("There is not enough space on the disk") != -1) { //NOI18N
lowDiskSpace = true;
String msg = NbBundle.getMessage(OutWriter.class,
"MSG_DiskSpace", storage); //NOI18N
Exceptions.attachLocalizedMessage(ioe, msg);
Exceptions.printStackTrace(ioe);
setError();
storage.dispose();
} else {
//Existing output may still be readable - close, but leave
//open for reads - if there's a problem there too, the error
//flag will be set when a read is attempted
Exceptions.printStackTrace(ioe);
onWriteException();
}
}
if (checkError()) {
return;
}
int length = bb.limit();
lineLength = lineLength + length;
this.lineCharLengthWithTabs += lineCharLengthWithTabs;
if (start >= 0 && lineStart == -1) {
lineStart = start;
}
lines.lineUpdated(lineStart, lineLength, this.lineCharLengthWithTabs, completeLine);
if (completeLine) {
lineStart = -1;
lineLength = 0;
this.lineCharLengthWithTabs = 0;
}
if (owner != null && owner.isStreamClosed()) {
owner.setStreamClosed(false);
lines.fire();
}
}
示例13: annotateException
import org.openide.util.Exceptions; //导入方法依赖的package包/类
public static void annotateException(final Throwable t) {
Exceptions.attachLocalizedMessage(t, t.getLocalizedMessage());
}
示例14: setAsText
import org.openide.util.Exceptions; //导入方法依赖的package包/类
public void setAsText(String text) throws java.lang.IllegalArgumentException {
if (text.equals("null")) { // NOI18N
setValue(null);
return;
}
if (text.equals("[]")) { // NOI18N
setValue(Array.newInstance(indexedProperty.getElementType(), 0));
return;
}
int i1 = text.indexOf('[');
if ((i1 < 0) || ((i1 + 1) >= text.length())) {
i1 = 0;
} else {
i1++;
}
int i2 = text.lastIndexOf(']');
if (i2 < 0) {
i2 = text.length();
}
if ((i2 < i1) || (i2 > text.length())) {
return;
} else {
}
try {
PropertyEditor p = indexedProperty.getIndexedPropertyEditor();
if (p == null) { //Test for no editor, it's not guaranteed there will be one
throw new IllegalStateException("Indexed type has no property " + "editor");
}
text = text.substring(i1, i2);
StringTokenizer tok = new StringTokenizer(text, ","); // NOI18N
java.util.List<Object> list = new LinkedList<Object>();
while (tok.hasMoreTokens()) {
String s = tok.nextToken();
p.setAsText(s.trim());
list.add(p.getValue());
}
Object[] a = list.toArray((Object[]) Array.newInstance(getConvertedType(), list.size()));
setValue(a);
} catch (Exception x) {
IllegalArgumentException iae = new IllegalArgumentException();
Exceptions.attachLocalizedMessage(iae, getString("EXC_ErrorInIndexedSetter"));
throw iae;
}
}
示例15: hgMoveImplementation
import org.openide.util.Exceptions; //导入方法依赖的package包/类
private void hgMoveImplementation(final File srcFile, final File dstFile) throws IOException {
final File root = hg.getRepositoryRoot(srcFile);
final File dstRoot = hg.getRepositoryRoot(dstFile);
Mercurial.LOG.log(Level.FINE, "hgMoveImplementation(): File: {0} {1}", new Object[] {srcFile, dstFile}); // NOI18N
boolean result = srcFile.renameTo(dstFile);
if (!result && equalPathsIgnoreCase(srcFile, dstFile)) {
Mercurial.LOG.log(Level.FINE, "hgMoveImplementation: magic workaround for filename case change {0} -> {1}", new Object[] { srcFile, dstFile }); //NOI18N
File temp = FileUtils.generateTemporaryFile(dstFile.getParentFile(), srcFile.getName());
Mercurial.LOG.log(Level.FINE, "hgMoveImplementation: magic workaround, step 1: {0} -> {1}", new Object[] { srcFile, temp }); //NOI18N
srcFile.renameTo(temp);
Mercurial.LOG.log(Level.FINE, "hgMoveImplementation: magic workaround, step 2: {0} -> {1}", new Object[] { temp, dstFile }); //NOI18N
result = temp.renameTo(dstFile);
Mercurial.LOG.log(Level.FINE, "hgMoveImplementation: magic workaround completed"); //NOI18N
}
if (!result) {
Mercurial.LOG.log(Level.WARNING, "Cannot rename file {0} to {1}", new Object[] {srcFile, dstFile});
IOException ex = new IOException();
Exceptions.attachLocalizedMessage(ex, NbBundle.getMessage(MercurialInterceptor.class, "MSG_MoveFailed", new Object[] { srcFile, dstFile })); //NOI18N
throw ex;
}
if (root == null) {
return;
}
// no need to do rename after in a background thread, code requiring the bg thread (see #125673) no more exists
OutputLogger logger = OutputLogger.getLogger(root);
try {
if (root.equals(dstRoot) && !HgUtils.isIgnored(dstFile, false)) {
// target does not lie under ignored folder and is in the same repo as src
HgCommand.doRenameAfter(root, srcFile, dstFile, logger);
} else {
// just hg rm the old file
HgCommand.doRemove(root, srcFile, logger);
}
} catch (HgException e) {
Mercurial.LOG.log(Level.FINE, "Mercurial failed to rename: File: {0} {1}", new Object[]{srcFile.getAbsolutePath(), dstFile.getAbsolutePath()}); // NOI18N
} finally {
logger.closeLog();
}
}