Search in sources :

Example 1 with BndEditor

use of bndtools.editor.BndEditor in project bndtools by bndtools.

the class BlueprintXmlFileWizard method updateBundleBlueprintAndIncludeResource.

private void updateBundleBlueprintAndIncludeResource(IFile blueprintFile, IFile bndFile) throws Exception {
    BndEditModel editModel;
    IEditorPart editor = ResourceUtil.findEditor(workbench.getActiveWorkbenchWindow().getActivePage(), bndFile);
    IDocument doc = null;
    if (editor instanceof BndEditor) {
        editModel = ((BndEditor) editor).getEditModel();
    } else {
        editModel = new BndEditModel(Central.getWorkspace());
        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);
    }
}
Also used : BndEditor(bndtools.editor.BndEditor) IEditorPart(org.eclipse.ui.IEditorPart) BndEditModel(aQute.bnd.build.model.BndEditModel) IDocumentWrapper(bndtools.editor.model.IDocumentWrapper) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

BndEditModel (aQute.bnd.build.model.BndEditModel)1 BndEditor (bndtools.editor.BndEditor)1 IDocumentWrapper (bndtools.editor.model.IDocumentWrapper)1 IDocument (org.eclipse.jface.text.IDocument)1 IEditorPart (org.eclipse.ui.IEditorPart)1