本文整理汇总了Java中org.openide.loaders.DataObject.isModified方法的典型用法代码示例。如果您正苦于以下问题:Java DataObject.isModified方法的具体用法?Java DataObject.isModified怎么用?Java DataObject.isModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.loaders.DataObject
的用法示例。
在下文中一共展示了DataObject.isModified方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileStreamFromDocument
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private Reader getFileStreamFromDocument(File resultFile) {
FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(resultFile));
if(fo != null){
DataObject dobj = null;
try {
dobj = DataObject.find(fo);
} catch (DataObjectNotFoundException ex) {
return null;
}
if(dobj.isValid() && dobj.isModified()){
// DataObjectAdapters does not implement getByteStream
// so calling this here will effectively return null
return DataObjectAdapters.inputSource(dobj).getCharacterStream();
} else{
//return null so that the validator will use normal file path to access doc
return null;
}
}
return null;
}
示例2: closeDocuments
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private static void closeDocuments(Set<DataObject> toCloseDocuments) {
for (DataObject dobj : toCloseDocuments) {
if (!dobj.isModified()) {
//the modified files would force user to decide about saving..
CloseCookie cook = dobj.getLookup().lookup(CloseCookie.class);
if (cook != null) {
cook.close();
}
}
}
}
示例3: getModifiedFiles
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
private static Set<DataObject> getModifiedFiles (Set<DataObject> openedFiles) {
Set<DataObject> set = new HashSet<DataObject> (openedFiles.size ());
for (DataObject obj: openedFiles) {
if (obj.isModified ()) {
set.add (obj);
}
}
return set;
}
示例4: canClose
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/**
* Overrides superclass method.
* Should test whether all data is saved, and if not, prompt the user
* to save. Called by my topcomponent when it wants to close its last topcomponent, but the table editor may still be open
* @return <code>true</code> if everything can be closed
*/
@Override
protected boolean canClose () {
// if the table is open, can close without worries, don't remove the save cookie
if (hasOpenedTableComponent()){
return true;
}else{
DataObject propDO = myEntry.getDataObject();
if ((propDO == null) || !propDO.isModified()) {
return true;
}
return super.canClose();
}
}
示例5: canCloseElement
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
@Messages({
"MSG_SaveModified=File {0} is modified. Save?"
})
@Override
public CloseOperationState canCloseElement() {
if (sqlEditorSupport().isConsole()) {
return CloseOperationState.STATE_OK;
} else {
DataObject sqlDO = sqlEditorSupport().getDataObject();
FileObject sqlFO = sqlEditorSupport().getDataObject().getPrimaryFile();
if (sqlDO.isModified()) {
if (sqlFO.canWrite()) {
Savable sav = sqlDO.getLookup().lookup(Savable.class);
if (sav != null) {
AbstractAction save = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
try {
sqlEditorSupport().saveDocument();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
};
save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_SaveModified(sqlFO.getNameExt()));
return MultiViewFactory.createUnsafeCloseState("editor", save, null);
}
}
}
}
return CloseOperationState.STATE_OK;
}
示例6: setCoverage
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void setCoverage(FileCoverageDetails details) {
if (details != null) {
FileCoverageSummary summary = details.getSummary();
float coverage = summary.getCoveragePercentage();
if (coverage >= 0.0) {
coverageBar.setCoveragePercentage(coverage);
}
//coverageBar.setStats(summary.getLineCount(), summary.getExecutedLineCount(),
// summary.getInferredCount(), summary.getPartialCount());
long dataModified = details.lastUpdated();
FileObject fo = details.getFile();
boolean tooOld = false;
if (fo != null && dataModified > 0 && dataModified < fo.lastModified().getTime()) {
tooOld = true;
} else if (fo != null && fo.isValid()) {
try {
DataObject dobj = DataObject.find(fo);
tooOld = dobj.isModified();
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
if (tooOld) {
warningsLabel.setText(NbBundle.getMessage(CoverageSideBar.class, "DataTooOld"));
} else {
warningsLabel.setText("");
}
} else {
coverageBar.setCoveragePercentage(0.0f);
warningsLabel.setText("");
}
}
示例7: getFileObject
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/**
* Get file object that have user selected
* @throws IOException if cancelled or invalid data entered
*/
public FileObject getFileObject () throws IOException {
FileObject newFO = null;
while ( newFO == null ) {
DialogDisplayer.getDefault().notify(selectDD);
if (selectDD.getValue() != NotifyDescriptor.OK_OPTION) {
throw new UserCancelException();
}
final String newName = selectDD.getInputText();
newFO = folder.getFileObject (newName, ext);
if ( ( newFO == null ) ||
( newFO.isVirtual() == true ) ) {
FileSystem fs = folder.getFileSystem();
final FileObject tempFile = newFO;
fs.runAtomicAction (new FileSystem.AtomicAction () {
public void run () throws IOException {
if ( ( tempFile != null ) &&
tempFile.isVirtual() ) {
tempFile.delete();
}
try {
folder.createData (newName, ext);
} catch (IOException exc) {
NotifyDescriptor desc = new NotifyDescriptor.Message
(NbBundle.getMessage(SelectFileDialog.class, "MSG_cannot_create_data", newName + "." + ext), NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify (desc);
//if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (exc);
}
}
});
newFO = folder.getFileObject (newName, ext);
} else if (newFO != null) {
DataObject data = DataObject.find(newFO);
if (data.isModified() || data.isValid() == false) {
NotifyDescriptor message = new NotifyDescriptor.Message(NbBundle.getMessage(SelectFileDialog.class, "BK0001"), NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(message);
throw new UserCancelException();
} else if (! GuiUtil.confirmAction (NbBundle.getMessage(SelectFileDialog.class, "PROP_replaceMsg",
newName, ext ) )) {
throw new UserCancelException();
}
}
} // while
return newFO;
}