本文整理汇总了Java中org.openide.util.io.NbMarshalledObject类的典型用法代码示例。如果您正苦于以下问题:Java NbMarshalledObject类的具体用法?Java NbMarshalledObject怎么用?Java NbMarshalledObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NbMarshalledObject类属于org.openide.util.io包,在下文中一共展示了NbMarshalledObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerializeAndDeserialize
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void testSerializeAndDeserialize() throws Exception {
InstanceContent ic = new InstanceContent();
Lookup context = new AbstractLookup(ic);
CloneableEditorSupport ces = createSupport(context);
ic.add(ces);
ic.add(10);
MultiViewEditorElement mvee = new MultiViewEditorElement(context);
assertEquals("ces", ces, mvee.getLookup().lookup(CloneableEditorSupport.class));
assertEquals("ten", Integer.valueOf(10), mvee.getLookup().lookup(Integer.class));
NbMarshalledObject mar = new NbMarshalledObject(mvee);
MultiViewEditorElement deser = (MultiViewEditorElement)mar.get();
assertEquals("ten", Integer.valueOf(10), deser.getLookup().lookup(Integer.class));
assertEquals("ces", ces, deser.getLookup().lookup(CloneableEditorSupport.class));
}
示例2: testGetOpenedPanesWorksAfterDeserializationIssue39236
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void testGetOpenedPanesWorksAfterDeserializationIssue39236 () throws Exception {
support.open ();
CloneableEditor ed = (CloneableEditor)support.getRef ().getAnyComponent ();
JEditorPane[] panes = support.getOpenedPanes ();
assertNotNull (panes);
assertEquals ("One is there", 1, panes.length);
NbMarshalledObject obj = new NbMarshalledObject (ed);
ed.close ();
panes = support.getOpenedPanes ();
assertNull ("No panes anymore", panes);
ed = (CloneableEditor)obj.get ();
panes = support.getOpenedPanes ();
assertNotNull ("One again", panes);
assertEquals ("One is there again", 1, panes.length);
}
示例3: testGlobalStateOnDeserializedPanel
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void testGlobalStateOnDeserializedPanel () throws Exception {
EP panel = new EP (null);
ExplorerPanel.setConfirmDelete(false);
setupExplorerManager (panel.getExplorerManager());
NbMarshalledObject mar = new NbMarshalledObject (panel);
Object obj = mar.get ();
EP deserializedPanel = (EP) obj;
// activate the actions
ActionsInfraHid.UT.setActivated (deserializedPanel);
deserializedPanel.componentActivated();
ActionsInfraHid.UT.setCurrentNodes (deserializedPanel.getExplorerManager().getRootContext ().getChildren ().getNodes ());
// deletes without asking a question, if the question appears something
// is wrong
delete.actionPerformed(new java.awt.event.ActionEvent (this, 0, ""));
}
示例4: skipForNowtestSelectedNodesInDeserializedPanel
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void skipForNowtestSelectedNodesInDeserializedPanel () throws Exception {
ExplorerPanel panel = new ExplorerPanel ();
FileObject fo = FileUtil.getConfigRoot();
Node root = new SerializableNode ();
panel.getExplorerManager ().setRootContext (root);
panel.getExplorerManager ().setSelectedNodes (new Node[] {root});
assertNotNull ("Array of selected nodes is not null.", panel.getExplorerManager ().getSelectedNodes ());
assertFalse ("Array of selected nodes is not empty.", panel.getExplorerManager ().getSelectedNodes ().length == 0);
assertEquals ("The selected node is Filesystems root.", panel.getExplorerManager ().getSelectedNodes ()[0], root);
NbMarshalledObject mar = new NbMarshalledObject (panel);
Object obj = mar.get ();
ExplorerPanel deserializedPanel = (ExplorerPanel) obj;
assertNotNull ("Deserialized panel is not null.", deserializedPanel);
assertNotNull ("[Deserialized panel] Array of selected nodes is not null.", deserializedPanel.getExplorerManager ().getSelectedNodes ());
assertFalse ("[Deserialized panel] Array of selected nodes is not empty.", deserializedPanel.getExplorerManager ().getSelectedNodes ().length == 0);
assertEquals ("[Deserialized panel] The selected node is Filesystems root.", deserializedPanel.getExplorerManager ().getSelectedNodes ()[0], root);
}
示例5: testDeserAndGC
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void testDeserAndGC() throws Exception {
MyCOS cos = MyCOS.find("test1");
CloneableTopComponent ctc = cos.openCloneableTopComponent();
assertEquals("Associated", cos.allEditors, ctc.getReference());
NbMarshalledObject mar = new NbMarshalledObject(ctc);
Reference<MyCOS> first = new WeakReference<MyCOS>(cos);
cos = null;
assertTrue("Closed", ctc.close());
ctc = null;
assertGC("Can GC away", first);
CloneableTopComponent newCtc = (CloneableTopComponent)mar.get();
Ref newRef = newCtc.getReference();
MyCOS newOne = MyCOS.find("test1");
assertEquals("Just two created", 2, MyCOS.cnt);
assertEquals("Associated 2", newOne.allEditors, newRef);
}
示例6: writeExternal
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
/** Saves pool to stream by saving all filesystems.
* The default (system) filesystem, or any persistent filesystems, are skipped.
*
* @param oos object output stream
* @exception IOException if an error occures
* @deprecated Unused.
*/
@Deprecated
public final synchronized void writeExternal(ObjectOutput oos)
throws IOException {
Iterator iter = fileSystems.iterator();
while (iter.hasNext()) {
FileSystem fs = (FileSystem) iter.next();
if (!fs.isDefault()) {
oos.writeObject(new NbMarshalledObject(fs));
}
}
oos.writeObject(null);
}
示例7: testSerialization
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void testSerialization() throws Exception {
ListenerList<MyL> ll = new ListenerList<MyL>();
ll.add(new MyL());
ll.add(new MyL());
ll.add(new MyL());
NbMarshalledObject mo = new NbMarshalledObject(ll);
@SuppressWarnings("unchecked")
ListenerList<MyL> sll = (ListenerList<MyL>)mo.get();
List<MyL> lla = ll.getListeners();
List<MyL> slla = sll.getListeners();
assertEquals(lla.size(), slla.size());
for (int i = lla.size() - 1; i >= 0; i--) {
assertEquals(lla.get(i), slla.get(i));
}
}
示例8: readExternal
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
super.readExternal(oi);
final NbMarshalledObject readObject = (NbMarshalledObject) oi.readObject();
if (readObject != null) {
try {
Object[] state = (Object[]) readObject.get();
if (state != null && state.length > 0) {
Integer dividerLocation = (Integer) state[0];
if (dividerLocation != null) {
this.splitPane.setDividerLocation(dividerLocation.intValue());
}
}
} catch (Exception e) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
}
}
}
示例9: readExternal
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
super.readExternal(oi);
final NbMarshalledObject readObject =(NbMarshalledObject)oi.readObject();
if (readObject != null) {
try {
Object[] state = (Object[])readObject.get();
if (state != null && state.length > 0) {
this.getKeyStoreBean().setName( (String)state[0] );
}
if (state != null && state.length > 1) {
this.aliasesSplitPane.setDividerLocation( ((Integer)state[1]).intValue() );
}
if (state != null && state.length > 2) {
KeyStoreBeanHistory newKsbh = (KeyStoreBeanHistory)state[2];
setKeyStoreBeanHistory( newKsbh );
}
} catch (Exception e) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
}
}
}
示例10: readExternal
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
super.readExternal(oi);
final NbMarshalledObject readObject =(NbMarshalledObject)oi.readObject();
if (readObject != null) {
try {
Object[] state = (Object[])readObject.get();
if (state == null) {
return ;
}
final int stateLength = state.length;
if (stateLength > 0 && state[0] instanceof Integer) {
int dividerLocation = ((Integer)state[0]);
this.splitPane.setDividerLocation( dividerLocation );
}
} catch (Exception e) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
}
}
}
示例11: readExternal
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
@Override
public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
super.readExternal(oi);
final NbMarshalledObject readObject = (NbMarshalledObject) oi.readObject();
if (readObject != null) {
try {
final Object[] state = (Object[]) readObject.get();
final String newFreeCharacters = (String) state[0];
final Integer newNumberOfCharacters = (Integer) state[1];
if (state.length > 0) {
this.randomPasswordPanel.setFreeCharacters(newFreeCharacters);
this.randomPasswordPanel.setNumberOfCharacters(newNumberOfCharacters);
}
} catch (Exception e) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
}
}
}
示例12: testCloneableMultiViewsSerialize
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void testCloneableMultiViewsSerialize() throws Exception {
InstanceContent ic = new InstanceContent();
Lookup lookup = new AbstractLookup(ic);
CloneableTopComponent cmv = MultiViews.createCloneableMultiView("text/context", new LP(lookup));
assertPersistence("Always", TopComponent.PERSISTENCE_ALWAYS, cmv);
assertNotNull("MultiViewComponent created", cmv);
NbMarshalledObject mar = new NbMarshalledObject(cmv);
TopComponent mvc = (TopComponent) mar.get();
doCheck(mvc, ic);
}
示例13: testGetOpenedPanesWorksAfterDeserializationIssue39236
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
public void testGetOpenedPanesWorksAfterDeserializationIssue39236 () throws Exception {
support.open ();
CloneableEditor ed = (CloneableEditor)support.getRef ().getAnyComponent ();
ic.add(20);
assertEquals("twenty", Integer.valueOf(20), ed.getLookup().lookup(Integer.class));
ic.remove(20);
assertNull("no twenty", ed.getLookup().lookup(Integer.class));
JEditorPane[] panes = support.getOpenedPanes ();
assertNotNull (panes);
assertEquals ("One is there", 1, panes.length);
NbMarshalledObject obj = new NbMarshalledObject (ed);
ed.close ();
panes = support.getOpenedPanes ();
assertNull ("No panes anymore", panes);
ed = (CloneableEditor)obj.get ();
panes = support.getOpenedPanes ();
assertNotNull ("One again", panes);
assertEquals ("One is there again", 1, panes.length);
ic.add(10);
assertEquals("ten", Integer.valueOf(10), ed.getLookup().lookup(Integer.class));
}
示例14: testNoDeserializationOfActions
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
/** Test to check that the deserialization of actions is completely ignored.
*/
public void testNoDeserializationOfActions () throws Exception {
assertEquals("No actions at the start", 0, node.getActions(false).length);
FileObject test = root;
PCL pcl = new PCL ();
obj.getLoader ().addPropertyChangeListener (pcl);
obj.getLoader().setActions(new SystemAction[] {
SystemAction.get(PropertiesAction.class)
});
pcl.assertEvent (1, "actions");
Action [] res = node.getActions(false);
assertEquals("There should be exactly one action.", 1, res.length);
assertEquals("One file created", 1, test.getChildren ().length);
NbMarshalledObject m = new NbMarshalledObject (obj.getLoader ());
obj.getLoader().setActions(new SystemAction[0]);
pcl.assertEvent (2, "actions");
assertEquals("No actions after deleting", 0, node.getActions(false).length);
assertEquals("file disappeared", 0, test.getChildren ().length);
assertEquals ("Loader deserialized", obj.getLoader (), m.get ());
assertEquals("Still no actions", 0, node.getActions(false).length);
obj.getLoader ().removePropertyChangeListener (pcl);
}
示例15: doComponentCanBeSerialized
import org.openide.util.io.NbMarshalledObject; //导入依赖的package包/类
private void doComponentCanBeSerialized(final String txt) throws Exception {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
try {
final EditorCookie c = (txt != null) ? tryToOpen(txt) : obj.getCookie(EditorCookie.class);
assertNotNull(c);
c.open();
JEditorPane[] arr = c.getOpenedPanes();
assertNotNull("Something opened", arr);
assertEquals("One opened", 1, arr.length);
Object o = SwingUtilities.getAncestorOfClass(TopComponent.class, arr[0]);
assertNotNull("Top component found", o);
NbMarshalledObject mar = new NbMarshalledObject(o);
((TopComponent) o).close();
obj.setValid(false);
TopComponent tc = (TopComponent) mar.get();
assertNotNull("Successfully deserialized", tc);
if (obj == DataObject.find(obj.getPrimaryFile())) {
fail("Strange, obj should be garbage collected" + obj);
}
} catch (Exception x) {
throw new RuntimeException(x);
}
}
});
}