本文整理匯總了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);
}