本文整理汇总了Java中org.openide.loaders.DataObject.setModified方法的典型用法代码示例。如果您正苦于以下问题:Java DataObject.setModified方法的具体用法?Java DataObject.setModified怎么用?Java DataObject.setModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.loaders.DataObject
的用法示例。
在下文中一共展示了DataObject.setModified方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIssue162686
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void testIssue162686() throws IOException {
SaveAllAction a = SaveAllAction.get(SaveAllAction.class);
assertNotNull("Action found", a);
assertFalse("Nothing is modified", a.isEnabled());
FileObject fo = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "Folder/JR.txt");
DataObject obj = DataObject.find(fo);
assertFalse("Nothing is modified2", a.isEnabled());
obj.setModified(true);
assertTrue("SaveAll enabled now", a.isEnabled());
obj.setModified(false);
assertFalse("SaveAll disabled now", a.isEnabled());
WeakReference<?> ref = new WeakReference<Object>(a);
a = null;
assertGC("The action can be GCed", ref);
a = SaveAllAction.get(SaveAllAction.class);
assertNotNull("But we can always create new one", a);
assertFalse("It is disbabled initially", a.isEnabled());
obj.setModified(true);
assertTrue("But enables as soon an object is modified", a.isEnabled());
}
示例2: testModifiedDocumentSaveAs
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void testModifiedDocumentSaveAs() throws IOException {
FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.obj");
DataObject obj = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.obj"));
assertEquals( MyDataObject.class, obj.getClass());
assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );
obj.setModified( true );
MyEnv env = new MyEnv( obj );
MyDataEditorSupport des = new MyDataEditorSupport( obj, env );
FileObject newFolder = FileUtil.createFolder(FileUtil.getConfigRoot(), "otherFolder");
des.saveAs( newFolder, "newFile.newExt" );
DataObject newObj = DataObject.find(FileUtil.getConfigFile("otherFolder/newFile.newExt"));
assertEquals( MyDataObject.class, newObj.getClass());
MyDataObject myObj = (MyDataObject)newObj;
assertEquals("the original StyledDocument was rendered (no file copy)", 1, des.renderCounter);
assertFalse("the original document is no longer modified", obj.isModified() );
assertEquals("the original document was closed", 1, des.closeCounter );
assertEquals("we don't ask before closing the original document", 0, des.canCloseCounter );
assertTrue("new document was opened", myObj.openCookieCalls > 0);
}
示例3: theEnd
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** Exit the IDE
*/
private void theEnd() {
// XXX(-ttran) result must be set before calling setVisible(false)
// because this will unblock the thread which called Dialog.show()
for (int i = listModel.size() - 1; i >= 0; i--) {
DataObject obj = (DataObject) listModel.getElementAt(i);
obj.setModified(false);
}
result = true;
exitDialog.setVisible (false);
exitDialog.dispose();
}
示例4: discardChanges
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** Discards all changes in modified files of given project. */
private static void discardChanges(Project project) {
// discard all changes in modified files
Iterator iter = DataObject.getRegistry().getModifiedSet().iterator();
while (iter.hasNext()) {
DataObject dobj = (DataObject) iter.next();
if (dobj != null) {
FileObject fobj = dobj.getPrimaryFile();
Project owner = FileOwnerQuery.getOwner(fobj);
if(owner == project) {
dobj.setModified(false);
}
}
}
}
示例5: testSetModifiedRemovesSaveCookie
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void testSetModifiedRemovesSaveCookie() throws Exception {
FileSystem fs = FileUtil.createMemoryFileSystem();
FileObject f = fs.getRoot().createData("index.test");
DataObject dob = DataObject.find(f);
assertEquals("The right object", GsfDataObject.class, dob.getClass());
dob.getLookup().lookup(EditorCookie.class).openDocument().insertString(0,
"modified", null);
assertTrue("Should be modified.", dob.isModified());
dob.setModified(false);
assertFalse("Should not be modified.", dob.isModified());
assertNull("Should not have SaveCookie.",
dob.getLookup().lookup(SaveCookie.class));
}
示例6: addSaveCookie
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void addSaveCookie() {
DataObject javaData = this.getDataObject();
if (javaData.getCookie(SaveCookie.class) == null) {
if (this.saveCookie == null)
this.saveCookie = new SaveSupport();
this.cookieSet.add(this.saveCookie);
javaData.setModified(true);
}
}
示例7: removeSaveCookie
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void removeSaveCookie() {
DataObject javaData = this.getDataObject();
if (javaData.getCookie(SaveCookie.class) != null) {
this.cookieSet.remove(this.saveCookie);
javaData.setModified(false);
}
}
示例8: addSaveCookie
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** Helper method. Adds save cookie to the data object. */
private void addSaveCookie() {
DataObject obj = getDataObject();
// Adds save cookie to the data object.
if(obj.getCookie(SaveCookie.class) == null) {
set.add(saveCookie);
obj.setModified(true);
}
}
示例9: removeSaveCookie
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** Helper method. Removes save cookie from the data object. */
private void removeSaveCookie(boolean setModified) {
DataObject obj = getDataObject();
// Remove save cookie from the data object.
Cookie cookie = obj.getCookie(SaveCookie.class);
if(cookie != null && cookie.equals(saveCookie)) {
set.remove(saveCookie);
if (setModified) {
obj.setModified(false);
}
}
}
示例10: setUnmodified
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
/** Finds DataObject for the content of this TopComponent and set it
* unmodified. Used in closeDiscard method.
*/
public void setUnmodified() {
DataObject dob = ((TopComponent) getSource()).getLookup().lookup(DataObject.class);
if (dob == null) {
// try to find possible enclosing MultiviewTopComponent
TopComponentOperator parentTco = findParentTopComponent();
if (parentTco != null) {
parentTco.setUnmodified();
}
} else {
dob.setModified(false);
}
}
示例11: testUnmodifyViaSetModified
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void testUnmodifyViaSetModified() throws IOException, BadLocationException {
FileObject fo = FileUtil.createData(FileUtil.getConfigRoot(), "test2.html");
assertNotNull(fo);
final DataObject obj = DataObject.find(fo);
assertNotNull(obj);
assertFalse(obj.isModified());
assertNull(obj.getLookup().lookup(SaveCookie.class));
final StyledDocument doc = obj.getLookup().lookup(EditorCookie.class).openDocument();
assertTrue(doc instanceof BaseDocument);
((BaseDocument) doc).runAtomic(new Runnable() {
@Override
public void run() {
try {
doc.insertString(0, "hello", null);
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
});
((BaseDocument) doc).runAtomic(new Runnable() {
@Override
public void run() {
assertTrue(obj.isModified());
}
});
assertNotNull(obj.getLookup().lookup(SaveCookie.class));
//some QE unit tests needs to silently discard the changed made to the editor document
obj.setModified(false);
assertFalse(obj.isModified());
assertNull(obj.getLookup().lookup(SaveCookie.class));
}
示例12: addSaveCookie
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void addSaveCookie() {
DataObject javaData = this.getDataObject();
if (javaData.getCookie(SaveCookie.class) == null) {
cookies.add(saveCookie);
javaData.setModified(true);
}
}
示例13: removeSaveCookie
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void removeSaveCookie() {
DataObject javaData = this.getDataObject();
if (javaData.getCookie(SaveCookie.class) != null) {
cookies.remove(saveCookie);
javaData.setModified(false);
}
}
示例14: save
import org.openide.loaders.DataObject; //导入方法依赖的package包/类
public void save() throws java.io.IOException {
DataObject dobj = getDataObject();
((DataEditorSupport) findCloneableOpenSupport()).saveDocument();
dobj.setModified(false);
}