本文整理汇总了Java中org.openide.filesystems.FileAlreadyLockedException类的典型用法代码示例。如果您正苦于以下问题:Java FileAlreadyLockedException类的具体用法?Java FileAlreadyLockedException怎么用?Java FileAlreadyLockedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileAlreadyLockedException类属于org.openide.filesystems包,在下文中一共展示了FileAlreadyLockedException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerLock
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
private static LockForFile registerLock(LockForFile result) throws IOException, FileAlreadyLockedException {
File file = result.getFile();
Namesakes namesakes = new Namesakes();
Namesakes oldNamesakes = name2Namesakes.putIfAbsent(file.getName(), namesakes);
if (oldNamesakes != null) {
namesakes = oldNamesakes;
}
if (namesakes.putInstance(file, result) == null) {
FileAlreadyLockedException alreadyLockedException = new FileAlreadyLockedException(file.getAbsolutePath());
LockForFile previousLock = namesakes.getInstance(file);
// #151576 - check for null although it should not happen
if (previousLock != null) {
alreadyLockedException.initCause(previousLock.lockedBy);
}
throw alreadyLockedException;
}
result.valid = true;
return result;
}
示例2: revertButtonActionPerformed
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
private void revertButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_revertButtonActionPerformed
final Node [] nodes = manager.getSelectedNodes ();
if (nodes != null && confirmRevert(nodes)) {
// Are you sure DLG
rp.post(new Runnable() {
@Override
public void run() {
for (Node node : nodes) {
FileObject fo = node.getLookup().lookup(FileObject.class);
if (fo != null) {
try {
fo.revert();
} catch (FileAlreadyLockedException falex) {
notifyFileLocked(fo);
revertButton.setEnabled(true);
} catch (IOException ex) {
Logger.getLogger(TemplatesPanel.class.getName()).log(Level.WARNING, null, ex);
}
}
}
}
});
revertButton.setEnabled(false);
}
}
示例3: test68015
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
public void test68015 () throws Exception {
DES edSupport = support();
edSupport.open();
waitEQ();
edSupport.desEnv().markModified();
assertTrue(edSupport.messageName().indexOf('*') != -1);
assertTrue(edSupport.messageHtmlName().indexOf('*') != -1);
try {
assertLockFree(fileObject);
fail("File shall be locked already");
} catch (FileAlreadyLockedException ex) {
// OK
}
}
示例4: lock
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
@Override
public synchronized FileLock lock() throws IOException {
if (lock != null) {
FileLock f = (FileLock) lock.get();
if (f != null) {
// System.out.println ("Already locked: " + this); // NOI18N
throw new FileAlreadyLockedException();
}
}
fs.lock(getPath());
FileLock l = new AfLock();
lock = new WeakReference(l);
// Thread.dumpStack ();
// System.out.println ("Locking file: " + this); // NOI18N
return l;
}
示例5: saveProperties
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
public void saveProperties() throws FileAlreadyLockedException, IOException {
OutputStream out = null;
FileLock lock = null;
try {
FileObject pFile = file.getPrimaryFile();
FileObject myFile = FileUtil.findBrother(pFile, extension);
if (myFile == null) {
myFile = FileUtil.createData(pFile.getParent(), pFile.getName() + "." + extension);
}
lock = myFile.lock();
out = myFile.getOutputStream(lock);
store(out, "");
} finally {
if (out != null) {
out.close();
}
if (lock != null) {
lock.releaseLock();
}
}
}
示例6: lock
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
public FileLock lock() throws IOException {
synchronized (this) {
FileLock current = getLock();
if (current != null) {
throw new FileAlreadyLockedException("File is already locked by [" + current + "]."); // NO18N
}
FileLock l = new FileLock();
lockReference = new WeakReference(l);
return l;
}
}
示例7: getOutputStream
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
private static OutputStream getOutputStream(FileObject fo) throws FileAlreadyLockedException, IOException, InterruptedException {
int retry = 0;
while (true) {
try {
return fo.getOutputStream();
} catch (IOException ioe) {
retry++;
if (retry > 7) {
throw ioe;
}
Thread.sleep(retry * 30);
}
}
}
示例8: getOutputStream
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
private static OutputStream getOutputStream(FileObject fo) throws FileAlreadyLockedException, IOException, InterruptedException {
int retry = 0;
while (true) {
try {
return fo.getOutputStream();
} catch (IOException ioe) {
retry++;
if (retry > 7) {
throw ioe;
}
Thread.sleep(retry * 30);
}
}
}
示例9: writeMindMap
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
protected static void writeMindMap(final File file, final MindMap map) throws IOException {
final FileObject fileObject = FileUtil.toFileObject(file);
FileLock lock = null;
while (true) {
try {
lock = fileObject.lock();
break;
}
catch (FileAlreadyLockedException ex) {
delay(500L);
}
}
try {
final OutputStream out = fileObject.getOutputStream(lock);
try {
IOUtils.write(map.packToString(), out, "UTF-8"); //NOI18N
}
finally {
IOUtils.closeQuietly(out);
}
}
finally {
if (lock != null) {
lock.releaseLock();
}
}
}
示例10: takeLock
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
protected FileLock takeLock() throws IOException {
FileLock fileLock = null;
try {
fileLock = super.getDataObject().getPrimaryFile().lock();
} catch (FileAlreadyLockedException exception) {
}
return fileLock;
}
示例11: saveProperties
import org.openide.filesystems.FileAlreadyLockedException; //导入依赖的package包/类
@Deprecated
public void saveProperties() throws FileAlreadyLockedException, IOException {
}