Search in sources :

Example 1 with InfoPlistManager

use of org.moe.editors.InfoPlistManager in project moe-ide-integration by multi-os-engine.

the class XcodeEditor method initManagers.

private void initManagers(VirtualFile virtualFile) {
    this.fileDocumentManager = FileDocumentManager.getInstance();
    this.xcodeProjectDocument = fileDocumentManager.getDocument(virtualFile);
    xcodeProjectDocument.addDocumentListener(new com.intellij.openapi.editor.event.DocumentListener() {

        @Override
        public void beforeDocumentChange(com.intellij.openapi.editor.event.DocumentEvent documentEvent) {
        }

        @Override
        public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent documentEvent) {
            reloadXcodeProjectFile();
        }
    });
    try {
        this.xcodeEditorManager = new XcodeEditorManager(null, xcodeProjectDocument.getText());
    } catch (ProjectException e) {
        e.printStackTrace();
    }
    xcodeEditorManager.setListener(new DocumentChangeListener() {

        @Override
        public void documentChanged() {
            saveXcodeDocument();
        }
    });
    this.projectName = EditorUtil.getXcodeProjectName(new File(virtualFile.getPath()));
    xcodeEditorManager.setProjectName(projectName);
    String root = virtualFile.getParent().getParent().getPath();
    File mainInfoPlist = getFileFromXcodeConfiguration(root, xcodeEditorManager.getInfoMainPlist());
    VirtualFile mainInfoVirtualFile = project.getBaseDir().getFileSystem().findFileByPath(mainInfoPlist.getAbsolutePath());
    this.mainInfoPlistDocument = fileDocumentManager.getDocument(mainInfoVirtualFile);
    try {
        this.mainInfoPlistManager = new InfoPlistManager(mainInfoPlistDocument.getText());
    } catch (Exception e) {
        LOG.error("Unable read main Info.plist", e);
    }
    mainInfoPlistManager.setListener(new DocumentChangeListener() {

        @Override
        public void documentChanged() {
            saveMainInfoPlistDocument();
        }
    });
    mainInfoPlistDocument.addDocumentListener(new com.intellij.openapi.editor.event.DocumentListener() {

        @Override
        public void beforeDocumentChange(com.intellij.openapi.editor.event.DocumentEvent documentEvent) {
        }

        @Override
        public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent documentEvent) {
            reloadMainInfoPlist();
        }
    });
    File testInfoPlist = getFileFromXcodeConfiguration(root, xcodeEditorManager.getInfoTestPlist());
    VirtualFile testInfoVirtualFile = project.getBaseDir().getFileSystem().findFileByPath(testInfoPlist.getAbsolutePath());
    this.testInfoPlistDocument = fileDocumentManager.getDocument(testInfoVirtualFile);
    try {
        this.testInfoPlistManager = new InfoPlistManager(testInfoPlistDocument.getText());
    } catch (Exception e) {
        LOG.error("Unable read test Info.plist", e);
    }
    testInfoPlistManager.setListener(new DocumentChangeListener() {

        @Override
        public void documentChanged() {
            saveTestInfoPlistDocument();
        }
    });
    testInfoPlistDocument.addDocumentListener(new com.intellij.openapi.editor.event.DocumentListener() {

        @Override
        public void beforeDocumentChange(com.intellij.openapi.editor.event.DocumentEvent documentEvent) {
        }

        @Override
        public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent documentEvent) {
            reloadTestInfoPlist();
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectException(org.moe.document.pbxproj.ProjectException) ProjectException(org.moe.document.pbxproj.ProjectException) XcodeEditorManager(org.moe.editors.XcodeEditorManager) DocumentChangeListener(org.moe.editors.DocumentChangeListener) InfoPlistManager(org.moe.editors.InfoPlistManager) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 ProjectException (org.moe.document.pbxproj.ProjectException)1 DocumentChangeListener (org.moe.editors.DocumentChangeListener)1 InfoPlistManager (org.moe.editors.InfoPlistManager)1 XcodeEditorManager (org.moe.editors.XcodeEditorManager)1