Java 类org.openide.util.io.NbMarshalledObject 实例源码

项目:incubator-netbeans    文件:MultiViewEditorElementTest.java   
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));
}
项目:incubator-netbeans    文件:CloneableEditorTest.java   
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);
}
项目:incubator-netbeans    文件:ExplorerActionsTest.java   
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, ""));
}
项目:incubator-netbeans    文件:ExplorerPanelTest.java   
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);

}
项目:incubator-netbeans    文件:CloneableOpenSupportTest.java   
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);
}
项目:incubator-netbeans    文件:Repository.java   
/** 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);
}
项目:incubator-netbeans    文件:ListenerListTest.java   
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));
    }
}
项目:netbeansplugins    文件:HttpPostTopComponent.java   
@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);
        }
    }
}
项目:netbeansplugins    文件:KeyStoreTopComponent.java   
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);
        }
    }
}
项目:netbeansplugins    文件:WordCountTopComponent.java   
@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);
        }
    }
}
项目:netbeansplugins    文件:RandomPasswordTopComponent.java   
@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);
        }
    }
}
项目:incubator-netbeans    文件:MultiViewProcessorTest.java   
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);
}
项目:incubator-netbeans    文件:CloneableEditorAssociateTest.java   
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));
}
项目:incubator-netbeans    文件:DataLoaderGetActionsTest.java   
/** 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);
}
项目:incubator-netbeans    文件:DefaultDataObjectHasOpenTest.java   
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);
            }
        }
    });
}
项目:incubator-netbeans    文件:DataLoaderGetActionsCompatibilityTest.java   
/** Test to check that the deserialization of actions works as expected.
 */
public void testNoDeserializationOfActions () throws Exception {
    assertEquals("No actions at the start", 0, node.getActions(false).length);

    PCL pcl = new PCL ();
    obj.getLoader ().addPropertyChangeListener (pcl);

    obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[] {
            org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class)
    });

    pcl.assertEvent (1, "actions");

    Action [] res = node.getActions(false);
    assertEquals("There should be exactly one action.", 1, res.length);

    NbMarshalledObject m = new NbMarshalledObject (obj.getLoader ());

    obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);

    pcl.assertEvent (2, "actions");
    assertEquals("No actions after setting empty array", 0, node.getActions(false).length);

    assertEquals ("Loader deserialized", obj.getLoader (), m.get ());
    res = node.getActions(false);
    assertEquals("One action", 1, res.length);
    assertEquals (
        "and that is the property action", 
        org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class),
        res[0]
    );

    obj.getLoader ().removePropertyChangeListener (pcl);
}
项目:incubator-netbeans    文件:PriorityListenerListTest.java   
public void testSerialization() throws Exception {
    PriorityListenerList<EventListener> ll = new PriorityListenerList<EventListener>();
    ll.add(new L(), 3);
    ll.add(new L(), 1);
    ll.add(new L(), 1);

    NbMarshalledObject mo = new NbMarshalledObject(ll);
    PriorityListenerList sll = (PriorityListenerList)mo.get();
    EventListener[][] lla = ll.getListenersArray();
    EventListener[][] slla = sll.getListenersArray();
    assertEquals(lla.length, slla.length);
    for (int priority = lla.length - 1; priority >= 0; priority--) {
        assertEquals(lla[priority].length, slla[priority].length);
    }
}
项目:incubator-netbeans    文件:ContextSystemOption.java   
public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    Object[] objects = getBeanContext().toArray();
    Arrays.sort(objects, new ClassComparator());

    for (int i = 0; i < objects.length; i++) {
        out.writeObject(new NbMarshalledObject(objects[i]));
    }

    out.writeObject(null);
}
项目:netbeansplugins    文件:LocaleTopComponent.java   
public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {
    super.readExternal(oi);

    final NbMarshalledObject readObject = (NbMarshalledObject) oi.readObject();
    if (readObject != null) {
        final Runnable r = new Runnable() {
            public void run() {
                try {
                    Object[] state = (Object[]) readObject.get();
                    if (state.length >= 3) {
                        LocaleTopComponent.this.formatCommands[0].setState(state[0]);
                        LocaleTopComponent.this.formatCommands[1].setState(state[1]);
                        LocaleTopComponent.this.formatCommands[2].setState(state[2]);
                    }

                    if (state.length >= 4 && state[3] instanceof Locale) {
                        final Locale locale = (Locale) state[3];
                        LocaleTopComponent.this.localeComboBox.setSelectedItem(locale);
                    }

                    if (state.length >= 5 && state[4] instanceof Integer) {
                        final Integer selectedTabIndex = (Integer) state[4];
                        int componentCount = LocaleTopComponent.this.localeTabbedPane.getComponentCount();
                        if (selectedTabIndex >= 0 && selectedTabIndex < componentCount) {
                            LocaleTopComponent.this.localeTabbedPane.setSelectedIndex(selectedTabIndex);
                        }
                    }
                } catch (Exception e) {
                    ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
                }
            }
        };
        SwingUtilities.invokeLater(r);
    }
}
项目:netbeansplugins    文件:DigestTopComponent.java   
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();
            final DigestActionCommand dac = (DigestActionCommand)state[0];

            this.digestPanel.setDigestActionCommand( dac );
        } catch (Exception e) {
            ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
        }
    }
}
项目:studio    文件:ContextSystemOption.java   
public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    Object objects[] =  getBeanContext().toArray();
    Arrays.sort(objects,new ClassComparator());
    for (int i = 0 ; i < objects.length ; i++) {
          out.writeObject(new NbMarshalledObject (objects[i]));
    }
    out.writeObject (null);
}
项目:studio    文件:Repository.java   
/** 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.
*/
public final synchronized void writeExternal (ObjectOutput oos) throws IOException {
    Iterator iter = fileSystems.iterator();
    while (iter.hasNext()) {
        FileSystem fs = (FileSystem)iter.next();

        if (!fs.isDefault () && !fs.isPersistent ()) {
            oos.writeObject (new NbMarshalledObject (fs));
        }
    }
    oos.writeObject (null);
}
项目:incubator-netbeans    文件:MultiViewCloneableTopComponentTest.java   
public void testPersistence() throws Exception {
    MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
    SerMVElem elem2 = new SerMVElem();
    SerMVElem elem3 = new SerMVElem();
    elem2.deserializeTest = "testtesttest - 2";
    elem3.deserializeTest = "testtesttest - 3";

    MultiViewDescription desc1 = new SerMVDesc("desc1", null, TopComponent.PERSISTENCE_NEVER, elem1);
    MultiViewDescription desc2 = new SerMVDesc("desc2", null, TopComponent.PERSISTENCE_ONLY_OPENED, elem2);
    MultiViewDescription desc3 = new SerMVDesc("desc3", null, TopComponent.PERSISTENCE_ALWAYS, elem3);

    MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
    SerCloseHandler close = new SerCloseHandler("serializedvalue");

    TopComponent tc = callFactory(descs, desc2, close);
    tc.open();
    tc.requestActive();
    // testing closehandler here..
    tc.close();

    NbMarshalledObject mars = new NbMarshalledObject(tc);
    Object obj = mars.get();
    assertNotNull(obj);
    assertEquals(getTopComponentClass(), obj.getClass());
    tc = (MultiViewCloneableTopComponent)obj;


    MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
    MultiViewPerspective[] descsAfter = handler.getPerspectives();
    assertNotNull(descsAfter);
    assertEquals(2, descsAfter.length);
    MultiViewPerspective selDesc = handler.getSelectedPerspective();
    assertNotNull(selDesc);
    assertEquals("desc2", selDesc.getDisplayName());
    tc.open();
    tc.requestActive();
    MultiViewCloneableTopComponent mvtc = (MultiViewCloneableTopComponent)tc;
    Collection cold = mvtc.getModel().getCreatedElements();
    // expected number of elements is one, because the elem3 was not initialized at all..
    assertEquals(1, cold.size());

    // test if the deserialized instance is there..
    SerMVElem elSelecto = (SerMVElem)mvtc.getModel().getActiveElement();
    assertEquals("testtesttest - 2", elSelecto.deserializeTest);
    assertEquals("componentOpened-componentShowing-componentActivated-", elSelecto.getLog());

    //testing if closehandler was correctly deserialized..
    tc.close();


}
项目:incubator-netbeans    文件:MultiViewTopComponentTest.java   
public void testPersistence() throws Exception {
    MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
    SerMVElem elem2 = new SerMVElem();
    SerMVElem elem3 = new SerMVElem();
    elem2.deserializeTest = "testtesttest - 2";
    elem3.deserializeTest = "testtesttest - 3";

    MultiViewDescription desc1 = new SerMVDesc("desc1", null, TopComponent.PERSISTENCE_NEVER, elem1);
    MultiViewDescription desc2 = new SerMVDesc("desc2", null, TopComponent.PERSISTENCE_ONLY_OPENED, elem2);
    MultiViewDescription desc3 = new SerMVDesc("desc3", null, TopComponent.PERSISTENCE_ALWAYS, elem3);

    MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
    SerCloseHandler close = new SerCloseHandler("serializedvalue");

    TopComponent tc = callFactory(descs, desc2, close);
    tc.open();
    tc.requestActive();
    // testing closehandler here..
    tc.close();

    NbMarshalledObject mars = new NbMarshalledObject(tc);
    Object obj = mars.get();
    assertNotNull(obj);
    assertEquals(getTopComponentClass(), obj.getClass());
    tc = (MultiViewTopComponent)obj;


    MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
    MultiViewPerspective[] descsAfter = handler.getPerspectives();
    assertNotNull(descsAfter);
    assertEquals(2, descsAfter.length);
    MultiViewPerspective selDesc = handler.getSelectedPerspective();
    assertNotNull(selDesc);
    assertEquals("desc2", selDesc.getDisplayName());
    tc.open();
    tc.requestActive();
    MultiViewTopComponent mvtc = (MultiViewTopComponent)tc;
    Collection cold = mvtc.getModel().getCreatedElements();
    // expected number of elements is one, because the elem3 was not initialized at all..
    assertEquals(1, cold.size());

    // test if the deserialized instance is there..
    SerMVElem elSelecto = (SerMVElem)mvtc.getModel().getActiveElement();
    assertEquals("testtesttest - 2", elSelecto.deserializeTest);
    assertEquals("componentOpened-componentShowing-componentActivated-", elSelecto.getLog());

    //testing if closehandler was correctly deserialized..
    tc.close();


}
项目:incubator-netbeans    文件:BaseFileObjectTestHid.java   
public void testDeserializationOfMasterFSLeadsToTheSameFileSystem () throws Exception {
    NbMarshalledObject stream = new NbMarshalledObject (testedFS);
    Object obj = stream.get ();
    assertNotNull(obj);
    //assertSame ("After deserialization it is still the same", testedFS, obj);
}
项目:incubator-netbeans    文件:DataLoaderTest.java   
public void testDataLoaderSerialization() throws Exception {
    // #51118 - loader is not deserialized correctly.
    XMLDataObject.Loader loader = new XMLDataObject.Loader();
    NbMarshalledObject marsh = new NbMarshalledObject(loader);
    XMLDataObject.Loader loader2 = (XMLDataObject.Loader)marsh.get();
}
项目:incubator-netbeans    文件:NbSheet.java   
/** Deserialize this property sheet. */
@Override
public void readExternal (ObjectInput in)
throws IOException, ClassNotFoundException {
    try {
        super.readExternal(in);
    } catch (SafeException se) {
        // ignore--we really do not care about the explorer manager that much
        //System.err.println("ignoring a SafeException: " + se.getLocalizedMessage ());
    }
    Object obj = in.readObject ();

    if (obj instanceof NbMarshalledObject || obj instanceof ExplorerManager) {
        // old version read the Boolean
        global = ((Boolean)in.readObject()).booleanValue();
    } else {
        Node[] ns;

        if (obj == null) {
            // handles can also be null for global 
            // property sheet
            ns = TopComponent.getRegistry().getActivatedNodes();
        } else {
            // new version, first read the nodes and then the global boolean
            Node.Handle[] arr = (Node.Handle[])obj;

            try {
                ns = NodeOp.fromHandles (arr);
            } catch (IOException ex) {
                Exceptions.attachLocalizedMessage(ex,
                                                  NbBundle.getBundle(NbSheet.class).getString("EXC_CannotLoadNodes"));
                Logger.getLogger(NbSheet.class.getName()).log(Level.WARNING, null, ex);
                ns = new Node[0];
            }
        }

        global = in.readBoolean ();

        setNodes(ns, true, "readExternal"); // NOI18N
    }

    /*
          if (obj instanceof Boolean) {
            global = (Boolean)in.readObject ()

          global = ((Boolean)in.readObject()).booleanValue();
    /*
          // start global listening if needed, but wait until
          // deserialization is done (ExplorerManager is uses
          // post-deserialization validating too, so we are forced
          // to use it)
          ((ObjectInputStream)in).registerValidation(
            new ObjectInputValidation () {
              public void validateObject () {
                updateGlobalListening(false);
              }
            }, 0
          );
    */
    // JST: I guess we are not and moreover the type casting is really ugly
    //      updateGlobalListening (global);
}
项目:incubator-netbeans    文件:DefaultAttributes.java   
/** Sets an marshaled attribute to the table.
*/
final void setMarshalledAttr(String fileName, String attrName, NbMarshalledObject obj) {
    setAttr(fileName, attrName, obj);
}
项目:studio    文件:DefaultAttributes.java   
/** Sets an marshaled attribute to the table.
*/
final void setMarshalledAttr (
    String fileName, String attrName, NbMarshalledObject obj
) {
    setAttr (fileName, attrName, obj);
}
项目:incubator-netbeans    文件:DataEditorSupportTest.java   
private void doGetOpenedPanesWorksAfterDeserialization (int size) throws Exception {
    support().open ();

    waitEQ ();

    CloneableEditor ed = (CloneableEditor)support().getRef ().getAnyComponent ();

    JEditorPane[] panes = getPanes();
    assertNotNull (panes);
    assertEquals ("One is there", 1, panes.length);

    NbMarshalledObject marshall = new NbMarshalledObject (ed);
    ed.close ();

    panes = getPanes();
    assertNull ("No panes anymore", panes);

    DataObject oldObj = DataObject.find (fileObject);
    oldObj.setValid (false);

    expectedSize = size;

    ed = (CloneableEditor)marshall.get ();

    DataObject newObj = DataObject.find (fileObject);

    if (oldObj == newObj) {
        fail ("Object should not be the same, new one shall be created after marking the old invalid");
    }

    panes = getPanes ();
    assertNotNull ("One again", panes);
    assertEquals ("One is there again", 1, panes.length);
}