use of org.moe.document.pbxproj.ProjectException 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();
}
});
}
use of org.moe.document.pbxproj.ProjectException in project moe-ide-integration by multi-os-engine.
the class GeneratorRunner method run.
private void run() {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress == null) {
progress = new EmptyProgressIndicator();
}
progress.pushState();
try {
progress.setText(ACTION_PROGRESS_LABEL);
runInternal(progress);
} catch (final Throwable t) {
t.printStackTrace(System.err);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
String message = t.getMessage();
if (message == null || message.length() == 0) {
message = "Unknown error";
}
String title = test ? "Test Binding Error" : "Generate Binding Error";
Messages.showErrorDialog(message, title);
}
});
} finally {
progress.popState();
}
}
private void runInternal(final ProgressIndicator progress) throws ProjectException, IOException {
String s = null;
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(module.getProject());
toolWindow.clear();
progress.setFraction(0.1);
final StringBuilder errorBuilder = new StringBuilder();
String modulePath = ModuleUtils.getModulePath(module);
File moduleFile = new File(modulePath);
progress.setFraction(0.2);
GradleExec exec = new GradleExec(moduleFile);
exec.getArguments().add("moeNatJGen");
exec.getArguments().add("-Draw-binding-output");
exec.getArguments().add("-Dmoe.binding.conf=" + coonfigurationFile.getPath());
if (test) {
exec.getArguments().add("-Dmoe.natjgen.testrun=true");
}
if (keep) {
exec.getArguments().add("-Dmoe.keep.natjgen");
}
ExecRunner runner = exec.getRunner();
runner.getBuilder().directory(moduleFile);
runner.setListener(new ExecRunnerBase.ExecRunnerListener() {
@Override
public void stdout(String line) {
toolWindow.printNormalMessage(line + "\n");
}
@Override
public void stderr(String line) {
toolWindow.printErrorMessage(line + "\n");
errorBuilder.append(line);
errorBuilder.append("\n");
}
});
runner.run(new IKillListener() {
@Override
public boolean needsKill() {
return progress.isCanceled();
}
});
progress.setFraction(0.9);
module.getProject().getBaseDir().getFileSystem().refresh(true);
progress.setFraction(1.0);
final String errorMessage = errorBuilder.toString();
if (errorMessage == null || errorMessage.isEmpty()) {
String format = test ? "Test successful" : "Generate successful";
toolWindow.balloon(MessageType.INFO, format);
} else {
String format = test ? "Test Error" : "Generate Error";
toolWindow.balloon(MessageType.INFO, format);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
String title = test ? "Test Binding Error" : "Generate Binding Error";
Messages.showErrorDialog(errorMessage, title);
}
});
}
}
}, ACTION_TITLE, true, module.getProject());
}
Aggregations