use of org.moe.idea.maven.MOEMavenTask in project moe-ide-integration by multi-os-engine.
the class MOEGenerateActionsAndOutletsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Module module = (Module) dataContext.getData(LangDataKeys.MODULE.getName());
if (module == null) {
Messages.showErrorDialog("Failed to locate module", "Actions and Outlets Generation Error");
return;
}
boolean isMaven = ModuleUtils.isMOEMavenModule(module);
if (!isMaven) {
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();
} 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";
}
Messages.showErrorDialog(message, "Actions and Outlets Generation Error");
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(module.getProject());
toolWindow.show();
}
});
} finally {
progress.popState();
}
}
private void runInternal() throws IOException, ExecutionException {
final GeneralCommandLine commandLine = MOEGradleRunner.construct(module, "moeGenerateUIObjCInterfaces");
final OSProcessHandler handler = new OSProcessHandler(commandLine);
handler.setShouldDestroyProcessRecursively(true);
// Configure output
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(module.getProject());
toolWindow.clear();
handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if (ProcessOutputTypes.STDERR.equals(outputType)) {
toolWindow.error(event.getText());
} else if (ProcessOutputTypes.STDOUT.equals(outputType)) {
toolWindow.log(event.getText());
}
}
});
handler.startNotify();
// Start and wait
handler.waitFor();
final int exitValue = handler.getProcess().exitValue();
if (exitValue != 0) {
throw new IOException(ACTION_TITLE + " finished with non-zero exit value (" + exitValue + ")");
}
}
}, ACTION_TITLE, true, module.getProject());
} else {
CompilerTask compilerTask = new CompilerTask(module.getProject(), "", false, true, true, true);
compilerTask.start(new Runnable() {
@Override
public void run() {
MOEMavenTask task = new MOEMavenTask(module, ACTION_TITLE, false);
task.setGoal("moe:generateUIObjCInterfaces");
if (!task.runTask()) {
ModuleUtils.runInDispatchedThread(new Runnable() {
@Override
public void run() {
Messages.showErrorDialog("Unable run generation", "Actions and Outlets Generation Error");
}
});
}
}
}, null);
ModuleUtils.runInDispatchedThread(new Runnable() {
@Override
public void run() {
MOEMavenTask task = new MOEMavenTask(module, ACTION_TITLE, false);
task.setGoal("moe:generateUIObjCInterfaces");
if (!task.runTask()) {
Messages.showErrorDialog("Unable run generation", "Actions and Outlets Generation Error");
}
}
});
}
}
use of org.moe.idea.maven.MOEMavenTask in project moe-ide-integration by multi-os-engine.
the class MOERefreshXcodeProject method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Module module = (Module) dataContext.getData(LangDataKeys.MODULE.getName());
if (module == null) {
Messages.showErrorDialog("Failed to locate module", "Injecting/Refreshing Xcode Settings Error");
return;
}
boolean isMaven = ModuleUtils.isMOEMavenModule(module);
if (!isMaven) {
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();
} 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";
}
Messages.showErrorDialog(message, "Injecting/Refreshing Xcode Settings Error");
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(module.getProject());
toolWindow.show();
}
});
} finally {
progress.popState();
}
}
private void runInternal() throws IOException, ExecutionException {
final GeneralCommandLine commandLine = MOEGradleRunner.construct(module, "moeUpdateXcodeSettings");
final OSProcessHandler handler = new OSProcessHandler(commandLine);
handler.setShouldDestroyProcessRecursively(true);
// Configure output
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(module.getProject());
toolWindow.clear();
handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if (ProcessOutputTypes.STDERR.equals(outputType)) {
toolWindow.error(event.getText());
} else if (ProcessOutputTypes.STDOUT.equals(outputType)) {
toolWindow.log(event.getText());
}
}
});
handler.startNotify();
// Start and wait
handler.waitFor();
final int exitValue = handler.getProcess().exitValue();
if (exitValue != 0) {
throw new IOException(ACTION_TITLE + " finished with non-zero exit value (" + exitValue + ")");
}
}
}, ACTION_TITLE, true, module.getProject());
} else {
CompilerTask compilerTask = new CompilerTask(module.getProject(), "", false, true, true, true);
compilerTask.start(new Runnable() {
@Override
public void run() {
MOEMavenTask task = new MOEMavenTask(module, ACTION_TITLE, false);
task.setGoal("moe:updateXcodeSettings");
if (!task.runTask()) {
ModuleUtils.runInDispatchedThread(new Runnable() {
@Override
public void run() {
Messages.showErrorDialog("Unable to refresh Xcode project", "Injecting/Refreshing Xcode Settings Error");
}
});
}
}
}, null);
ModuleUtils.runInDispatchedThread(new Runnable() {
@Override
public void run() {
MOEMavenTask task = new MOEMavenTask(module, ACTION_TITLE, false);
task.setGoal("moe:updateXcodeSettings");
if (!task.runTask()) {
Messages.showErrorDialog("Unable to refresh Xcode project", "Injecting/Refreshing Xcode Settings Error");
}
}
});
}
}
Aggregations