Package org.locationtech.udig.project.internal

Examples of org.locationtech.udig.project.internal.BlackboardEntry


        }
        if (key == null)
            return null;

        // look up the entry
        BlackboardEntry entry = blackboard.get(key);
        if (entry != null) {
            if (entry.getObject() != null) {
                return entry.getObject();
            } else {
                Object object = null;
                try {
                    // have to load from memento
                    String memento2 = entry.getMemento();
                    if (memento2 == null || memento2.length() == 0) {
                        return null;
                    }
                    XMLMemento memento = XMLMemento.createReadRoot(new StringReader(memento2));
                    IPersister<Object> persister = (IPersister<Object>) findPersister(entry,
                            memento);
                    if (persister != null) {
                        object = persister.load(memento);
                        entry.setObject(object);
                        entry.setObjectClass(object.getClass());
                    } else {
                        // real object which cannot be saved between runs
                    }
                } catch (Exception e) {
                    String msg = "Error loading content: " + entry.getObjectClass(); //$NON-NLS-1$
                    IStatus status = new Status(IStatus.WARNING, ProjectPlugin.ID, 0, msg, e); //$NON-NLS-1$
                    ProjectPlugin.getPlugin().getLog().log(status);
                }

                return object;
View Full Code Here


    public Object remove(String key) {
        if (key == null)
            return null;

        // look up the entry
        BlackboardEntry entry = blackboard.remove(key);
        if (entry == null) {
            return null;
        }
        Object oldValue = entry.getObject();
        entry.setMemento(null);
        entry.setObject(null);

        BlackboardEvent event = new BlackboardEvent(this, key, oldValue, null);
        for (IBlackboardListener l : listeners) {
            try {
                l.blackBoardChanged(event);
View Full Code Here

        if (value == null) {
            this.remove(key);
            return;
        }
        Object oldValue = null;
        BlackboardEntry entry = blackboard.get(key);

        if (entry == null) {
            entry = createEntry(key, value);
        } else {
            oldValue = entry.getObject();
        }
        // set the cache
        entry.setObject(value);

        // find the persister to save the state
        @SuppressWarnings("unchecked")
        IPersister<Object> persister = (IPersister<Object>) findPersister(entry, null);
        try {
            if (persister != null) {
                XMLMemento memento = XMLMemento.createWriteRoot("blackboardContent"); //$NON-NLS-1$
                persister.save(value, memento);
                memento.putString("internalObjectClassStorage", entry.getObjectClass().getName()); //$NON-NLS-1$

                StringWriter writer = new StringWriter();
                memento.save(writer);
                entry.setMemento(writer.getBuffer().toString());
            } else {
                // this is a "real" object that cannot be shared between runs
            }
        } catch (Exception e) {
            String msg = "Error persisting content: " + value.getClass(); //$NON-NLS-1$
View Full Code Here

            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
        case ProjectPackage.BLACKBOARD_ENTRY: {
            BlackboardEntry blackboardEntry = (BlackboardEntry) theEObject;
            T result = caseBlackboardEntry(blackboardEntry);
            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.internal.BlackboardEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.