Package bndtools.editor.model

Examples of bndtools.editor.model.IDocumentWrapper


    }

    private IDocument getDocument() {
        IDocumentProvider docProvider = getDocumentProvider();
        IEditorInput input = getEditorInput();
        return new IDocumentWrapper(docProvider.getDocument(input));
    }
View Full Code Here


        }

        final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
        IDocument document = docProvider.getDocument(input);
        try {
            model.loadFrom(new IDocumentWrapper(document));
            model.setBndResourceName(resourceName);

            if (resource != null) {
                model.setBndResource(resource.getLocation().toFile());
            }
            // model.addPropertyChangeListener(modelListener);
        } catch (IOException e) {
            throw new PartInitException("Error reading editor input.", e);
        }

        // Ensure the field values are updated if the file content is replaced
        docProvider.addElementStateListener(new IElementStateListener() {
            public void elementMoved(Object originalElement, Object movedElement) {}

            public void elementDirtyStateChanged(Object element, boolean isDirty) {}

            public void elementDeleted(Object element) {}

            public void elementContentReplaced(Object element) {
                try {
                    model.loadFrom(new IDocumentWrapper(docProvider.getDocument(element)));
                } catch (IOException e) {
                    logger.logError("Error loading model from document.", e);
                }
            }
View Full Code Here

                final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
                final IDocument document = docProvider.getDocument(getEditorInput());
                SWTConcurrencyUtil.execForControl(getEditorSite().getShell(), true, new Runnable() {
                    public void run() {
                        try {
                            model.loadFrom(new IDocumentWrapper(document));
                            updatePages();
                        } catch (IOException e) {
                            logger.logError("Failed to reload document", e);
                        }
                    }
View Full Code Here

    }

    private IDocument getDocument() {
        IDocumentProvider docProvider = getDocumentProvider();
        IEditorInput input = getEditorInput();
        return new IDocumentWrapper(docProvider.getDocument(input));
    }
View Full Code Here

        }

        final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
        IDocument document = docProvider.getDocument(input);
        try {
            model.loadFrom(new IDocumentWrapper(document));
            model.setBndResourceName(resourceName);

            if (resource != null) {
                model.setBndResource(resource.getLocation().toFile());
            }
            // model.addPropertyChangeListener(modelListener);
        } catch (IOException e) {
            throw new PartInitException("Error reading editor input.", e);
        }

        // Ensure the field values are updated if the file content is replaced
        docProvider.addElementStateListener(new IElementStateListener() {

            String savedString = null;

            public void elementMoved(Object originalElement, Object movedElement) {}

            public void elementDirtyStateChanged(Object element, boolean isDirty) {}

            public void elementDeleted(Object element) {}

            public void elementContentReplaced(Object element) {
                try {
                    IDocumentWrapper idoc = new IDocumentWrapper(docProvider.getDocument(element));
                    if (!saving.get()) {
                        model.loadFrom(idoc);
                    } else {
                        if (savedString != null) {
                            logger.logInfo("Putting back content that we almost lost!", null);
                            try {
                                idoc.replace(0, idoc.getLength(), savedString);
                            } catch (BadLocationException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                } catch (IOException e) {
                    logger.logError("Error loading model from document.", e);
                } finally {
                    savedString = null;
                }
            }

            public void elementContentAboutToBeReplaced(Object element) {
                // [cs] This check is here to attempt to save content that would be thrown away by a (misbehaving?) version control plugin.
                // Scenario: File is checked out by Perforce plugin.
                // This causes elementContentAboutToBeReplaced and elementContentReplaced callbacks to be fired.
                // However -- by the time that elementContentReplaced is called, the content inside of the IDocumentWrapper
                // is already replaced with the contents of the perforce file being checked out.
                // To avoid losing changes, we need to save the content here, then put that content BACK on to the document
                // in elementContentReplaced
                if (saving.get()) {
                    logger.logInfo("Content about to be replaced... Save it.", null);
                    savedString = new IDocumentWrapper(docProvider.getDocument(element)).get();
                }
            }
        });
    }
View Full Code Here

                final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
                final IDocument document = docProvider.getDocument(getEditorInput());
                SWTConcurrencyUtil.execForControl(getEditorSite().getShell(), true, new Runnable() {
                    public void run() {
                        try {
                            model.loadFrom(new IDocumentWrapper(document));
                            updatePages();
                        } catch (IOException e) {
                            logger.logError("Failed to reload document", e);
                        }
                    }
View Full Code Here

        if (editor instanceof BndEditor) {
            editModel = ((BndEditor) editor).getEditModel();
        } else {
            editModel = new BndEditModel();
            doc = FileUtils.readFully(bndFile);
            editModel.loadFrom(new IDocumentWrapper(doc));
        }

        String blueprintrelativePath = blueprintFile.getProjectRelativePath().toString();

        updateBundleBlueprintIfNecessary(editModel, blueprintrelativePath);

        updateIncludeResourceIfNecessary(editModel, blueprintrelativePath, blueprintFile);

        if (editor == null) {
            editModel.saveChangesTo(new IDocumentWrapper(doc));
            FileUtils.writeFully(doc, bndFile, false);
        }
    }
View Full Code Here

TOP

Related Classes of bndtools.editor.model.IDocumentWrapper

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.